var lvForm:TSRMM ;
v_sql,displayname,ptime1,ptime2,v_status :string;
v_flag:integer;
lContextCurrent:TContextCurrent;
begin
if query1.RecordCount<=0 then
begin
dialogs.ShowMessage('记录为空,请先查询记录');
exit;
end;
ptime1:=FormatDateTime('yyyy-mm-dd hh:mm:ss',packtime1.DateTime);
ptime2:=FormatDateTime('yyyy-mm-dd hh:mm:ss',packtime2.DateTime);
try
lvForm:=TSRMM.Create(context);
if lvForm.ShowModal=Business.Forms.Controls.mrOk then
begin
query2.Close;
query2.Open;
query2.Edit;
query1.First;
while not query1.Eof do
begin
with query2 do
begin
insert;
FieldByName('SERIES').AsString:=query1.FieldByName('SERIES').AsString;
FieldByName('JOBNO').AsString:=query1.FieldByName('JOBNO').AsString;
FieldByName('PCNO').AsString:=query1.FieldByName('PCNO').AsString;
FieldByName('PKNO').AsString:=query1.FieldByName('PKNO').AsString;
FieldByName('KG').AsFloat:=query1.FieldByName('KG').AsFloat;
FieldByName('YARD').AsFloat:=query1.FieldByName('YARD').AsFloat;
FieldByName('LB').AsFloat:=query1.FieldByName('LB').AsFloat;
FieldByName('METER').AsFloat:=query1.FieldByName('METER').AsFloat;
FieldByName('COLORRGB').AsString:=query1.FieldByName('COLORRGB').AsString;
FieldByName('ADJUST').AsString:=query1.FieldByName('ADJUST').AsString;
FieldByName('PACKTIME').AsDateTime:=query1.FieldByName('PACKTIME').AsDateTime;
FieldByName('STATUS').AsString:=query1.FieldByName('STATUS').AsString;
FieldByName('STOWTYPE').AsString:=query1.FieldByName('STOWTYPE').AsString;
FieldByName('STOWAGE').AsString:=query1.FieldByName('STOWAGE').AsString;
FieldByName('FABNO').AsString:=query1.FieldByName('FABNO').AsString;
FieldByName('PARKNO').AsString:=query1.FieldByName('PARKNO').AsString;
FieldByName('PARKSEQ').AsString:=query1.FieldByName('PARKSEQ').AsString;
FieldByName('DELNO').AsString:=query1.FieldByName('DELNO').AsString;
FieldByName('DELSEQ').AsString:=query1.FieldByName('DELSEQ').AsString;
FieldByName('DEFECT').AsString:=query1.FieldByName('DEFECT').AsString;
FieldByName('RATE').AsString:=query1.FieldByName('RATE').AsString;
FieldByName('NEEDFABRIC').AsString:=query1.FieldByName('NEEDFABRIC').AsString;
FieldByName('LAYOUT').AsString:=query1.FieldByName('LAYOUT').AsString;
FieldByName('CLASSNO').AsString:=query1.FieldByName('CLASSNO').AsString;
FieldByName('SHIFT').AsString:=query1.FieldByName('SHIFT').AsString;
FieldByName('DEPOT').AsString:=query1.FieldByName('DEPOT').AsString;
FieldByName('ISDEF').AsString:=query1.FieldByName('ISDEF').AsString;
FieldByName('SEQNO').AsString:=query1.FieldByName('SEQNO').AsString;
FieldByName('stuffNO').AsString:=query1.FieldByName('stuffNO').AsString;
FieldByName('shelf').AsString:=query1.FieldByName('shelf').AsString;
FieldByName('defpoint').AsString:=query1.FieldByName('defpoint').AsString;
FieldByName('MEMO').AsString:=query1.FieldByName('MEMO').AsString;
//FieldByName('DEFPOINTS').AsInteger:=query1.FieldByName('DEFPOINTS').AsInteger;
end;
query1.Next;
end ;
try
query2.ApplyUpdates;
v_status:='备份到server243成功';
except
v_status:='备份server243失败';
dialogs.ShowMessage(v_status);
exit;
end;
v_sql:='delete from ledwaybc.cxd where (delno is not null) and ledwaybc.cxd.packtime between '''+ptime1+''' and '''+ptime2+'''';
v_flag:= Connection1.ExecuteSQL(v_sql);
lContextCurrent:=TContextCurrent.Create(Context);
displayname:=lContextCurrent.Operator.DisplayName;
if v_flag<>-1 then
begin
//v_status:='删除server185中ledwaybc.CXD中包装时间从'''+ptime1+''' 到 '''+ptime2+''' 记录成功,'''+v_status+'''' ;
v_status:='删除server185中ledwaybc.CXD中包装时间从'+ptime1+' 到 '+ptime2+' 记录成功,'+v_status+', 记录数量为'+Sysutils.IntToStr(v_flag) ;
v_sql:='insert into dbo.htt_deletedetail(username,demo,deltype) values('''+displayname+''','''+v_status+''',''备份删除'')';
connection1.ExecuteSQL(v_sql);
dialogs.ShowMessage(v_status);
end
else
begin
v_status:='删除server185中ledwaybc.CXD中包装时间从'+ptime1+' 到 '+ptime2+' 记录成功,'+v_status+',记录数量为'+Sysutils.IntToStr(v_flag) ;
v_sql:='insert into dbo.htt_deletedetail(username,demo,deltype) values('''+displayname+''','''+v_status+''',''备份删除'')';
connection1.ExecuteSQL(v_sql);
dialogs.ShowMessage(v_status);
end;
end;
finally
lvForm.Free
end ;
query1.Refresh;
end;
我运行以上程序出现错误 |