lo posto immediatamente e grazie sempre a tutti per il vs interessamento
Codice:
unit Pv100Read;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, ExtCtrls, DBCtrls,printers, StdCtrls,
QRPrntr, ComCtrls, jpeg;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ProgressBar1: TProgressBar;
Label1: TLabel;
Image1: TImage;
Label2: TLabel;
Label3: TLabel;
ADOConnection1: TADOConnection;
ADOTable1Kod: TIntegerField;
ADOTable1Descriptio: TWideStringField;
ADOTable1Qyt: TIntegerField;
ADOTable1Price: TIntegerField;
ADOTable1fpa: TIntegerField;
ADOTable1Data: TDateTimeField;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses RpPrint;
{$R *.dfm}
procedure ctrl_data;
var
i: integer;
db:Tadotable;
d1,d2:Tdate;
prova:string;
myYear,myyear2, myMonth,mymonth2, myDay:word;
data1,data2:string;
begin
i:=0;
form1.ProgressBar1.min:=0;
form1.ProgressBar1.Max:=form2.ADOTable1.RecordCount;
for I := 0 to form1.ADOTable1.RecordCount do
begin
form1.progressbar1.Position:=i;
form1.Refresh;
d1:=form1.ADOTable1Data.Value;
data1:=datetostr(d1);
data2:=datetostr(d2);
prova:=form1.ADOTable1Descriptio.Text;
if i=0 then
d2:=d1;
if abs(d1-d2)>200 then
begin
DecodeDate(d1, myYear, myMonth, myDay);
data1:=datetostr(d1);
data2:=datetostr(d2);
myyear:=myyear+1;
form1.ADOTable1Data.NewValue:=Encodedate(myYear,MyMonth,MyDay);
data1:=datetostr(form1.ADOTable1Data.NewValue);
d1:=form1.ADOTable1Data.NewValue;
d2:=d1;
end
else
d2:=d1;
form1.ADOTable1.Next;
form1.Label1.Caption:='Record N. '+inttostr(i)+' Of '+inttostr(form2.ADOTable1.RecordCount)+' '+ prova;
form1.Label1.Refresh;
end;
showmessage(inttostr(i));
begin
form1.ADOConnection1.BeginTrans; // Inizio una transazione
try
form1.ADOTable1.UpdateBatch(arAll); // Aggiorno il database con le modifiche apportate ai dati contenuti in ADOTable1
Form1.ADOConnection1.CommitTrans; // Tento di chiudere la transazione
except
on exception do
begin
showmessage('Processing Error');
form1.ADOConnection1.RollbackTrans;// Errore, qualcosa non va nei dati, annullo la transazione
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
rpprint.Form2.QuickRep1.Preview;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
rpprint.Form2.QuickRep1.PrinterSettings;
rpprint.Form2.QuickRep1.Print;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ctrl_data;
end;
end.
mentre il dbase e':