Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

How to attach progressbar to batchmove process

Sorry my bad English, maybe someone can help me..
here is my code.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls, DB,
  DBTables, ITProgrB;

type
  TForm1 = class(TForm)
    DBGridiep: TDBGrid;
    StatusBar1: TStatusBar;
    DBGridizp: TDBGrid;
    BitBt2: TBitBtn;
    BitBtn1: TBitBtn;
    Panel1: TPanel;
    BitBtn3: TBitBtn;
    MultiProgressBar1: TMultiProgressBar;
    procedure BitBtn1Click(Sender: TObject);
   
   
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}


procedure TForm1.BitBtn1Click(Sender: TObject);
begin
begin
   with DM.Qiepsk do begin
     DM.Qiepsk.Active;
     end;


   with DM.BMiepsk do begin
     Mode := batAppend;
     Source := DM.Qiepsk;
     Destination := DM.Tiepsk;
     Execute;
     end;
     end;
  end;

end
0
Jurcix
Asked:
Jurcix
1 Solution
 
classmateCommented:
This can't be done without appropriate events, and to my knowledge, TBatchMove has no events at all...

You might write an appending loop for this by yourself, or perhaps investigate the possibility of creating a descendant component of TBatchMove with such an event. But this also might not be possible.

regards, classmate.
0
 
ILECommented:
THERE IS ONE SOLUTION

IF U COPY FORM QUERY1 (SOURCE TABLE)
DEFINE FIELDS FOR EVERY ROW
AND IN ONCHANGE EVENT ON SOME ROW DO WHATEVER U WONA DO TO
MAKE SOME CAIND OF PROGRES BAR


U NOW HOW TO DEFINE FIELDS AREN'T YOU?
IF U DONT NOU JUST ASK
0
 
kretzschmarCommented:
hi,
have a similar older sample

using ttables

just use instead table1.recordcount
(table1 was the source, and your source
seems to be a query)
a variable, where you have stored the
count of to be moved records
(a simple
select count(*) from SameTablesAsTheQueryHave where SameConditionAsTheQueryHave
for example)

//copying a table to another alias
//set the recordcound of the tbatchmove
//to a stepvalue you want
//maybe CountOfToCopiedRecords/10
//will update 10 times the progessbar
procedure TForm1.Button1Click(Sender: TObject);
var Count : Integer;
begin
  table2.DatabaseName := ComboBox1.Text;
  Table2.TableName := Table1.TableName;
  try
    Table1.Open;
    Button1.Visible := False;
    Progressbar1.Visible := True;
    Label4.Visible := True;
    Label5.Visible := True;
    Table1.DisableControls;
    Count := 0;
    Application.ProcessMessages;
    While Not table1.EOF do
    begin
      BatchMove1.Execute;
      Count := Count + BatchMove1.MovedCount;
      Progressbar1.Position := Round((Table1.RecordCount/count)*100);
      label5.Caption := InttoStr(Count)+' of '+InttoStr(Table1.Recordcount)+' processed';
      Application.ProcessMessages;
      Table1.MoveBy(BatchMove1.RecordCount);
    end;
    Table1.Close;
    Table1.EnableControls;
    Panel3.Visible := False;
    Application.ProcessMessages;
    Showmessage('Filling was Successfull');
  except
    Showmessage('Cannot Open Table');
  end;
end;

hope thats it

meikl ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now