unit u_op_seae_TaskContrast_TD; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxLookAndFeelPainters, dxExEdtr, DB, ADODB, bsSkinCtrls, dxTL, dxDBCtrl, dxDBGrid, dxCntner, StdCtrls, cxCheckBox, Mask, DBCtrls, cxButtons, cxLabel, cxDBEdit, cxControls, cxContainer, cxEdit, cxTextEdit, cxMemo; type TfrmOp_seae_Taskcontrast_TD = class(TForm) bsknpnl1: TbsSkinPanel; cxdbm19_tzhrdm: TcxDBMemo; cxdbtxtdt4: TcxDBTextEdit; cxdbtxtdt2_cm: TcxDBTextEdit; cxdbtxtdt3_hc: TcxDBTextEdit; cxdbtxtdt6_zhg: TcxDBTextEdit; cxdbtxtdt7_xhg: TcxDBTextEdit; cxdbtxtdt8_mdd: TcxDBTextEdit; cxdbm27_mt: TcxDBMemo; cxdbm31_hwmsh: TcxDBMemo; cxdbtxtdt11_ystk: TcxDBTextEdit; cxdbtxtdt16_fffsh: TcxDBTextEdit; cxdbtxtdt20_jsh: TcxDBTextEdit; cxdbtxtdt21_bzh: TcxDBTextEdit; cxdbtxtdt22_zhl: TcxDBTextEdit; cxdbtxtdt23_chm: TcxDBTextEdit; cxdbm10_shr: TcxDBMemo; cxdbm1_fhr: TcxDBMemo; cxchckbx1_fhr: TcxCheckBox; cxchckbx10_shr: TcxCheckBox; cxchckbx19_tzhrdm: TcxCheckBox; cxchckbx31_hwmsh: TcxCheckBox; cxchckbx27_mt: TcxCheckBox; cxchckbx2_cm: TcxCheckBox; cxchckbx3_hc: TcxCheckBox; cxchckbx16_fffsh: TcxCheckBox; cxchckbx6_zhg: TcxCheckBox; cxchckbx7_xhg: TcxCheckBox; cxchckbx8_mdd: TcxCheckBox; cxchckbx11_ystk: TcxCheckBox; cxchckbx20_jsh: TcxCheckBox; cxchckbx21_bzh: TcxCheckBox; cxchckbx22_zhl: TcxCheckBox; cxchckbx23_chm: TcxCheckBox; cxchckbx32_jzxmx: TcxCheckBox; dxdbgrd32_jzxmx: TdxDBGrid; dxdbgrdclmndxdbgrd1Column1: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column2: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column3: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column4: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column5: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column6: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column7: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column8: TdxDBGridColumn; bsknpnl2: TbsSkinPanel; btn2Cancel: TbsSkinButton; btn1Import: TbsSkinButton; btn12: TbsSkinButton; ds_op_seae1_td: TDataSource; ds_op_ctn1_td: TDataSource; qry_op_seae_td: TADOQuery; qry_op_ctn_td: TADOQuery; cxchckbx14_zhyfsh: TcxCheckBox; cxdbtxtdt14_zhyfsh: TcxDBTextEdit; btn7: TbsSkinButton; btn8: TbsSkinButton; cxdbtxtdt12_tdfsh: TcxDBTextEdit; cxchckbx12_tdfsh: TcxCheckBox; cxchckbx13_fbtdfsh: TcxCheckBox; cxdbtxtdt13_fbtdfsh: TcxDBTextEdit; cxchckbx17_yfdd: TcxCheckBox; cxdbtxtdt17_yfdd: TcxDBTextEdit; cxchckbx18_dfdd: TcxCheckBox; cxdbtxtdt18_dfdd: TcxDBTextEdit; cxchckbx15_qdfsh: TcxCheckBox; cxdbtxtdt15_qdfsh: TcxDBTextEdit; cxchckbx5_cgs: TcxCheckBox; cxdbtxtdt5_cgs: TcxDBTextEdit; cxdbtxtdt9_jhd: TcxDBTextEdit; cxchckbx9_jhd: TcxCheckBox; grp1: TGroupBox; cxlbl1: TcxLabel; cxdbtxtdt15: TcxDBTextEdit; cxdbtxtdt16: TcxDBTextEdit; cxchckbx14: TcxCheckBox; cxchckbx21: TcxCheckBox; cxdbtxtdt23: TcxDBTextEdit; cxchckbx28: TcxCheckBox; Edit1: TEdit; lbl5: TLabel; cxchckbx24_wxpfl: TcxCheckBox; cxdbtxtdt24_wxpfl: TcxDBTextEdit; cxchckbx25_wxpbm: TcxCheckBox; cxdbtxtdt25_wxpbm: TcxDBTextEdit; cxchckbx26_lctfl: TcxCheckBox; cxdbtxtdt26_lctfl: TcxDBTextEdit; cxchckbx28_szwd: TcxCheckBox; cxdbtxtdt28_szwd: TcxDBTextEdit; cxchckbx29_zdwd: TcxCheckBox; cxdbtxtdt29_zdwd: TcxDBTextEdit; cxchckbx30_zgwd: TcxCheckBox; cxdbtxtdt30_zgwd: TcxDBTextEdit; cxchckbx6_zhgdm: TcxCheckBox; cxchckbx7_xhgdm: TcxCheckBox; cxdbtxtdt7_xhgdm: TcxDBTextEdit; cxchckbx8_mdddm: TcxCheckBox; cxdbtxtdt8_mdddm: TcxDBTextEdit; cxdbtxtdt6_zhgdm: TcxDBTextEdit; cxdbtxtdt8: TcxDBTextEdit; cxdbm1: TcxDBMemo; cxdbtxtdt9_jhddm: TcxDBTextEdit; cxchckbx9_jhddm: TcxCheckBox; procedure btn7Click(Sender: TObject); procedure btn8Click(Sender: TObject); procedure btn1ImportClick(Sender: TObject); procedure btn2CancelClick(Sender: TObject); private { Private declarations } m_qrytask:TADOQuery; m_qrysea:TADOQuery; m_qryctn:TADOQuery; procedure ContrastTDNR (); procedure ContrastFieldNr(fldname:string; chkctrol:TcxCheckBox; dbEDcontrol:TObject ); procedure SetContrastFieldBkcolor(dbEDcontrol:TObject;isSet:Boolean); public { Public declarations } procedure BindData(qrytask:TADOQuery;qrysea:TADOQuery;qryctn:TADOQuery); function DoImportData():Boolean ; function CancelImportData():Boolean; end; var frmOp_seae_Taskcontrast_TD: TfrmOp_seae_Taskcontrast_TD; implementation {$R *.dfm} uses u_main,u_op_seae_TaskContrast; procedure TfrmOp_seae_Taskcontrast_TD.BindData(qrytask:TADOQuery;qrysea:TADOQuery;qryctn:TADOQuery); var taskid:string; begin taskid:=qrytask.fieldbyname('任务编号').AsString; qry_op_seae_td.Active:=False; qry_op_seae_td.Parameters[0].Value:=taskid; qry_op_seae_td.Active:=True; qry_op_ctn_td.Active:=False; qry_op_ctn_td.Parameters[0].Value:=taskid; qry_op_ctn_td.Active:=True; m_qrytask:=qrytask; m_qrysea:=qrysea; m_qryctn:=qryctn; ContrastTDNR(); end; procedure TfrmOp_seae_Taskcontrast_TD.ContrastTDNR (); begin if(m_qrysea=nil )or(m_qrysea.Recordset=nil) or (m_qrysea.Recordset.RecordCount<1) then begin btn1Import.Enabled:=False; Exit; end else btn1Import.Enabled:=True; if(m_qrytask<>nil) and (m_qrytask.recordset<>nil) and (m_qrytask.fieldbyname('是否完成').AsInteger =1) then btn2Cancel.Enabled:=False; //发货人-->发货人代码 ContrastFieldNr('发货人代码',cxchckbx1_fhr,cxdbm1_fhr); ContrastFieldNr('船名',cxchckbx2_cm,cxdbtxtdt2_cm); ContrastFieldNr('航次',cxchckbx3_hc,cxdbtxtdt3_hc); ContrastFieldNr('船公司',cxchckbx5_cgs,cxdbtxtdt5_cgs); ContrastFieldNr('装货港',cxchckbx6_zhg,cxdbtxtdt6_zhg); ContrastFieldNr('卸货港',cxchckbx7_xhg,cxdbtxtdt7_xhg); ContrastFieldNr('目的地',cxchckbx8_mdd,cxdbtxtdt8_mdd); ContrastFieldNr('交货地点',cxchckbx9_jhd,cxdbtxtdt9_jhd); ContrastFieldNr('装港代码',cxchckbx6_zhgdm,cxdbtxtdt6_zhgdm); ContrastFieldNr('卸货代码',cxchckbx7_xhgdm,cxdbtxtdt7_xhgdm); ContrastFieldNr('目的地代码',cxchckbx8_mdddm,cxdbtxtdt8_mdddm); ContrastFieldNr('交货代码',cxchckbx9_jhddm,cxdbtxtdt9_jhddm); ContrastFieldNr('收货人代码',cxchckbx10_shr,cxdbm10_shr); ContrastFieldNr('运输条款',cxchckbx11_ystk,cxdbtxtdt11_ystk); ContrastFieldNr('提单份数',cxchckbx12_tdfsh,cxdbtxtdt12_tdfsh); ContrastFieldNr('副本提单份数',cxchckbx13_fbtdfsh,cxdbtxtdt13_fbtdfsh); ContrastFieldNr('装运方式',cxchckbx14_zhyfsh,cxdbtxtdt14_zhyfsh); ContrastFieldNr('签单方式',cxchckbx15_qdfsh,cxdbtxtdt15_qdfsh); ContrastFieldNr('付费方式',cxchckbx16_fffsh,cxdbtxtdt16_fffsh); ContrastFieldNr('预付地点',cxchckbx17_yfdd,cxdbtxtdt17_yfdd); ContrastFieldNr('到付地点',cxchckbx18_dfdd,cxdbtxtdt18_dfdd); ContrastFieldNr('通知人代码',cxchckbx19_tzhrdm,cxdbm19_tzhrdm); ContrastFieldNr('件数',cxchckbx20_jsh,cxdbtxtdt20_jsh); ContrastFieldNr('包装',cxchckbx21_bzh,cxdbtxtdt21_bzh); ContrastFieldNr('重量',cxchckbx22_zhl,cxdbtxtdt22_zhl); ContrastFieldNr('尺码',cxchckbx23_chm,cxdbtxtdt23_chm); ContrastFieldNr('危险品分类',cxchckbx24_wxpfl,cxdbtxtdt24_wxpfl); ContrastFieldNr('危险品编号',cxchckbx25_wxpbm,cxdbtxtdt25_wxpbm); ContrastFieldNr('冷藏通风量',cxchckbx26_lctfl,cxdbtxtdt26_lctfl); ContrastFieldNr('唛头',cxchckbx27_mt,cxdbm27_mt); ContrastFieldNr('设置温度',cxchckbx28_szwd,cxdbtxtdt28_szwd); ContrastFieldNr('最低温度',cxchckbx29_zdwd,cxdbtxtdt29_zdwd); ContrastFieldNr('最高温度',cxchckbx30_zgwd,cxdbtxtdt30_zgwd); ContrastFieldNr('货物描述',cxchckbx31_hwmsh,cxdbm31_hwmsh); cxchckbx32_jzxmx.Checked:=true; // ContrastFieldNr('集装箱明细',cxchckbx32_jzxmx,dxdbgrd32_jzxmx); end; procedure TfrmOp_seae_Taskcontrast_TD.ContrastFieldNr(fldname:string; chkctrol:TcxCheckBox; dbEDcontrol:TObject ); begin SetContrastFieldBkcolor( dbEDcontrol,False); chkctrol.Checked:=False; if(qry_op_seae_td.FieldByName(fldname).AsString='') then begin if(m_qrysea.FieldByName(fldname).AsString<>'') then SetContrastFieldBkcolor( dbEDcontrol,True); end else if(m_qrysea.FieldByName(fldname).AsString<> qry_op_seae_td.FieldByName(fldname).AsString) then begin SetContrastFieldBkcolor( dbEDcontrol,True); chkctrol.Checked:=True; end; end; procedure TfrmOp_seae_Taskcontrast_TD.SetContrastFieldBkcolor(dbEDcontrol:TObject;isSet:Boolean); var bcolor:TColor; begin bcolor:=clWindow; if(isSet) then bcolor:=$00FCD6F7;//clFuchsia; if(dbEDcontrol is TcxDBTextEdit) then (dbEDcontrol as TcxDBTextEdit).Style.Color:=bcolor else if(dbEDcontrol is TcxDBMemo) then (dbEDcontrol as TcxDBMemo).Style.Color:=bcolor end; procedure TfrmOp_seae_Taskcontrast_TD.btn7Click(Sender: TObject); var i:Integer; begin for i :=0 to Self.Componentcount-1 do if( Self.Components[i] is TcxCheckBox ) then (Self.Components[i] as TcxCheckBox ).Checked :=True; end; procedure TfrmOp_seae_Taskcontrast_TD.btn8Click(Sender: TObject); var i:Integer; begin for i :=0 to Self.Componentcount -1 do if( Self.Components[i] is TcxCheckBox ) then (Self.Components[i] as TcxCheckBox ).Checked :=False; end; procedure TfrmOp_seae_Taskcontrast_TD.btn1ImportClick(Sender: TObject); begin // DoImportData(); end; procedure TfrmOp_seae_Taskcontrast_TD.btn2CancelClick(Sender: TObject); begin // CancelImportData(); end; function TfrmOp_seae_Taskcontrast_TD.DoImportData():Boolean; var sql,bsno,reportid,cnfields:string; begin Result:=True; if(m_qrysea<>nil) and (m_qrysea.Recordset<>nil) and (m_qrysea.Recordset.RecordCount>0) then begin try cnfields:='[编号],[代码],[尺寸],[箱型],[数量],[TEU],[表现形式]' +',[箱号],[封号],[件数],[包装],[重量],[尺码],[品名],[唛头]' +',[备注],[开],[掏],[货物描述],[提单号] '; bsno:=qry_op_seae_td.fieldbyname('编号').AsString; reportid:=qry_op_seae_td.fieldbyname('base_reportid').AsString; m_qrysea.Connection.BeginTrans; m_qrysea.Edit; if cxchckbx1_fhr.checked then m_qrysea.FieldByName('发货人代码').AsString :=qry_op_seae_td.FieldByName('发货人代码').AsString; if cxchckbx2_cm.checked then m_qrysea.FieldByName('船名').AsString :=qry_op_seae_td.FieldByName('船名').AsString; if cxchckbx3_hc.checked then m_qrysea.FieldByName('航次').AsString :=qry_op_seae_td.FieldByName('航次').AsString; if cxchckbx5_cgs.checked then m_qrysea.FieldByName('船公司').AsString :=qry_op_seae_td.FieldByName('船公司').AsString; if cxchckbx6_zhg.checked then m_qrysea.FieldByName('装货港').AsString :=qry_op_seae_td.FieldByName('装货港').AsString; if cxchckbx7_xhg.checked then m_qrysea.FieldByName('卸货港').AsString :=qry_op_seae_td.FieldByName('卸货港').AsString; if cxchckbx8_mdd.checked then m_qrysea.FieldByName('目的地').AsString :=qry_op_seae_td.FieldByName('目的地').AsString; if cxchckbx9_jhd.checked then m_qrysea.FieldByName('交货地点').AsString :=qry_op_seae_td.FieldByName('交货地点').AsString; if cxchckbx10_shr.checked then m_qrysea.FieldByName('收货人代码').AsString :=qry_op_seae_td.FieldByName('收货人代码').AsString; if cxchckbx11_ystk.checked then m_qrysea.FieldByName('运输条款').AsString :=qry_op_seae_td.FieldByName('运输条款').AsString; if cxchckbx12_tdfsh.checked then m_qrysea.FieldByName('提单份数').AsString :=qry_op_seae_td.FieldByName('提单份数').AsString; if cxchckbx13_fbtdfsh.checked then m_qrysea.FieldByName('副本提单份数').AsString :=qry_op_seae_td.FieldByName('副本提单份数').AsString; if cxchckbx14_zhyfsh.checked then m_qrysea.FieldByName('装运方式').AsString :=qry_op_seae_td.FieldByName('装运方式').AsString; if cxchckbx15_qdfsh.checked then m_qrysea.FieldByName('签单方式').AsString :=qry_op_seae_td.FieldByName('签单方式').AsString; if cxchckbx16_fffsh.checked then m_qrysea.FieldByName('付费方式').AsString :=qry_op_seae_td.FieldByName('付费方式').AsString; if cxchckbx17_yfdd.checked then m_qrysea.FieldByName('预付地点').AsString :=qry_op_seae_td.FieldByName('预付地点').AsString; if cxchckbx18_dfdd.checked then m_qrysea.FieldByName('到付地点').AsString :=qry_op_seae_td.FieldByName('到付地点').AsString; if cxchckbx19_tzhrdm.checked then m_qrysea.FieldByName('通知人代码').AsString :=qry_op_seae_td.FieldByName('通知人代码').AsString; if cxchckbx20_jsh.checked then m_qrysea.FieldByName('件数').AsString :=qry_op_seae_td.FieldByName('件数').AsString; if cxchckbx21_bzh.checked then m_qrysea.FieldByName('包装').AsString :=qry_op_seae_td.FieldByName('包装').AsString; if cxchckbx22_zhl.checked then m_qrysea.FieldByName('重量').AsString :=qry_op_seae_td.FieldByName('重量').AsString; if cxchckbx23_chm.checked then m_qrysea.FieldByName('尺码').AsString :=qry_op_seae_td.FieldByName('尺码').AsString; if cxchckbx24_wxpfl.checked then m_qrysea.FieldByName('危险品分类').AsString :=qry_op_seae_td.FieldByName('危险品分类').AsString; if cxchckbx25_wxpbm.checked then m_qrysea.FieldByName('危险品编号').AsString :=qry_op_seae_td.FieldByName('危险品编号').AsString; if cxchckbx26_lctfl.checked then m_qrysea.FieldByName('冷藏通风量').AsString :=qry_op_seae_td.FieldByName('冷藏通风量').AsString; if cxchckbx27_mt.checked then m_qrysea.FieldByName('唛头').AsString :=qry_op_seae_td.FieldByName('唛头').AsString; if cxchckbx28_szwd.checked then m_qrysea.FieldByName('设置温度').AsString :=qry_op_seae_td.FieldByName('设置温度').AsString; if cxchckbx29_zdwd.checked then m_qrysea.FieldByName('最低温度').AsString :=qry_op_seae_td.FieldByName('最低温度').AsString; if cxchckbx30_zgwd.checked then m_qrysea.FieldByName('最高温度').AsString :=qry_op_seae_td.FieldByName('最高温度').AsString; if cxchckbx31_hwmsh.checked then m_qrysea.FieldByName('货物描述').AsString :=qry_op_seae_td.FieldByName('货物描述').AsString; //if cxchckbx32_jzxmx.checked then m_qrysea.FieldByName('集装箱明细').AsString :=qry_op_seae_td.FieldByName('集装箱明细').AsString; if cxchckbx6_zhgdm.checked then m_qrysea.FieldByName('装港代码').AsString :=qry_op_seae_td.FieldByName('装港代码').AsString; if cxchckbx7_xhgdm.checked then m_qrysea.FieldByName('卸货代码').AsString :=qry_op_seae_td.FieldByName('卸货代码').AsString; if cxchckbx8_mdddm.checked then m_qrysea.FieldByName('目的地代码').AsString :=qry_op_seae_td.FieldByName('目的地代码').AsString; if cxchckbx9_jhddm.checked then m_qrysea.FieldByName('交货代码').AsString :=qry_op_seae_td.FieldByName('交货代码').AsString; m_qrysea.Post; sql:=Format(' delete from t_op_ctn where 编号=''%s'';',[bsno])+#13+#10 +' INSERT INTO [t_op_ctn] (' +cnfields +' ) ' +#13+#10 +' SELECT '+ cnfields + 'FROM [t_op_td_ctn] ' + Format(' where [base_reportid]=''%s'';',[reportid]); m_qrysea.Connection.Execute(sql); m_qryTask.Edit; m_qryTask.FieldByName('完成时间').AsDateTime:=Now; m_qryTask.FieldByName('是否完成').AsInteger:=1; m_qryTask.FieldByName('任务状态').AsString:='完成'; m_qryTask.post; sql:='INSERT INTO t_op_task_state ( [任务编号],[任务状态],[操作人])VALUES (''%s'' ,''%s'' ,''%s'')'; sql:=Format(sql,[m_qryTask.fieldbyname('任务编号').asstring,'完成',employee] ); m_qryTask.Connection.Execute(sql); m_qrysea.Connection.CommitTrans; m_qryTask.Requery(); Application.MessageBox(PChar('操作完成'),'信息提示'); frmOpSeae_TaskContrast.close; except on e:Exception do begin // on except m_qrysea.Connection.RollbackTrans; m_qrysea.Cancel(); Result:=False; Application.MessageBox(PChar('处理发生错误: '+E.Message),'信息提示'); end; end; end; end; function TfrmOp_seae_Taskcontrast_TD.CancelImportData():Boolean; var sql,bsno,reportid,cnfields:string; begin if( Application.MessageBox(PChar('您确实要直接结束该任务吗?'+#13#10+'结束任务将直接关闭任务!,是否结束任务?'),'信息提示',MB_YESNO+ MB_ICONQUESTION)<>IDYES) then Exit; // try //** m_qryTask.Connection.BeginTrans; m_qryTask.Edit; m_qryTask.FieldByName('完成时间').AsDateTime:=Now; m_qryTask.FieldByName('是否完成').AsInteger:=1; m_qryTask.FieldByName('任务状态').AsString:='结束'; m_qryTask.Post; // sql:='INSERT INTO t_op_task_state ( [任务编号],[任务状态],[操作人])VALUES (''%s'' ,''%s'' ,''%s'')'; sql:=Format(sql,[m_qryTask.fieldbyname('任务编号').asstring,'结束',employee] ); m_qryTask.Connection.Execute(sql); //** m_qryTask.Connection.CommitTrans; m_qryTask.Requery(); Application.MessageBox(PChar('操作完成'),'信息提示'); frmOpSeae_TaskContrast.close; except on e:Exception do begin // on except //** m_qryTask.Connection.RollbackTrans; Result:=False; Application.MessageBox(PChar('处理发生错误: '+E.Message),'信息提示'); end; end; end; end.