unit u_op_seae_mscbc; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, iWebPDFEditorLib_TLB, ExtCtrls, Buttons, DB, ADODB, bsSkinCtrls, DBCtrls, bsdbctrls, StdCtrls, RxLookup, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker, Mask, wwdblook, ComCtrls, bsSkinTabs, Wwdbigrd, Wwdbgrid, Grids, DBGridEh, cxControls, cxSplitter, Menus, ToolWin, ImgList, kbmMemTable,shellapi, IdAttachmentFile,IdText, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP,IdMessage,IdAttachment, RXSplit, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, SHDocVw; type TfrmOpSeae_mscbc = class(TForm) pnl1: TPanel; qry_op_seae: TADOQuery; ds_op_seae2: TDataSource; lbl38: TLabel; lbl39: TLabel; lbl40: TLabel; lbl41: TLabel; lbl42: TLabel; lbl43: TLabel; lbl44: TLabel; lbl45: TLabel; lbl47: TLabel; lbl48: TLabel; dbtxt1: TDBText; btn5: TbsSkinSpeedButton; lbl50: TLabel; bsknpnl1: TbsSkinPanel; lbldc: TLabel; dbedt3: TDBEdit; dbedt4: TDBEdit; dbedt5: TDBEdit; dbedt6: TDBEdit; dbedt7: TDBEdit; dbedt8: TDBEdit; RxDBLookupCombo1: TRxDBLookupCombo; dbedt9: TDBEdit; dbedt11: TDBEdit; dbedt12: TDBEdit; dbedt13: TDBEdit; scrlbx2: TScrollBox; bsknpnl4: TbsSkinPanel; lbl5: TLabel; lbl6: TLabel; lbl7: TLabel; lbl8: TLabel; lbl9: TLabel; lbl10: TLabel; lbl11: TLabel; lbl12: TLabel; lbl15: TLabel; lbl16: TLabel; lbl17: TLabel; lbl18: TLabel; lbl19: TLabel; lbl20: TLabel; lbl22: TLabel; lbl24: TLabel; lbl25: TLabel; lbl30: TLabel; lbl31: TLabel; lbl14: TLabel; lbl21: TLabel; lbl23: TLabel; lbl26: TLabel; lbl27: TLabel; lbl28: TLabel; lbl29: TLabel; lbl4: TLabel; lbl32: TLabel; lbl33: TLabel; lbl34: TLabel; lbl35: TLabel; lbl36: TLabel; lbl37: TLabel; dbedt1: TDBEdit; wdbdtmpckr1: TwwDBDateTimePicker; wdbdtmpckr2: TwwDBDateTimePicker; wdbdtmpckr4: TwwDBDateTimePicker; wdbdtmpckr5: TwwDBDateTimePicker; bskndbchckrdbx1: TbsSkinDBCheckRadioBox; dbmmo4: TDBMemo; dbmmo5: TDBMemo; dbmmo6: TDBMemo; dbmmo7: TDBMemo; dbmmo8: TDBMemo; dbedt2: TDBEdit; dbmmo9: TDBMemo; cxspltr1: TcxSplitter; pnl4_jjx: TPanel; bsknpnl2: TbsSkinPanel; wdblkpcmb1: TwwDBLookupCombo; bsknpnl3: TbsSkinPanel; lbl52: TLabel; dbtxtTEU: TDBText; lbl53: TLabel; dbtxt2: TDBText; dbtxt3: TDBText; lbl54: TLabel; dbtxt4: TDBText; lbl55: TLabel; lbl56: TLabel; dbtxt5: TDBText; dbedt14: TDBEdit; dbedt15: TDBEdit; dbedt16: TDBEdit; dbedt17: TDBEdit; dbedt18: TDBEdit; dbedt19: TDBEdit; dbedt20: TDBEdit; dbedt21: TDBEdit; dbedt22: TDBEdit; dbedt23: TDBEdit; dbedt24: TDBEdit; dbedt26: TDBEdit; dbedt29: TDBEdit; dbedt30: TDBEdit; dbedt32: TDBEdit; dbedt33: TDBEdit; dbedt35: TDBEdit; dbmmo3: TDBMemo; lbl3: TLabel; lbl2: TLabel; dbmmo2: TDBMemo; lbl1: TLabel; dbmmo1: TDBMemo; dbedt34: TDBEdit; dbedt36: TDBEdit; dbedt27: TDBEdit; dbedt28: TDBEdit; dbedt31: TDBEdit; pm1_tsk_vcMenu: TPopupMenu; mni_mniN1Confirm: TMenuItem; mni_mniN2ConfirmAndFinish: TMenuItem; il1: TImageList; tlb1: TToolBar; btn2Confirm: TToolButton; btnCancelTask: TToolButton; btn12: TToolButton; wwDBGrid1: TwwDBGrid; lbl57: TLabel; il2_taskmenu: TImageList; ds_op_ctn1: TDataSource; qry_op_ctn: TADOQuery; mailSend: TkbmMemTable; strngfldSendStringField: TStringField; strngfldSendField: TStringField; strngfldSendField2: TStringField; strngfldSendField3: TStringField; strngfldSendField4: TStringField; strngfldSendField5: TStringField; strngfldSendField6: TStringField; strngfldSendField7: TStringField; bsknpnl2_right: TbsSkinPanel; scrlbx1: TScrollBox; bsknpnl6_left: TbsSkinPanel; cxspltr2: TcxSplitter; spl2: TSplitter; lbl75: TLabel; lbl79: TLabel; dbmmo10: TDBMemo; lbl83: TLabel; dbedt37: TDBEdit; WebBrowser1: TWebBrowser; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; bsSkinPanel1: TbsSkinPanel; bsSkinButton2: TbsSkinButton; t_op_task_fieldvalue: TADOQuery; t_op_task_fieldvalue1: TDataSource; bsSkinButton50: TbsSkinButton; Label1: TLabel; DBEdit1: TDBEdit; procedure FormShow(Sender: TObject); procedure btnCoseClick(Sender: TObject); procedure btnCancelTaskClick(Sender: TObject); procedure mniN1ConfirmClick(Sender: TObject); procedure mni_mniN2ConfirmAndFinishClick(Sender: TObject); procedure btn1pdfDownloadClick(Sender: TObject); procedure cxspltr2Moved(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton50Click(Sender: TObject); private { Private declarations } m_pdfFileName:string; m_bsno:string; m_qryTask:TADOQuery; procedure InitialBusiData(); procedure openpdfFile(); function sendmail( mailSendTbl: TkbmMemTable;mailtype,bsno:string;ishtml:Boolean):Boolean; procedure InitialTDWindow(); procedure InitialCh_fee_edi_Window(); public { Public declarations } public procedure InitialData( qryTask:TADOQuery; bsno1,pdfpath:string); end; var frmOpSeae_mscbc: TfrmOpSeae_mscbc; implementation {$R *.dfm} uses my_sys_function,u_main, u_tree_main, u_data_share, u_sys_progress, u_op_seae_TaskContrast_TD, u_ch_fee_edi, u_op_letter; /// /// 临时目录 /// function GetWinTempPath: string; var TempDir: array[0..255] of char; begin GetTempPath(255, @TempDir); Result := strPas(TempDir); end; procedure TfrmOpSeae_mscbc.InitialData( qryTask:TADOQuery; bsno1,pdfpath:string ); var state,tasktype,strtmp:string; strsql:string; begin m_qryTask:=qryTask; m_bsno:=bsno1; m_pdfFileName:=pdfpath; tasktype:= m_qryTask.FieldByName('任务类型').AsString; state:=m_qryTask.fieldbyname('任务状态').AsString; //状态处理 btnCancelTask.Enabled:=False; btn2Confirm.Enabled:=False; mni_mniN1Confirm.Visible:=false; mni_mniN2ConfirmAndFinish.Visible:=False; if(m_qryTask.FieldByName('是否完成').AsInteger<1) then begin btnCancelTask.Enabled:=true; mni_mniN2ConfirmAndFinish.Visible:=true; btn2Confirm.Enabled:=True; if(state<>'PENDING') then mni_mniN1Confirm.Visible:=True; //btn1Forword.Enabled:=True; end ; end; procedure TfrmOpSeae_mscbc.InitialBusiData(); var strtmp,strtmp1:string; begin //通过编号获取数据信息 qry_op_seae.Close; qry_op_seae.SQL.clear; qry_op_seae.SQL.Add('select *,''主单'' BLTYPE from t_op_seae where 编号='''+ m_bsno + ''''); qry_op_seae.open; if (qry_op_seae.IsEmpty) then begin qry_op_seae.Close; qry_op_seae.SQL.clear; qry_op_seae.SQL.Add('SELECT AS_ID 编号,bl.主编号,bl.业务状态,bl.费用状态,bl.业务编号,bl.会计期间,bl.周次,bl.主提单号,bl.分提单号,bl.委托编号'); qry_op_seae.SQL.Add(',bl.装运方式,bl.委托单位,bl.发货人,bl.收货人,bl.通知人,bl.发货人代码,bl.收货人代码,bl.通知人代码,bl.代理,bl.代理内容'); qry_op_seae.SQL.Add(',bl.场站,bl.船名,bl.航次,bl.开船日期,bl.截港日期,bl.预抵日期,bl.起运港,bl.装货港,bl.装港代码,bl.卸货港,bl.卸货代码,bl.二程开船日期'); qry_op_seae.SQL.Add(',bl.二程港口,bl.二程船名,bl.二程航次,bl.目的地,bl.交货地点,bl.交货代码,bl.提单份数,bl.签单方式,bl.签单地点,bl.签单日期,bl.付费方式'); qry_op_seae.SQL.Add(',bl.预付地点,bl.到付地点,bl.运输条款,bl.唛头,bl.箱号封号,bl.件数包装,bl.货物描述,bl.货物名称,bl.货物重量,bl.货物尺码,bl.件数'); qry_op_seae.SQL.Add(',bl.包装,bl.重量,bl.尺码,bl.件数大写,bl.箱数大写,bl.箱型1,bl.箱型2,bl.箱型3,bl.箱型4,bl.箱型5,bl.箱型6,bl.箱型7,bl.箱型8,bl.箱型9'); qry_op_seae.SQL.Add(',bl.箱型10,bl.其他箱型,bl.箱TEU,bl.集装箱,bl.录入人,bl.录入日期,bl.操作员,bl.揽货人,bl.客服员,bl.航线,bl.船公司,bl.货代公司'); qry_op_seae.SQL.Add(',bl.备注,bl.报关行,bl.承运车队,bl.分单列表,bl.计费标准,bl.报关日期,bl.报关员,bl.报关单号,bl.发票号,bl.商品编码,bl.危险品分类'); qry_op_seae.SQL.Add(',bl.危险品编号,bl.冷藏通风量,bl.温度单位,bl.设置温度,bl.最低温度,bl.最高温度,bl.货物标识,bl.销售部门,bl.操作部门,bl.工作量,bl.业务来源'); qry_op_seae.SQL.Add(',bl.英文船期,bl.三程开船日期,bl.三程港口,bl.三程船名,bl.三程航次,bl.辅助字段一,bl.辅助字段二,bl.辅助字段三,bl.辅助字段四'); qry_op_seae.SQL.Add(',bl.二程取货日期,bl.二程到港日期,bl.三程取货日期,bl.三程到港日期,bl.附加条款,bl.报关操作,bl.报检操作,bl.目的地代码,bl.包装代码'); qry_op_seae.SQL.Add(',bl.发货人编号,bl.运输方式,bl.是否自有箱,bl.运费协议号,b.结费类型,b.湿度,b.截单日期,b.副本提单份数,b.是否换签,b.订舱单号'); qry_op_seae.SQL.Add(',b.来源明细,bl.EDI备注,bl.第二通知人,''分单'' BLTYPE FROM t_op_seae_assistant bl left join t_op_seae b on (b.编号=bl.编号) where AS_ID='''+ m_bsno + ''''); qry_op_seae.open; qry_op_ctn.Close; qry_op_ctn.SQL.Add('select * from t_op_ctn_fendan where AS_ID=:编号'); qry_op_ctn.Open; end else begin qry_op_ctn.Active:=False; qry_op_ctn.Active:=True; end; t_op_task_fieldvalue.Close; t_op_task_fieldvalue.SQL.clear; t_op_task_fieldvalue.SQL.Add('select * from t_op_task_fieldvalue where 任务编号='''+m_qryTask.FieldByName('任务编号').AsString+''''); t_op_task_fieldvalue.open; end; /// /// /// procedure TfrmOpSeae_mscbc.openpdfFile(); begin end; procedure TfrmOpSeae_mscbc.FormShow(Sender: TObject); begin InitialBusiData(); end; procedure TfrmOpSeae_mscbc.btnCoseClick(Sender: TObject); begin close(); end; procedure TfrmOpSeae_mscbc.btnCancelTaskClick(Sender: TObject); var sql: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.FieldByName('操作人').AsString:=employee; 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('操作完成'),'信息提示'); close(); except on e:Exception do begin // on except //* m_qryTask.Connection.RollbackTrans; m_qryTask.Cancel(); Application.MessageBox(PChar('处理发生错误: '+E.Message),'信息提示'); end; end; end; /// /// /// procedure TfrmOpSeae_mscbc.mniN1ConfirmClick(Sender: TObject); var sql:string; optype:string; begin //确认 ORIGINAL FTP //if(m_qryTask.FieldByName('任务类型').AsString='ORIGINAL') and (m_qryTask.FieldByName('任务来源').AsString='FTP' ) then begin // optype:='PENDING'; try //** m_qryTask.Connection.BeginTrans; m_qryTask.Edit; m_qryTask.FieldByName('完成时间').AsDateTime:=Now; //m_qryTask.FieldByName('是否完成').AsInteger:=1; m_qryTask.FieldByName('任务状态').AsString:=optype; m_qryTask.FieldByName('操作人').AsString:=employee; m_qryTask.Post; // sql:='INSERT INTO t_op_task_state ( [任务编号],[任务状态],[操作人])VALUES (''%s'' ,''%s'' ,''%s'')'; sql:=Format(sql,[m_qryTask.fieldbyname('任务编号').asstring,optype,employee] ); m_qryTask.Connection.Execute(sql); //** m_qryTask.Connection.CommitTrans; m_qryTask.Requery(); Application.MessageBox(PChar('操作完成'),'信息提示'); close(); except on e:Exception do begin // on except //** m_qryTask.Connection.RollbackTrans; m_qryTask.Cancel(); Application.MessageBox(PChar('处理发生错误: '+E.Message),'信息提示'); end; end; end; end; /// /// 确认并完成任务 /// procedure TfrmOpSeae_mscbc.mni_mniN2ConfirmAndFinishClick( Sender: TObject); var sql,strtmp:string; mainno,bsno,filename,filetype:string; optype:string; isok:Boolean; remark:string; begin //确认 ORIGINAL FTP //if(m_qryTask.FieldByName('任务类型').AsString='ORIGINAL') and (m_qryTask.FieldByName('任务来源').AsString='FTP' ) then // mainno:=m_qryTask.fieldbyname('提单号').AsString; bsno:=m_qryTask.fieldbyname('SEA编号').AsString; strtmp:=m_qryTask.fieldbyname('任务类型').AsString; filename:=m_qryTask.fieldbyname('电子档案路径').AsString; remark:=m_qryTask.fieldbyname('备注').AsString; //检查是否允许挂单 optype:='完成'; isok:=true; try if (strtmp='MSC BCL') then begin qry_op_ctn.First; while not qry_op_ctn.Eof do qry_op_ctn.Delete; qry_op_seae.Delete; end; //挂单 if (isok=true) then begin m_qryTask.Edit; m_qryTask.FieldByName('完成时间').AsDateTime:=Now; m_qryTask.FieldByName('是否完成').AsInteger:=1; m_qryTask.FieldByName('任务状态').AsString:=optype; m_qryTask.FieldByName('操作人').AsString:=employee; m_qryTask.Post; // sql:='INSERT INTO t_op_task_state ( [任务编号],[任务状态],[操作人])VALUES (''%s'' ,''%s'' ,''%s'')'; sql:=Format(sql,[m_qryTask.fieldbyname('任务编号').asstring,optype,employee] ); m_qryTask.Connection.Execute(sql); m_qryTask.Requery(); Application.MessageBox(PChar('操作完成'),'信息提示'); close(); end ; except on e:Exception do begin Application.MessageBox(PChar('处理发生错误: '+E.Message),'信息提示'); end; end; // end; function TfrmOpSeae_mscbc.sendmail( mailSendTbl: TkbmMemTable;mailtype,bsno:string;ishtml:Boolean):Boolean; begin end; procedure TfrmOpSeae_mscbc.btn1pdfDownloadClick(Sender: TObject); begin // try frm_tree_main.ConnectDownServer(); except on ex: Exception do begin ;//s end; end; openpdfFile(); end; procedure TfrmOpSeae_mscbc.InitialTDWindow(); begin end; procedure TfrmOpSeae_mscbc.InitialCh_fee_edi_Window(); begin end; procedure TfrmOpSeae_mscbc.cxspltr2Moved(Sender: TObject); begin if cxspltr2.Left<200 then begin bsknpnl2_right.Left:=200+cxspltr2.Width; cxspltr2.Left:=200; end; end; procedure TfrmOpSeae_mscbc.bsSkinButton2Click(Sender: TObject); var aQuery,aQueryBl:TADOQuery; isve begin if (t_op_task_fieldvalue.IsEmpty) then begin ShowMessage('没有数据要更新'); exit; end; aQuery:=CreateAdoQuery; aQueryBl:=CreateAdoQuery; try aQueryBl.Close; aQueryBl.SQL.Clear; aQueryBl.SQL.Add('update t_op_seae_assistant set 到付运费=到付运费'); aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.Add('update t_op_seae set 周次=周次'); t_op_task_fieldvalue.First; while not t_op_task_fieldvalue.Eof do begin if (t_op_task_fieldvalue.FieldByName('字段').AsString='集装箱') then begin end else begin aQuery.SQL.Add(','+t_op_task_fieldvalue.FieldByName('字段').AsString+'='''+t_op_task_fieldvalue.FieldByName('值').AsString+''''); aQueryBl.SQL.Add(','+t_op_task_fieldvalue.FieldByName('字段').AsString+'='''+t_op_task_fieldvalue.FieldByName('值').AsString+''''); if (t_op_task_fieldvalue.FieldByName('字段').AsString='船公司航线') then begin aQuery.SQL.Add(',航线=isnull((select top 1 航线 from t_code_trade_msc where MSC航线名称='''+ t_op_task_fieldvalue.FieldByName('值').AsString +'''),航线) '); end; end; t_op_task_fieldvalue.Next; end; aQuery.SQL.Add(' WHERE 编号='''+qry_op_seae.fieldbyname('编号').AsString+''''); aQueryBl.SQL.Add(' WHERE AS_ID='''+qry_op_seae.fieldbyname('编号').AsString+''''); aQueryBl.ExecSQL; aQuery.ExecSQL; finally FreeAndNil(aQuery); FreeAndNil(aQueryBl); end; ShowMessage('更新完成!'); end; procedure TfrmOpSeae_mscbc.bsSkinButton50Click(Sender: TObject); var tmpfile:string; begin try tmpfile:=m_qryTask.fieldbyname('电子档案路径').asstring ; ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL); except showmessage('不能打开文件,请检查!'); end ; end; end.