unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ADODB, StdCtrls, DB,StrUtils, TFlatEditUnit, TFlatButtonUnit,
TFlatTitlebarUnit, ExtCtrls, TFlatPanelUnit, TFlatProgressBarUnit;type
TForm1 = class(TForm)
EdtSpbm: TFlatEdit;
LblCaption: TLabel;
Button1: TFlatButton;
FlatTitlebar1: TFlatTitlebar;
FlatPanel1: TFlatPanel;
FlatButton1: TFlatButton;
LblTotal: TLabel;
pb: TFlatProgressBar;
FlatPanel2: TFlatPanel;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FlatButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{
步骤
1根据原月合计表是否有库存开始导记录,第一步导档案
2第二步导饰品对应的材料
3第三步导合计数
}
procedure TForm1.Button1Click(Sender: TObject);
var
StrConn:string;
AdoConn:TADOConnection;
Ds:TAdoDataSet;
sp:TAdoStoredProc;
//---------------------------------
//StrBm:string;
//intBm:integer;
strUpdate:string;
strUpdateJd:string;
strUpdateQg:string;
strTemp:string;
intCount:integer;
const
StrSpbmHead='AAA0406';
begin
//StrBm:='00000000';
//intBm:=0;
intCount:=0;
//---------------------------------------------------------------------------------------------------------
StrConn:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=zbjxc;Data Source=.';
AdoConn:=TAdoConnection.Create(nil);
Adoconn.LoginPrompt:=false;
AdoConn.ConnectionString:=StrConn;
AdoConn.Open;
//--------------------------------------
sp:=TAdoStoredProc.Create(nil);
sp.Connection:=AdoConn;
sp.ProcedureName:='sp_output';
sp.Parameters.AddParameter;
sp.Parameters.AddParameter;
//-------------------------------------
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=AdoConn;
Ds.CommandText:='select * from tb200406_yhj where f_qmsl>0 order by f_Bmbm';
Ds.open;
if ds.Eof and ds.Bof then
exit
else
begin
pb.Max:=ds.RecordCount;
pb.Position:=0;
strTemp:='if exists(select name from zbjxc.dbo.sysobjects where name=''TempTable'' and xtype=''U'') drop table TempTable';
adoconn.Execute(strTemp);
adoconn.Execute('SELECT * INTO TempTable FROM pssoft.dbo.tbda_sp WHERE f_Spbm LIKE ''aaa%''');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_sp');
adoconn.Execute('insert into pssoft.dbo.tbda_sp select * from TempTable'); adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_sp_cl');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbhj_yjxc');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_bmspjgdz'); Ds.First;
LblCaption.Caption:='正在导入数据...';
while not Ds.Eof do
begin
LblTotal.Caption:='已导入记录:'+inttostr(intCount)+' 条';
edtspbm.Text:=Ds.FieldValues['f_spbm'];
self.Refresh;
//StrBm:=dupeString('0',length(Strbm)-length(IntToStr(intBm+1)))+intToStr(intbm+1);
//------------导档案记录--导材料档案--导月合计-------------------------
sp.Close;
sp.Prepared:=false;
sp.Parameters[0].Value:=Ds.FieldValues['f_spbm'];
sp.Parameters[1].Value:=Ds.FieldValues['f_bmbm'];
sp.Prepared:=true;
sp.ExecProc();
//-----------以下三条更新实际成本、净度、切工-----------------------------------
StrUpdate:='update pssoft.dbo.tbda_sp set f_sjcb = (select f_qmje/f_qmsl from tb200406_yhj where f_spbm='''+Ds.FieldValues['f_spbm']+'''and f_bmbm='''+Ds.FieldValues['f_bmbm']+''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(StrUpdate);
strUpdateJd:='update pssoft.dbo.tbda_sp set f_JdBm=isnull((select tempjdbm from tb200406_spda where f_spbm='''+Ds.FieldValues['f_spbm']+'''),'''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(strUpdateJd);
strUpdateQg:='update pssoft.dbo.tbda_sp set f_QgBm=isnull((select tempqgbm from tb200406_spda where f_spbm='''+Ds.FieldValues['f_spbm']+'''),'''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(strUpdateQg);
//inc(intBm);
inc(intCount);
pb.Position:=intCount;
Ds.Next;
end;
end;
finally
Ds.Close;
Ds.Free;
sp.Close;
sp.Free;
AdoConn.Close;
AdoConn.Free;
end;
LblCaption.Caption:='处理完毕,已成功导入'+inttostr(intCount-1)+'条记录.';
end;procedure TForm1.FlatButton1Click(Sender: TObject);
begin
close;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ADODB, StdCtrls, DB,StrUtils, TFlatEditUnit, TFlatButtonUnit,
TFlatTitlebarUnit, ExtCtrls, TFlatPanelUnit, TFlatProgressBarUnit;type
TForm1 = class(TForm)
EdtSpbm: TFlatEdit;
LblCaption: TLabel;
Button1: TFlatButton;
FlatTitlebar1: TFlatTitlebar;
FlatPanel1: TFlatPanel;
FlatButton1: TFlatButton;
LblTotal: TLabel;
pb: TFlatProgressBar;
FlatPanel2: TFlatPanel;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FlatButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{
步骤
1根据原月合计表是否有库存开始导记录,第一步导档案
2第二步导饰品对应的材料
3第三步导合计数
}
procedure TForm1.Button1Click(Sender: TObject);
var
StrConn:string;
AdoConn:TADOConnection;
Ds:TAdoDataSet;
sp:TAdoStoredProc;
//---------------------------------
//StrBm:string;
//intBm:integer;
strUpdate:string;
strUpdateJd:string;
strUpdateQg:string;
strTemp:string;
intCount:integer;
const
StrSpbmHead='AAA0406';
begin
//StrBm:='00000000';
//intBm:=0;
intCount:=0;
//---------------------------------------------------------------------------------------------------------
StrConn:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=zbjxc;Data Source=.';
AdoConn:=TAdoConnection.Create(nil);
Adoconn.LoginPrompt:=false;
AdoConn.ConnectionString:=StrConn;
AdoConn.Open;
//--------------------------------------
sp:=TAdoStoredProc.Create(nil);
sp.Connection:=AdoConn;
sp.ProcedureName:='sp_output';
sp.Parameters.AddParameter;
sp.Parameters.AddParameter;
//-------------------------------------
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=AdoConn;
Ds.CommandText:='select * from tb200406_yhj where f_qmsl>0 order by f_Bmbm';
Ds.open;
if ds.Eof and ds.Bof then
exit
else
begin
pb.Max:=ds.RecordCount;
pb.Position:=0;
strTemp:='if exists(select name from zbjxc.dbo.sysobjects where name=''TempTable'' and xtype=''U'') drop table TempTable';
adoconn.Execute(strTemp);
adoconn.Execute('SELECT * INTO TempTable FROM pssoft.dbo.tbda_sp WHERE f_Spbm LIKE ''aaa%''');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_sp');
adoconn.Execute('insert into pssoft.dbo.tbda_sp select * from TempTable'); adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_sp_cl');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbhj_yjxc');
adoconn.Execute('TRUNCATE TABLE pssoft.dbo.tbda_bmspjgdz'); Ds.First;
LblCaption.Caption:='正在导入数据...';
while not Ds.Eof do
begin
LblTotal.Caption:='已导入记录:'+inttostr(intCount)+' 条';
edtspbm.Text:=Ds.FieldValues['f_spbm'];
self.Refresh;
//StrBm:=dupeString('0',length(Strbm)-length(IntToStr(intBm+1)))+intToStr(intbm+1);
//------------导档案记录--导材料档案--导月合计-------------------------
sp.Close;
sp.Prepared:=false;
sp.Parameters[0].Value:=Ds.FieldValues['f_spbm'];
sp.Parameters[1].Value:=Ds.FieldValues['f_bmbm'];
sp.Prepared:=true;
sp.ExecProc();
//-----------以下三条更新实际成本、净度、切工-----------------------------------
StrUpdate:='update pssoft.dbo.tbda_sp set f_sjcb = (select f_qmje/f_qmsl from tb200406_yhj where f_spbm='''+Ds.FieldValues['f_spbm']+'''and f_bmbm='''+Ds.FieldValues['f_bmbm']+''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(StrUpdate);
strUpdateJd:='update pssoft.dbo.tbda_sp set f_JdBm=isnull((select tempjdbm from tb200406_spda where f_spbm='''+Ds.FieldValues['f_spbm']+'''),'''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(strUpdateJd);
strUpdateQg:='update pssoft.dbo.tbda_sp set f_QgBm=isnull((select tempqgbm from tb200406_spda where f_spbm='''+Ds.FieldValues['f_spbm']+'''),'''') where f_spbm='''+Ds.FieldValues['f_spbm']+'''';
adoconn.Execute(strUpdateQg);
//inc(intBm);
inc(intCount);
pb.Position:=intCount;
Ds.Next;
end;
end;
finally
Ds.Close;
Ds.Free;
sp.Close;
sp.Free;
AdoConn.Close;
AdoConn.Free;
end;
LblCaption.Caption:='处理完毕,已成功导入'+inttostr(intCount-1)+'条记录.';
end;procedure TForm1.FlatButton1Click(Sender: TObject);
begin
close;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货