我是用一个界面的方式作的。
========================================
var
FrmOrderDistic: TFrmOrderDistic;
implementation
uses DatDM;
{$R *.DFM}
procedure TFrmOrderDistic.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TFrmOrderDistic.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TFrmOrderDistic.Button1Click(Sender: TObject);
var
XSQL:String;
i:Integer;
y:Integer;
x:Array[0..59] of String;
j:Integer;
z:Integer;
begin
DataModule1.ADODataSet1.Close;
XSQL:='SELECT COUNT(*) FROM DORDER WHERE 訂單狀態='+''''+'OK'+''''+' AND DATEPART(MM,接單日期)='+''''+ComboBox1.Text+'''';
DataModule1.ADODataSet1.CommandText:=XSQL;
DataModule1.ADODataSet1.Open;
y:=DataModule1.ADODataSet1.FieldByName ('COLUMN1').AsInteger;
for j:=1 to y do
begin
DataModule1.ADODataSet1.Close;
XSQL:='SELECT * FROM DORDER WHERE 訂單狀態='+''''+'OK'+''''+' AND DATEPART(MM,接單日期)='+''''+ComboBox1.Text+'''';
DataModule1.ADODataSet1.CommandText:=XSQL;
DataModule1.ADODataSet1.Open;
if DataModule1.ADODataSet1.RecordCount<>0 then
begin
for i:=0 to 59 do
begin
x:=DataModule1.ADODataSet1.Fields.AsString;
end;
end;
DataModule1.ADODataSet1.Close;
XSQL:='INSERT DFORDER (( 訂單號碼,鞋型編號,顏色編號,接單日期,工廠確認日,客戶確認日,預計交貨日,客戶訂單號, 客戶編號,转档日期,修改用戶) VALUES
('+''''+X[0]+''''+','+''''+X[1]+''''+','+''''+X[2]+''''+','+''''+X[3]+''''+','+'
'''+X[4]+'
'''+','+''''+X[5]+''''+','+''''+X[6]+''''+','+''''+X[7]+''''+','+''''+X[8]+''''+
','+''''+X
[57]+''''+','+''''+X[58]+''''+')';
DataModule1.ADOConnection1.Execute(XSQL);
for z:=1 to 48 do
begin
DataModule1.ADODataSet1.Close;
XSQL:='UPDATE DFORDER SET SIZE_'+IntToStr(z)+'='+''''+x[z+8]+''''+'WHERE 訂單號碼='+''''+x[0]+'''';
DataModule1.ADOConnection1.Execute(XSQL);
end;
DataModule1.ADODataSet1.Close;
XSQL:='DELETE DORDER WHERE 訂單號碼='+''''+x[0]+'''';
DataModule1.ADOConnection1.Execute(XSQL);
DataModule1.ADODataSet1.Close;
XSQL:='DELETE DIN WHERE 訂單號碼='+''''+x[0]+'''';
DataModule1.ADOConnection1.Execute(XSQL);
DataModule1.ADODataSet1.Close;
XSQL:='DELETE DOUT WHERE 訂單號碼='+''''+x[0]+'''';
DataModule1.ADOConnection1.Execute(XSQL);
DataModule1.ADODataSet1.Close;
XSQL:='DELETE DSTOCK WHERE 訂單號碼='+''''+x[0]+'''';
DataModule1.ADOConnection1.Execute(XSQL);
Label4.Caption:=x[0];
with Gauge1 do
begin
if (100 div y)=(100 / y) then
begin
progress:=progress+(100 div y);
end
else
begin
progress:=progress+(100 div y)+1;
end;
end;
end;
end;
end.