unit u_op_seae_assistant; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, StdCtrls, DBCtrls, RxLookup, bsSkinCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker, wwdblook, Menus, DBCtrlsEh, ExtCtrls,ComObj, ComCtrls, bsSkinTabs, Grids, Wwdbigrd, Wwdbgrid, bsdbctrls, kbmMemTable, IdHTTP,superobject; type Tfrm_op_seae_assistant = class(TForm) t_op_seae_assistant: TADOQuery; t_op_seae_assistant1: TDataSource; p_getMaxHblno: TADOStoredProc; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; t_op_seae_assistant_online: TADOQuery; Panel1: TPanel; bsSkinPanel3: TbsSkinPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridColumn; StaticText1: TStaticText; PopupMenu2: TPopupMenu; N3: TMenuItem; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label122: TLabel; Label121: TLabel; Label123: TLabel; Label38: TLabel; Label36: TLabel; Label125: TLabel; Label126: TLabel; Label15: TLabel; Label7: TLabel; Label124: TLabel; Label146: TLabel; Label145: TLabel; Label32: TLabel; Label21: TLabel; Label26: TLabel; Label27: TLabel; Label30: TLabel; Label28: TLabel; Label31: TLabel; Label13: TLabel; Label163: TLabel; Label158: TLabel; Label165: TLabel; Label166: TLabel; Label167: TLabel; Label168: TLabel; Label169: TLabel; Label170: TLabel; Label33: TLabel; Label1: TLabel; Label2: TLabel; Label3: TLabel; bsSkinSpeedButton1: TbsSkinSpeedButton; bsSkinPanel2: TbsSkinPanel; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; RxDBLookupCombo2: TRxDBLookupCombo; DBMemo33: TDBMemo; DBMemo34: TDBMemo; RxDBLookupCombo3: TRxDBLookupCombo; RxDBLookupCombo4: TRxDBLookupCombo; DBMemo35: TDBMemo; DBEdit9: TDBEdit; DBEdit7: TDBEdit; wwDBLookupCombo49: TwwDBLookupCombo; DBEdit63: TDBEdit; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo52: TwwDBLookupCombo; DBEdit10: TDBEdit; DBEdit11: TDBEdit; wwDBLookupCombo21: TwwDBLookupCombo; wwDBComboBox1: TwwDBComboBox; wwDBDateTimePicker4: TwwDBDateTimePicker; DBEdit25: TDBEdit; RxDBLookupCombo15: TRxDBLookupCombo; DBEdit26: TDBEdit; DBEdit27: TDBEdit; DBEdit5: TDBEdit; DBMemo38: TDBMemo; DBMemo37: TDBMemo; DBMemo39: TDBMemo; DBMemo40: TDBMemo; DBMemo41: TDBMemo; DBMemo42: TDBMemo; DBEdit80: TDBEdit; DBEdit81: TDBEdit; wwDBLookupCombo61: TwwDBLookupCombo; DBEdit82: TDBEdit; DBEdit83: TDBEdit; RxDBLookupCombo19: TRxDBLookupCombo; DBMemo6: TDBMemo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo5: TwwDBLookupCombo; wwDBLookupCombo6: TwwDBLookupCombo; bsSkinButton21: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; wwDBLookupCombo1: TwwDBLookupCombo; DBEdit1: TDBEdit; bsSkinPanel10: TbsSkinPanel; lblhbl: TLabel; DBEditEh1: TDBEditEh; Label71: TLabel; DBMemo7: TDBMemo; Label72: TLabel; DBMemo8: TDBMemo; Label75: TLabel; DBMemo11: TDBMemo; DBMemo9: TDBMemo; Label74: TLabel; Label5: TLabel; DBMemo1: TDBMemo; bsSkinGroupBox1: TbsSkinGroupBox; Label103: TLabel; Label104: TLabel; Label105: TLabel; Label108: TLabel; Label6: TLabel; DBEdit77: TDBEdit; DBEdit72: TDBEdit; DBEdit73: TDBEdit; DBEdit74: TDBEdit; DBEdit75: TDBEdit; DBEdit76: TDBEdit; DBEdit36: TDBEdit; DBEdit37: TDBEdit; Label8: TLabel; Label9: TLabel; Label10: TLabel; DBEdit3: TDBEdit; DBEdit4: TDBEdit; Label11: TLabel; DBEdit6: TDBEdit; DBEdit8: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; Label14: TLabel; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBEdit17: TDBEdit; DBEdit18: TDBEdit; DBEdit19: TDBEdit; Label16: TLabel; Label17: TLabel; DBEdit20: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit28: TDBEdit; Label18: TLabel; DBEdit29: TDBEdit; DBEdit30: TDBEdit; DBEdit31: TDBEdit; Label4: TLabel; DBEdit2: TDBEdit; Label35: TLabel; RxDBLookupCombo28: TRxDBLookupCombo; bsSkinSpeedButton2: TbsSkinSpeedButton; OpenDialog1: TOpenDialog; t_op_ctn_fendan1: TDataSource; wwDBLookupCombo4: TwwDBLookupCombo; wwDBLookupCombo7: TwwDBLookupCombo; t_op_ctn_fendan: TADOQuery; t_op_ctn_fendanctn_id: TAutoIncField; t_op_ctn_fendanAS_ID: TIntegerField; t_op_ctn_fendanDSDesigner: TStringField; t_op_ctn_fendanDSDesigner2: TStringField; t_op_ctn_fendanDSDesigner3: TStringField; t_op_ctn_fendanDSDesigner4: TIntegerField; t_op_ctn_fendanTEU: TIntegerField; t_op_ctn_fendanDSDesigner5: TStringField; t_op_ctn_fendanDSDesigner6: TStringField; t_op_ctn_fendanDSDesigner7: TStringField; t_op_ctn_fendanDSDesigner8: TIntegerField; t_op_ctn_fendanDSDesigner9: TStringField; t_op_ctn_fendanDSDesigner10: TBCDField; t_op_ctn_fendanDSDesigner11: TBCDField; t_op_ctn_fendanDSDesigner12: TStringField; t_op_ctn_fendanDSDesigner13: TStringField; t_op_ctn_fendanDSDesigner14: TStringField; t_op_ctn_fendanDSDesigner15: TStringField; t_pt_fendan: TADOQuery; t_pt_fendan1: TDataSource; bsSkinPanel4: TbsSkinPanel; wwDBGrid1: TwwDBGrid; bsSkinPanel5: TbsSkinPanel; bsSkinDBNavigator1: TbsSkinDBNavigator; bsSkinButton15: TbsSkinButton; Label12: TLabel; DBMemo2: TDBMemo; bsSkinButton16: TbsSkinButton; bsSkinButton17: TbsSkinButton; mailSend: TkbmMemTable; mailSendStringField: TStringField; mailSendField: TStringField; mailSendField2: TStringField; mailSendField3: TStringField; mailSendField4: TStringField; mailSendField5: TStringField; mailSendField6: TStringField; mailSendField7: TStringField; Label19: TLabel; DBEdit32: TDBEdit; DBMemo3: TDBMemo; Label20: TLabel; bsSkinSpeedButton3: TbsSkinSpeedButton; v_vessel_voyage: TADOQuery; v_vessel_voyageDSDesigner: TStringField; v_vessel_voyageDSDesigner2: TStringField; v_vessel_voyageDSDesigner3: TStringField; v_vessel_voyageDSDesigner4: TStringField; v_vessel_voyageDSDesigner5: TStringField; v_vessel_voyageDSDesigner6: TStringField; v_vessel_voyageDSDesigner7: TStringField; v_vessel_voyageDSDesigner8: TDateTimeField; v_vessel_voyageDSDesigner9: TDateTimeField; v_vessel_voyageDSDesigner10: TDateTimeField; v_vessel_voyageDSDesigner11: TDateTimeField; bsSkinButton18: TbsSkinButton; Button3: TButton; DBEdit41: TDBEdit; Label133: TLabel; Label22: TLabel; DBEdit33: TDBEdit; t_op_ctn_fendanDSDesigner16: TBCDField; t_op_ctn_fendanDSDesigner17: TBCDField; t_op_ctn_fendanDSDesigner18: TBCDField; procedure bsSkinPanel2Resize(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure t_op_seae_assistantAfterInsert(DataSet: TDataSet); procedure t_op_seae_assistantBeforeInsert(DataSet: TDataSet); procedure bsSkinButton8Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure DBEdit9KeyPress(Sender: TObject; var Key: Char); procedure DBEdit7KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo49KeyPress(Sender: TObject; var Key: Char); procedure DBEdit63KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker2KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo52KeyPress(Sender: TObject; var Key: Char); procedure DBEdit10KeyPress(Sender: TObject; var Key: Char); procedure DBEdit11KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo21KeyPress(Sender: TObject; var Key: Char); procedure wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit25KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker4KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo15KeyPress(Sender: TObject; var Key: Char); procedure DBEdit26KeyPress(Sender: TObject; var Key: Char); procedure DBEdit27KeyPress(Sender: TObject; var Key: Char); procedure DBEdit5KeyPress(Sender: TObject; var Key: Char); procedure DBEdit81KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo61KeyPress(Sender: TObject; var Key: Char); procedure DBEdit82KeyPress(Sender: TObject; var Key: Char); procedure DBEdit83KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo2Change(Sender: TObject); procedure RxDBLookupCombo3Change(Sender: TObject); procedure RxDBLookupCombo4Change(Sender: TObject); procedure DBMemo40Change(Sender: TObject); procedure DBMemo41Change(Sender: TObject); procedure DBMemo41Exit(Sender: TObject); procedure DBMemo42Change(Sender: TObject); procedure DBMemo42Exit(Sender: TObject); procedure wwDBLookupCombo61Change(Sender: TObject); procedure RxDBLookupCombo19Change(Sender: TObject); procedure wwDBLookupCombo2Enter(Sender: TObject); procedure wwDBLookupCombo5Enter(Sender: TObject); procedure wwDBLookupCombo6Enter(Sender: TObject); procedure wwDBLookupCombo2Change(Sender: TObject); procedure wwDBLookupCombo5Change(Sender: TObject); procedure wwDBLookupCombo6Change(Sender: TObject); procedure wwDBLookupCombo2Exit(Sender: TObject); procedure wwDBLookupCombo5Exit(Sender: TObject); procedure wwDBLookupCombo6Exit(Sender: TObject); procedure wwDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo6KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure t_op_seae_assistantBeforePost(DataSet: TDataSet); procedure bsSkinButton21Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure wwDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo19KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo1Enter(Sender: TObject); procedure wwDBLookupCombo1Exit(Sender: TObject); procedure wwDBLookupCombo1Change(Sender: TObject); procedure DBEdit1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit7DblClick(Sender: TObject); procedure DBEdit7Exit(Sender: TObject); procedure RxDBLookupCombo15Change(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure DBEditEh1EditButtons0Click(Sender: TObject; var Handled: Boolean); procedure t_op_seae_assistantAfterPost(DataSet: TDataSet); procedure bsSkinButton14Click(Sender: TObject); procedure dxDBGrid1Column1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure N3Click(Sender: TObject); procedure bsSkinSpeedButton2Click(Sender: TObject); procedure wwDBLookupCombo4Change(Sender: TObject); procedure t_op_ctn_fendanAfterInsert(DataSet: TDataSet); procedure t_op_seae_assistantAfterScroll(DataSet: TDataSet); procedure t_op_ctn_fendanBeforeInsert(DataSet: TDataSet); procedure bsSkinButton15Click(Sender: TObject); procedure DBMemo33Click(Sender: TObject); procedure DBMemo34Click(Sender: TObject); procedure DBMemo35Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinSpeedButton3Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure Button3Click(Sender: TObject); private updates:boolean; function getYardCode(yard:string):string; { Private declarations } public { Public declarations } end; var frm_op_seae_assistant: Tfrm_op_seae_assistant; implementation uses u_op_seae, u_main, my_sys_function, u_data_share,u_op_seae_assistant_qr , u_send_msg ; {$R *.dfm} procedure Tfrm_op_seae_assistant.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.width/9); bsSkinButton9.width:=i; bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton13.width:=i; bsSkinButton12.width:=i; bsSkinButton14.width:=i; end; procedure Tfrm_op_seae_assistant.bsSkinButton1Click(Sender: TObject); begin t_op_seae_assistant.insert; end; procedure Tfrm_op_seae_assistant.bsSkinButton2Click(Sender: TObject); begin //t_op_seae_assistant.fieldbyname('第二通知人').AsString:=frm_op_seae.t_op_seae.fieldbyname('第二通知人').AsString; table_post(t_op_seae_assistant); end; procedure Tfrm_op_seae_assistant.bsSkinButton4Click(Sender: TObject); begin table_delete(t_op_seae_assistant); end; procedure Tfrm_op_seae_assistant.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae_assistant); end; procedure Tfrm_op_seae_assistant.bsSkinButton9Click(Sender: TObject); var i:integer; str:widestring; aQuery:TADOQuery; begin if t_op_seae_assistant.IsEmpty then exit; { if dxDBGrid1.SelectedCount<1 then begin ShowMessage('选择打印分单为0,请选择'); exit; end; if dxDBGrid1.SelectedCount>=0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae_assistant.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+t_op_seae_assistant.fieldbyname('AS_ID').asstring else str:=str+','+t_op_seae_assistant.fieldbyname('AS_ID').asstring; end; str:=str+')'; } if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae_assistant.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+'''' else str:=str+','+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+''''; end; end else begin str:='('+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+''''; end; str:=str+')'; t_pt_fendan.close; t_pt_fendan.sql.clear; t_pt_fendan.sql.add('select * from t_op_seae_assistant ' +'where AS_ID in '+str +' order by 主提单号'); t_pt_fendan.open; if t_op_seae_assistant.DataSource.DataSet.FieldByName('客户邮件方案').AsString<>'' then begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.Clear; SQL.Add('select * from t_code_cust_mailproject_detail where 方案代码='''+t_op_seae_assistant.DataSource.DataSet.FieldByName('客户邮件方案').AsString+''' and 单据类型=''提单及下货纸'' '); Open; if not IsEmpty then begin mailSend.EmptyTable; mailSend.Open; mailSend.Insert; mailSend.FieldByName('收件人').AsString:=fieldbyname('收件人').AsString; str:=fieldbyname('主题模板').AsString; str:=StringReplace(str,'[主提单号]',t_op_seae_assistant.fieldbyname('主提单号').AsString,[]); // 补充委托编号 程建波 2017-07-22 str:=StringReplace(str,'[委托编号]',t_op_seae_assistant.fieldbyname('委托编号').AsString,[]); str:=StringReplace(str,'[船名]',t_op_seae_assistant.fieldbyname('船名').AsString,[]); str:=StringReplace(str,'[航次]',t_op_seae_assistant.fieldbyname('航次').AsString,[]); str:=StringReplace(str,'[委托单位]',t_op_seae_assistant.DataSource.DataSet.fieldbyname('委托单位').AsString,[]); mailSend.FieldByName('邮件主题').AsString:=str; str:=fieldbyname('邮件内容').AsString; str:=StringReplace(str,'[主提单号]',t_op_seae_assistant.fieldbyname('主提单号').AsString,[]); // 补充委托编号 程建波 2017-07-22 str:=StringReplace(str,'[委托编号]',t_op_seae_assistant.fieldbyname('委托编号').AsString,[]); str:=StringReplace(str,'[船名]',t_op_seae_assistant.fieldbyname('船名').AsString,[]); str:=StringReplace(str,'[航次]',t_op_seae_assistant.fieldbyname('航次').AsString,[]); str:=StringReplace(str,'[委托单位]',t_op_seae_assistant.DataSource.DataSet.fieldbyname('委托单位').AsString,[]); mailSend.FieldByName('邮件内容').AsString:=str; frm_data_share.t_sys_employee.Locate('姓名',employee,[]); mailSend.FieldByName('邮件签名').AsString:=MailSignName;//frm_data_share.t_sys_employee.fieldbyname('邮件签名').AsString; str:=fieldbyname('附件名称').AsString; str:=StringReplace(str,'[主提单号]',t_op_seae_assistant.fieldbyname('主提单号').AsString,[]); // 补充委托编号 程建波 2017-07-22 str:=StringReplace(str,'[委托编号]',t_op_seae_assistant.fieldbyname('委托编号').AsString,[]); str:=StringReplace(str,'[船名]',t_op_seae_assistant.fieldbyname('船名').AsString,[]); str:=StringReplace(str,'[航次]',t_op_seae_assistant.fieldbyname('航次').AsString,[]); str:=StringReplace(str,'[委托单位]',t_op_seae_assistant.DataSource.DataSet.fieldbyname('委托单位').AsString,[]); mailSend.FieldByName('附件名称').AsString:=str; mailSend.FieldByName('单据类型').AsString:=fieldbyname('单据类型').AsString; mailSend.FieldByName('编号').AsString:=t_op_seae_assistant.fieldbyname('编号').AsString; mailSend.FieldByName('主提单号').AsString:=t_op_seae_assistant.fieldbyname('主提单号').AsString; mailSend.Post; sys_print('海运出口单证',2,t_pt_fendan1,t_op_seae_assistant.DataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,True,'',nil,nil,mailSend); end else sys_print('海运出口单证',2,t_pt_fendan1,t_op_seae_assistant.DataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; finally FreeAndNil(aQuery); end; end else begin sys_print('海运出口单证',2,t_pt_fendan1,t_op_seae_assistant.DataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; end; procedure Tfrm_op_seae_assistant.t_op_seae_assistantAfterInsert( DataSet: TDataSet); var afield : variant; i: Integer; aAdoQuery:TAdoQuery; begin // 复制业务基本信息内容 if application.MessageBox('您是否要建直单信息,直单将调入发货人\收货人\通知人信息?','敬告:',MB_OKCANCEL)=IDOK then begin for i:=0 to (t_op_seae_assistant.DataSource.DataSet.fieldcount-1) do begin try if t_op_seae_assistant.FindField(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName)<>nil then t_op_seae_assistant[t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName]:= t_op_seae_assistant.DataSource.DataSet.fields[i].value; except ; end; end; t_op_seae_assistant['提交确认']:=td_sate1 ; t_op_seae_assistant['提单类型']:='直单'; end else begin for i:=0 to (t_op_seae_assistant.DataSource.DataSet.fieldcount-1) do begin try if (t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'发货人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'发货人代码') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'收货人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'收货人代码') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'通知人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'通知人代码')then if t_op_seae_assistant.FindField(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName)<>nil then t_op_seae_assistant[t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName]:= t_op_seae_assistant.DataSource.DataSet.fields[i].value; except ; end; end; t_op_seae_assistant['提交确认']:=td_sate1 ; t_op_seae_assistant['提单类型']:='套单'; end; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('select * from t_op_ctn'); sql.Add('where 编号=:bsno'); Parameters.ParamByName('bsno').Value:=t_op_seae_assistant.DataSource.DataSet.FieldByName('编号').AsString; Open;First; while not eof do begin t_op_ctn_fendan.Insert; t_op_ctn_fendan.FieldByName('代码').Value:=FieldByName('代码').Value; t_op_ctn_fendan.FieldByName('尺寸').Value:=FieldByName('尺寸').Value; t_op_ctn_fendan.FieldByName('箱型').Value:=FieldByName('箱型').Value; t_op_ctn_fendan.FieldByName('数量').Value:=FieldByName('数量').Value; t_op_ctn_fendan.FieldByName('TEU').Value:=FieldByName('TEU').Value; t_op_ctn_fendan.FieldByName('表现形式').Value:=FieldByName('表现形式').Value; t_op_ctn_fendan.FieldByName('箱号').Value:=FieldByName('箱号').Value; t_op_ctn_fendan.FieldByName('箱号').Value:=FieldByName('箱号').Value; t_op_ctn_fendan.FieldByName('封号').Value:=FieldByName('封号').Value; t_op_ctn_fendan.FieldByName('件数').Value:=FieldByName('件数').Value; t_op_ctn_fendan.FieldByName('包装').Value:=FieldByName('包装').Value; t_op_ctn_fendan.FieldByName('重量').Value:=FieldByName('重量').Value; t_op_ctn_fendan.FieldByName('尺码').Value:=FieldByName('尺码').Value; t_op_ctn_fendan.post; Next; end; finally Free; end; end; procedure Tfrm_op_seae_assistant.t_op_seae_assistantBeforeInsert( DataSet: TDataSet); begin if t_op_seae_assistant.DataSource.DataSet.State=dsinsert then t_op_seae_assistant.DataSource.DataSet.post; if t_op_seae_assistant.DataSource.DataSet.ISEMPTY then abort; end; procedure Tfrm_op_seae_assistant.bsSkinButton8Click(Sender: TObject); var afield : variant; i: Integer; begin // 刷新复制业务基本信息内容 if t_op_seae_assistant.IsEmpty then exit; t_op_seae_assistant.edit; if application.MessageBox('您是否要调入直单信息,直单信息包括发货人\收货人\通知人信息?','敬告:',MB_OKCANCEL)=IDOK then begin for i:=0 to (t_op_seae_assistant.DataSource.DataSet.fieldcount-1) do begin try if t_op_seae_assistant.FindField(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName)<>nil then t_op_seae_assistant[t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName]:= t_op_seae_assistant.DataSource.DataSet.fields[i].value; except ; end; end; end else begin for i:=0 to (t_op_seae_assistant.DataSource.DataSet.fieldcount-1) do begin try if (t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'发货人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'发货人代码') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'收货人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'收货人代码') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'通知人') and(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName<>'通知人代码')then if t_op_seae_assistant.FindField(t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName)<>nil then t_op_seae_assistant[t_op_seae_assistant.DataSource.DataSet.fields[i].FieldName]:= t_op_seae_assistant.DataSource.DataSet.fields[i].value; except ; end; end; end; end; procedure Tfrm_op_seae_assistant.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_op_seae_assistant.Hide; frm_op_seae_assistant.ManualFloat(frm_op_seae_assistant.BoundsRect ); action:=cafree; frm_op_seae_assistant:=nil; end; procedure Tfrm_op_seae_assistant.FormShow(Sender: TObject); begin t_op_seae_assistant.open; t_op_ctn_fendan.Open; { try if strtobool(get_parameters_value(154,'false')) then t_op_seae_assistant_online.Open except on E: Exception do begin ShowMessage(e.Message); end; end; } updates:=false; end; procedure Tfrm_op_seae_assistant.DBEdit9KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit7); end; procedure Tfrm_op_seae_assistant.DBEdit7KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit1); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo49KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit63); end; procedure Tfrm_op_seae_assistant.DBEdit63KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(Key,wwDBDateTimePicker2); end; procedure Tfrm_op_seae_assistant.wwDBDateTimePicker2KeyPress( Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo3); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo52); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo52KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit10); end; procedure Tfrm_op_seae_assistant.DBEdit10KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit11); end; procedure Tfrm_op_seae_assistant.DBEdit11KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo21); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo21KeyPress(Sender: TObject; var Key: Char); begin key_wwDBComboBox(Key,wwDBComboBox1); end; procedure Tfrm_op_seae_assistant.wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit25); end; procedure Tfrm_op_seae_assistant.DBEdit25KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(Key,wwDBDateTimePicker4); end; procedure Tfrm_op_seae_assistant.wwDBDateTimePicker4KeyPress( Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo15); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo15KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit26); end; procedure Tfrm_op_seae_assistant.DBEdit26KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit27); end; procedure Tfrm_op_seae_assistant.DBEdit27KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo28); end; procedure Tfrm_op_seae_assistant.DBEdit5KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo38); end; procedure Tfrm_op_seae_assistant.DBEdit81KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo61); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo61KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit82); end; procedure Tfrm_op_seae_assistant.DBEdit82KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit83); end; procedure Tfrm_op_seae_assistant.DBEdit83KeyPress(Sender: TObject; var Key: Char); begin key_dbedit(Key,DBEdit80); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo2Change(Sender: TObject); begin if (t_op_seae_assistant.State=dsinsert)or(t_op_seae_assistant.State=dsedit)then begin if RxDBLookupCombo2.DisplayValue<>'' then t_op_seae_assistant['发货人代码']:=frm_data_share.t_crm_client_shiper.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo3Change(Sender: TObject); begin if (t_op_seae_assistant.State=dsinsert)or(t_op_seae_assistant.State=dsedit)then begin if RxDBLookupCombo3.DisplayValue<>'' then t_op_seae_assistant['收货人代码']:=frm_data_share.t_crm_client_shouhuo.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo4Change(Sender: TObject); begin if (t_op_seae_assistant.State=dsinsert)or(t_op_seae_assistant.State=dsedit)then begin if RxDBLookupCombo4.DisplayValue<>'' then t_op_seae_assistant['通知人代码']:=frm_data_share.t_crm_client_tongzhi.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_assistant.DBMemo40Change(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin t_op_seae_assistant['件数']:=total_num(DBMemo40); t_op_seae_assistant['包装']:=total_package(dbmemo40); t_op_seae_assistant['件数大写'] :='SAY:'+ntoc(t_op_seae_assistant.FieldByName('件数').asfloat,true) +t_op_seae_assistant.FieldByName('包装').asstring+' ONLY.'; end; end; procedure Tfrm_op_seae_assistant.DBMemo41Change(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin t_op_seae_assistant['重量']:=total_num(DBMemo41); end; end; procedure Tfrm_op_seae_assistant.DBMemo41Exit(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin kgs_cbm(DBMemo41,'KGS'); t_op_seae_assistant['货物重量']:=DBMemo41.text; end; end; procedure Tfrm_op_seae_assistant.DBMemo42Change(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin t_op_seae_assistant['尺码']:=total_num(DBMemo42); end; end; procedure Tfrm_op_seae_assistant.DBMemo42Exit(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin kgs_cbm(DBMemo42,'CBM'); t_op_seae_assistant['货物尺码']:=DBMemo42.text; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo61Change(Sender: TObject); begin if (t_op_seae_assistant.state=dsedit)or(t_op_seae_assistant.state=dsinsert)then begin t_op_seae_assistant['件数大写'] :='SAY:'+ntoc(t_op_seae_assistant.FieldByName('件数').asfloat,true) +wwDBLookupCombo61.text+' ONLY.'; end; end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo19Change(Sender: TObject); begin if (t_op_seae_assistant.state=dsinsert)or(t_op_seae_assistant.state=dsedit)then begin if RxDBLookupCombo19.DisplayValue='' then exit; t_op_seae_assistant['代理内容']:=frm_data_share.t_crm_client_daili['快捷代码']; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo2Enter(Sender: TObject); begin with frm_data_share do begin t_code_code.Filtered:=false; t_code_code.Filter:='发货人=1'; t_code_code.Filtered:=true; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo5Enter(Sender: TObject); begin with frm_data_share do begin t_code_code.Filtered:=false; t_code_code.Filter:='收货人=1'; t_code_code.Filtered:=true; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo6Enter(Sender: TObject); begin with frm_data_share do begin t_code_code.Filtered:=false; t_code_code.Filter:='通知人=1'; t_code_code.Filtered:=true; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo2Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo2.text,[]) then begin t_op_seae_assistant.edit; t_op_seae_assistant['发货人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo5Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo5.text,[]) then begin t_op_seae_assistant.edit; t_op_seae_assistant['收货人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo6Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo6.text,[]) then begin t_op_seae_assistant.edit; t_op_seae_assistant['通知人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo2Exit(Sender: TObject); begin wwDBLookupCombo2.Clear; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo5Exit(Sender: TObject); begin wwDBLookupCombo5.Clear; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo6Exit(Sender: TObject); begin wwDBLookupCombo6.Clear; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo33); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo34); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo6KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo35); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo2); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo5); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo6); end; procedure Tfrm_op_seae_assistant.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_seae_assistant,'主提单号'); end; procedure Tfrm_op_seae_assistant.t_op_seae_assistantBeforePost( DataSet: TDataSet); begin t_op_seae_assistant['英文船期']:=date_eng(t_op_seae_assistant.fieldbyname('开船日期').AsDateTime); try if t_op_seae_assistant.state in [dsedit] then if (t_op_seae_assistant.FieldByName('件数').Value<>t_op_seae_assistant.FieldByName('件数').oldValue) or (t_op_seae_assistant.FieldByName('包装').Value<>t_op_seae_assistant.FieldByName('包装').oldValue) or (t_op_seae_assistant.FieldByName('尺码').Value<>t_op_seae_assistant.FieldByName('尺码').oldValue) or (t_op_seae_assistant.FieldByName('重量').Value<>t_op_seae_assistant.FieldByName('重量').oldValue) or (t_op_seae_assistant.FieldByName('唛头').Value<>t_op_seae_assistant.FieldByName('唛头').oldValue) or (t_op_seae_assistant.FieldByName('箱号封号').Value<>t_op_seae_assistant.FieldByName('箱号封号').oldValue) then begin updates:=true; end; except end; end; procedure Tfrm_op_seae_assistant.bsSkinButton21Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'货物描述'); end; procedure Tfrm_op_seae_assistant.bsSkinButton7Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'唛头'); end; procedure Tfrm_op_seae_assistant.bsSkinButton6Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'箱号封号'); end; procedure Tfrm_op_seae_assistant.bsSkinButton5Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'件数包装'); end; procedure Tfrm_op_seae_assistant.bsSkinButton10Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'货物重量'); end; procedure Tfrm_op_seae_assistant.bsSkinButton11Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'货物尺码'); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo6); end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo19KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo1); end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo1Enter(Sender: TObject); begin with frm_data_share do begin t_code_code.Filtered:=false; t_code_code.Filter:='代理=1'; t_code_code.Filtered:=true; end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo1Exit(Sender: TObject); begin wwDBLookupCombo1.Clear; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo1Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo1.text,[]) then begin t_op_seae_assistant.edit; t_op_seae_assistant['代理内容']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_assistant.DBEdit1KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo49); end; procedure Tfrm_op_seae_assistant.DBEdit7DblClick(Sender: TObject); begin with p_getMaxHblno do begin close; Parameters.ParamByName('@hblhead').value:=DBEdit7.text+'%'; open; if (not IsEmpty) and (FieldByName('分提单号').AsString<>'') then begin lblhbl.Caption:=FieldByName('分提单号').AsString; bsSkinPanel10.Visible:=true; end; end; end; procedure Tfrm_op_seae_assistant.DBEdit7Exit(Sender: TObject); begin bsSkinPanel10.Visible:=false; end; procedure Tfrm_op_seae_assistant.RxDBLookupCombo15Change(Sender: TObject); begin if RxDBLookupCombo15.DisplayValues[1]='FREIGHT PREPAID' then begin t_op_seae_assistant1.DataSet['预付地点']:=t_op_seae_assistant1.DataSet['装货港']; t_op_seae_assistant1.DataSet['到付地点']:=''; end; if RxDBLookupCombo15.DisplayValues[1]='FREIGHT COLLECT' then begin t_op_seae_assistant1.DataSet['预付地点']:=''; t_op_seae_assistant1.DataSet['到付地点']:='DESTINATION'; end; end; procedure Tfrm_op_seae_assistant.bsSkinButton12Click(Sender: TObject); var i:integer ; myfield:string ; begin //提交网上提单确认数据 if t_op_seae_assistant.IsEmpty then exit ; if t_op_seae_assistant.State in [dsedit,dsinsert] then t_op_seae_assistant.post ; if (t_op_seae_assistant['提交确认']<>td_sate1) then exit ; if t_op_seae_assistant.fieldbyname('主提单号').AsString='' then begin showmessage('主提单号为空不能提交确认!'); exit ; end ; try t_op_seae_assistant_online.Close ; t_op_seae_assistant_online.Open; while t_op_seae_assistant_online.RecordCount>0 do t_op_seae_assistant_online.Delete ; t_op_seae_assistant.Edit ; t_op_seae_assistant['提交确认']:=td_sate2 ; t_op_seae_assistant.Post ; ////add 网上 数据库 t_op_seae_assistant_online.Insert ; for i:=0 to (t_op_seae_assistant_online.fieldcount-1) do begin try myfield:=t_op_seae_assistant_online.Fields[i].fieldName ; if t_op_seae_assistant.FindField(myfield)<>nil then t_op_seae_assistant_online[myfield]:=t_op_seae_assistant[myfield]; except ; end; end ; t_op_seae_assistant_online['提交确认']:=td_assate1 ; t_op_seae_assistant_online.post ; except showmessage('提交失败'); exit ; end ; //给客户发送提醒 if (yctx<>'启用') then exit ; if (trim(get_parameters_value(136,'无'))='无') then exit; frm_send_msg:=Tfrm_send_msg.Create(self); try frm_data_share.t_crm_client_all.Locate('客户简称',t_op_seae_assistant1.DataSet['委托单位'],[]); frm_send_msg.t_crm_client_link.Open; frm_send_msg.memmsg.open; frm_send_msg.memmsg.insert; frm_send_msg.memmsg.FieldByName('收件单位').AsString:=t_op_seae_assistant1.DataSet['委托单位']; if not frm_send_msg.t_crm_client_link.IsEmpty then begin frm_send_msg.t_crm_client_link.first; frm_send_msg.memmsg.FieldByName('收件人').AsString:=frm_send_msg.t_crm_client_link['姓名']; end; frm_send_msg.memmsg.FieldByName('内容').AsString:='主提单号:'+t_op_seae_assistant1.DataSet['主提单号']+',' +'开船日期:'+t_op_seae_assistant1.DataSet.Fieldbyname('开船日期').AsString+',' +'船名:'+t_op_seae_assistant1.DataSet.Fieldbyname('船名').AsString+',' +'航次:'+t_op_seae_assistant1.DataSet.Fieldbyname('航次').AsString+' '+'请您确认'; if trim(get_parameters_value(136,'无'))='MSN' then frm_send_msg.checkboxMSN.Checked:=true; if trim(get_parameters_value(136,'无'))='邮件' then frm_send_msg.checkboxMAIL.Checked:=true; if trim(get_parameters_value(136,'无'))='短信' then frm_send_msg.checkboxMSG.Checked:=true; frm_send_msg.ShowModal; finally FreeAndNil(frm_send_msg); end; end; procedure Tfrm_op_seae_assistant.bsSkinButton13Click(Sender: TObject); begin //更改网上提单确认 状态 if t_op_seae_assistant.IsEmpty then exit ; if t_op_seae_assistant['提交确认']=td_sate3 then begin showmessage('当前状态不能取消确认!'); exit ; end ; t_op_seae_assistant.Edit ; t_op_seae_assistant['提交确认']:=td_sate1 ; t_op_seae_assistant.Post ; ////del 网上 数据库 with frm_main.qryTmp,sql do begin close ; clear ; add('delete from t_op_seae_assistant_on where as_id=:as_id'); parameters.ParamByName('as_id').value:=t_op_seae_assistant.Fieldbyname('as_id').AsInteger ; execsql ; end ; end; procedure Tfrm_op_seae_assistant.DBEditEh1EditButtons0Click( Sender: TObject; var Handled: Boolean); begin //网上提单确认更新到本地数据 if t_op_seae_assistant['提交确认']=td_sate1 then exit ; if t_op_seae_assistant.State in [dsedit,dsinsert] then t_op_seae_assistant.post ; frm_op_seae_assistant_qr:=Tfrm_op_seae_assistant_qr.Create(self); frm_op_seae_assistant_qr.showasid(t_op_seae_assistant,t_op_seae_assistant.FieldByName('as_id').asinteger) ; frm_op_seae_assistant_qr.Free ; t_op_seae_assistant.Refresh ; if (t_op_seae_assistant.DataSource.DataSet<>nil)and (t_op_seae_assistant.DataSource.DataSet.Active) then t_op_seae_assistant.DataSource.DataSet.Refresh ; end; procedure Tfrm_op_seae_assistant.t_op_seae_assistantAfterPost( DataSet: TDataSet); begin // TAdoQuery(t_op_seae_assistant.DataSource.DataSet).Refresh; //更改件重尺更新基本信息内容 try if updates then if MessageDlg('件、重、尺或唛头、箱封号已发生改变,是否更基本信息内容?',mtWarning,[mbYes,mbNo],0)=mrYes then begin t_op_seae_assistant.DataSource.DataSet.Edit; t_op_seae_assistant.DataSource.DataSet['件数']:=t_op_seae_assistant['件数']; t_op_seae_assistant.DataSource.DataSet['包装']:=t_op_seae_assistant['包装']; t_op_seae_assistant.DataSource.DataSet['尺码']:=t_op_seae_assistant['尺码']; t_op_seae_assistant.DataSource.DataSet['重量']:=t_op_seae_assistant['重量']; t_op_seae_assistant.DataSource.DataSet['件数包装']:=t_op_seae_assistant['件数包装']; t_op_seae_assistant.DataSource.DataSet['货物重量']:=t_op_seae_assistant['货物重量']; t_op_seae_assistant.DataSource.DataSet['货物尺码']:=t_op_seae_assistant['货物尺码']; t_op_seae_assistant.DataSource.DataSet['唛头']:=t_op_seae_assistant['唛头']; t_op_seae_assistant.DataSource.DataSet['箱号封号']:=t_op_seae_assistant['箱号封号']; t_op_seae_assistant.DataSource.DataSet['件数大写']:=t_op_seae_assistant['件数大写']; frm_op_seae.assup:=true; t_op_seae_assistant.DataSource.DataSet.post; updates:=false; end; finally frm_op_seae.assup:=false; end; end; procedure Tfrm_op_seae_assistant.bsSkinButton14Click(Sender: TObject); begin //更新到基本信息内容 try if MessageDlg('确实要更新基本信息所有内容吗?',mtWarning,[mbYes,mbNo],0)=mrYes then begin t_op_seae_assistant.DataSource.DataSet.Edit; if t_op_seae_assistant.FieldByName('提单类型').AsString='直单' then begin t_op_seae_assistant.DataSource.DataSet['发货人代码']:=t_op_seae_assistant['发货人代码']; t_op_seae_assistant.DataSource.DataSet['收货人代码']:=t_op_seae_assistant['收货人代码']; t_op_seae_assistant.DataSource.DataSet['通知人代码']:=t_op_seae_assistant['通知人代码']; end; t_op_seae_assistant.DataSource.DataSet['代理内容']:=t_op_seae_assistant['代理内容']; t_op_seae_assistant.DataSource.DataSet['货物描述']:=t_op_seae_assistant['货物描述']; t_op_seae_assistant.DataSource.DataSet['件数大写']:=t_op_seae_assistant['件数大写']; t_op_seae_assistant.DataSource.DataSet['船名']:=t_op_seae_assistant['船名']; t_op_seae_assistant.DataSource.DataSet['航次']:=t_op_seae_assistant['航次']; t_op_seae_assistant.DataSource.DataSet['开船日期']:=t_op_seae_assistant['开船日期']; t_op_seae_assistant.DataSource.DataSet['装货港']:=t_op_seae_assistant['装货港']; t_op_seae_assistant.DataSource.DataSet['卸货港']:=t_op_seae_assistant['卸货港']; t_op_seae_assistant.DataSource.DataSet['交货地点']:=t_op_seae_assistant['交货地点']; t_op_seae_assistant.DataSource.DataSet['目的地']:=t_op_seae_assistant['目的地']; t_op_seae_assistant.DataSource.DataSet['运输条款']:=t_op_seae_assistant['运输条款']; t_op_seae_assistant.DataSource.DataSet['提单份数']:=t_op_seae_assistant['提单份数']; t_op_seae_assistant.DataSource.DataSet['签单地点']:=t_op_seae_assistant['签单地点']; t_op_seae_assistant.DataSource.DataSet['签单日期']:=t_op_seae_assistant['签单日期']; t_op_seae_assistant.DataSource.DataSet['付费方式']:=t_op_seae_assistant['付费方式']; t_op_seae_assistant.DataSource.DataSet['预付地点']:=t_op_seae_assistant['预付地点']; t_op_seae_assistant.DataSource.DataSet['到付地点']:=t_op_seae_assistant['到付地点']; t_op_seae_assistant.DataSource.DataSet['唛头']:=t_op_seae_assistant['唛头']; t_op_seae_assistant.DataSource.DataSet['箱号封号']:=t_op_seae_assistant['箱号封号']; t_op_seae_assistant.DataSource.DataSet['件数']:=t_op_seae_assistant['件数']; t_op_seae_assistant.DataSource.DataSet['包装']:=t_op_seae_assistant['包装']; t_op_seae_assistant.DataSource.DataSet['尺码']:=t_op_seae_assistant['尺码']; t_op_seae_assistant.DataSource.DataSet['重量']:=t_op_seae_assistant['重量']; t_op_seae_assistant.DataSource.DataSet['件数包装']:=t_op_seae_assistant['件数包装']; t_op_seae_assistant.DataSource.DataSet['货物重量']:=t_op_seae_assistant['货物重量']; t_op_seae_assistant.DataSource.DataSet['货物尺码']:=t_op_seae_assistant['货物尺码']; t_op_seae_assistant.DataSource.DataSet.post; end; except end; end; procedure Tfrm_op_seae_assistant.dxDBGrid1Column1CustomDraw( Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if Trim(ANode.Strings[dxDBGrid1Column3.Index])='直单' then AColor:=clgreen; AFont.Color:=clblack; end; procedure Tfrm_op_seae_assistant.N3Click(Sender: TObject); begin //强制转换成大写 if t_op_seae_assistant.state in [dsedit,dsinsert] then t_op_seae_assistant.post; if t_op_seae_assistant.IsEmpty then exit; t_op_seae_assistant.Edit; t_op_seae_assistant.FieldByName('委托编号').AsString:=UpperCase(t_op_seae_assistant.FieldByName('委托编号').AsString); t_op_seae_assistant.FieldByName('主提单号').AsString:=UpperCase(t_op_seae_assistant.FieldByName('主提单号').AsString); t_op_seae_assistant.FieldByName('分提单号').AsString:=UpperCase(t_op_seae_assistant.FieldByName('分提单号').AsString); t_op_seae_assistant.FieldByName('发货人代码').AsString:=UpperCase(t_op_seae_assistant.FieldByName('发货人代码').AsString); t_op_seae_assistant.FieldByName('收货人代码').AsString:=UpperCase(t_op_seae_assistant.FieldByName('收货人代码').AsString); t_op_seae_assistant.FieldByName('通知人代码').AsString:=UpperCase(t_op_seae_assistant.FieldByName('通知人代码').AsString); t_op_seae_assistant.FieldByName('代理内容').AsString:=UpperCase(t_op_seae_assistant.FieldByName('代理内容').AsString); t_op_seae_assistant.FieldByName('唛头').AsString:=UpperCase(t_op_seae_assistant.FieldByName('唛头').AsString); t_op_seae_assistant.FieldByName('箱号封号').AsString:=UpperCase(t_op_seae_assistant.FieldByName('箱号封号').AsString); t_op_seae_assistant.FieldByName('货物描述').AsString:=UpperCase(t_op_seae_assistant.FieldByName('货物描述').AsString); t_op_seae_assistant.FieldByName('件数包装').AsString:=UpperCase(t_op_seae_assistant.FieldByName('件数包装').AsString); t_op_seae_assistant.FieldByName('件数大写').AsString:=UpperCase(t_op_seae_assistant.FieldByName('件数大写').AsString); t_op_seae_assistant.FieldByName('船名').AsString:=UpperCase(t_op_seae_assistant.FieldByName('船名').AsString); t_op_seae_assistant.FieldByName('航次').AsString:=UpperCase(t_op_seae_assistant.FieldByName('航次').AsString); t_op_seae_assistant.FieldByName('装货港').AsString:=UpperCase(t_op_seae_assistant.FieldByName('装货港').AsString); t_op_seae_assistant.FieldByName('卸货港').AsString:=UpperCase(t_op_seae_assistant.FieldByName('卸货港').AsString); t_op_seae_assistant.FieldByName('交货地点').AsString:=UpperCase(t_op_seae_assistant.FieldByName('交货地点').AsString); t_op_seae_assistant.FieldByName('到付地点').AsString:=UpperCase(t_op_seae_assistant.FieldByName('到付地点').AsString); t_op_seae_assistant.FieldByName('目的地').AsString:=UpperCase(t_op_seae_assistant.FieldByName('目的地').AsString); t_op_seae_assistant.FieldByName('签单地点').AsString:=UpperCase(t_op_seae_assistant.FieldByName('签单地点').AsString); t_op_seae_assistant.FieldByName('预付地点').AsString:=UpperCase(t_op_seae_assistant.FieldByName('预付地点').AsString); t_op_seae_assistant.post; end; procedure Tfrm_op_seae_assistant.bsSkinSpeedButton2Click(Sender: TObject); var Edistring:TStrings; filenames:string; begin EdiString:=TStringList.Create; try OpenDialog1.Execute; FileNames:=OpenDialog1.FileName; if FileNames<>'' then begin EdiString.LoadFromFile(FileNames); NewEdiSEAE(EdiString,t_op_seae_assistant1); end; finally FreeAndNil(EdiString); end; end; procedure Tfrm_op_seae_assistant.wwDBLookupCombo4Change(Sender: TObject); begin if (t_op_ctn_fendan.State=dsedit)or(t_op_ctn_fendan.State=dsinsert) then begin if frm_data_share.t_code_ctn.Locate('代码',wwDBLookupCombo4.text,[]) then begin t_op_ctn_fendan['表现形式']:=frm_data_share.t_code_ctn['表现形式']; t_op_ctn_fendan['箱型']:=frm_data_share.t_code_ctn['箱型']; t_op_ctn_fendan['尺寸']:=frm_data_share.t_code_ctn['尺寸']; end else begin t_op_ctn_fendan['表现形式']:=''; t_op_ctn_fendan['箱型']:=''; t_op_ctn_fendan['尺寸']:=''; end; end; end; procedure Tfrm_op_seae_assistant.t_op_ctn_fendanAfterInsert( DataSet: TDataSet); begin t_op_ctn_fendan['编号']:=t_op_seae_assistant.FieldByName('AS_ID').AsInteger; t_op_ctn_fendan['数量']:=1; end; procedure Tfrm_op_seae_assistant.t_op_seae_assistantAfterScroll( DataSet: TDataSet); begin t_op_ctn_fendan.Open; end; procedure Tfrm_op_seae_assistant.t_op_ctn_fendanBeforeInsert( DataSet: TDataSet); begin if t_op_seae_assistant.IsEmpty then begin ShowMessage('请先点添加分单按钮,添加分单'); Abort; end; if t_op_seae_assistant.State in [dsEdit,dsInsert] then t_op_seae_assistant.Post; end; procedure Tfrm_op_seae_assistant.bsSkinButton15Click(Sender: TObject); begin frm_main.view_momo(t_op_ctn_fendan1,'品名'); end; procedure Tfrm_op_seae_assistant.DBMemo33Click(Sender: TObject); begin wwDBLookupCombo2.Text:='Num:'+IntToStr(Length(DBMemo33.Lines[DBMemo33.CaretPos.Y])); end; procedure Tfrm_op_seae_assistant.DBMemo34Click(Sender: TObject); begin wwDBLookupCombo5.Text:='Num:'+IntToStr(Length(DBMemo34.Lines[DBMemo34.CaretPos.Y])); end; procedure Tfrm_op_seae_assistant.DBMemo35Click(Sender: TObject); begin wwDBLookupCombo6.Text:='Num:'+IntToStr(Length(DBMemo35.Lines[DBMemo35.CaretPos.Y])); end; procedure Tfrm_op_seae_assistant.bsSkinButton16Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_assistant1,'EDI备注'); end; procedure Tfrm_op_seae_assistant.bsSkinButton17Click(Sender: TObject); var bok:Tbookmark; if_first:boolean; pkgs:integer; kgs,cbm:double; s,package:string; list1,list2,list3,list4:TStringList; begin if t_op_ctn_fendan.IsEmpty then exit; t_op_seae_assistant.AfterPost:=nil; t_op_ctn_fendan.First; if_first:=true; pkgs:=0; kgs:=0.00; cbm:=0.00; bok:=t_op_ctn_fendan.GetBookmark; try list1:=TStringList.Create; list2:=TStringList.Create; list3:=TStringList.Create; list4:=TStringList.Create; t_op_ctn_fendan.DisableControls; while not t_op_ctn_fendan.Eof do begin if if_first then begin if (Trim(t_op_ctn_fendan.fieldbyname('箱号').asstring)<>'') then list1.Text:=t_op_ctn_fendan.fieldbyname('箱号').asstring+'/'+t_op_ctn_fendan.fieldbyname('封号').asstring; list2.Text:=t_op_ctn_fendan.fieldbyname('件数').asstring+t_op_ctn_fendan.fieldbyname('包装').asstring; list3.Text:=t_op_ctn_fendan.fieldbyname('重量').asstring+'KGS'; list4.Text:=t_op_ctn_fendan.fieldbyname('尺码').asstring+'CBM'; pkgs:=t_op_ctn_fendan.fieldbyname('件数').asinteger; kgs:=t_op_ctn_fendan.fieldbyname('重量').asfloat; cbm:=t_op_ctn_fendan.fieldbyname('尺码').asfloat; package:=t_op_ctn_fendan.fieldbyname('包装').asstring; if_first:=false; end else begin if (Trim(t_op_ctn_fendan.fieldbyname('箱号').asstring)<>'') then list1.Add(t_op_ctn_fendan.fieldbyname('箱号').asstring+'/'+t_op_ctn_fendan.fieldbyname('封号').asstring); list2.Add(t_op_ctn_fendan.fieldbyname('件数').asstring+t_op_ctn_fendan.fieldbyname('包装').asstring); list3.Add(t_op_ctn_fendan.fieldbyname('重量').asstring+'KGS'); list4.Add(t_op_ctn_fendan.fieldbyname('尺码').asstring+'CBM'); pkgs:=pkgs+t_op_ctn_fendan.fieldbyname('件数').asinteger; kgs:=kgs+t_op_ctn_fendan.fieldbyname('重量').asfloat; cbm:=cbm+t_op_ctn_fendan.fieldbyname('尺码').asfloat; package:=t_op_ctn_fendan.fieldbyname('包装').asstring; end; t_op_ctn_fendan.next; end; t_op_seae_assistant.edit; t_op_seae_assistant.FieldByName('箱号封号').asstring:=list1.Text; t_op_seae_assistant.FieldByName('件数包装').asstring:=list2.Text; t_op_seae_assistant.FieldByName('货物重量').asstring:=list3.Text; t_op_seae_assistant.FieldByName('货物尺码').asstring:=list4.Text; t_op_seae_assistant.post; finally t_op_seae_assistant.AfterPost:=t_op_seae_assistantAfterPost; t_op_ctn_fendan.EnableControls; t_op_ctn_fendan.GotoBookmark(bok); list1.Free; list2.Free; list3.Free; list4.Free; end; end; procedure Tfrm_op_seae_assistant.bsSkinSpeedButton3Click(Sender: TObject); var Ext,vessel,voyno,tmpstr,strhscode,tmpexcel,ctnnumstr,ctntype,ctnsize:String; ExcelTemplet:Variant; TempstrList:Tstringlist; i,excelline,ctnnum:Integer; aQuery,aQuery2:TADOQuery; begin if not (t_op_seae_assistant.State in [dsedit,dsinsert]) then t_op_seae_assistant.Edit; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); TempstrList:=Tstringlist.Create; aQuery:=createAdoQuery; try ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[6,25].Value); t_op_seae_assistant.FieldByName('主提单号').AsString:=tmpstr; // if t_op_seae_assistant.FieldByName('场站').AsString='' then t_op_seae_assistant.FieldByName('场站').AsString:='港陆场站(付费)'; // t_op_seae_assistant.FieldByName('船公司').AsString:='MSC'; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[14,23].Value); if (tmpstr='') then tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[15,23].Value); if (tmpstr='') then tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[16,23].Value); if (tmpstr='') then tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[17,23].Value); if (tmpstr<>'') then begin TempstrList.Text:=tmpstr; t_op_seae_assistant.FieldByName('EDI备注').AsString:=tmpstr; for i:=0 to TempstrList.Count-1 do begin tmpstr:= TempstrList.Strings[i]; if pos('HS:',tmpstr)>0 then begin strhscode:=Copy(tmpstr,pos('HS:',tmpstr)+3,Length(tmpstr)-pos('HS:',tmpstr)-2); if (strhscode<>'') then t_op_seae_assistant.FieldByName('HS编码').AsString:=Trim(strhscode); end; end; end; for excelline:=2 to 70 do begin tmpexcel:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline,2].Value); if (tmpexcel='Shipper (发货人)') then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,2].Value); t_op_seae_assistant.FieldByName('发货人代码').AsString:=tmpstr; end; if (tmpexcel='Consignee (收货人)') then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+2,2].Value); t_op_seae_assistant.FieldByName('收货人代码').AsString:=tmpstr; end; if (tmpexcel='Notify Party (通知人)') then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,2].Value); t_op_seae_assistant.FieldByName('通知人代码').AsString:=tmpstr; end; if (tmpexcel='Ocean Vessel(船名) Voy. No. (航次)') then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,2].Value); if (Pos('-',tmpstr)>0) then begin vessel:=copy(tmpstr,0,Pos('-',tmpstr)-1); voyno:= copy(tmpstr,Pos('-',tmpstr)+1,Length(tmpstr)-Pos('-',tmpstr)-1); t_op_seae_assistant.FieldByName('船名').AsString:=Trim(vessel); t_op_seae_assistant.FieldByName('航次').AsString:=Trim(voyno); v_vessel_voyage.close; v_vessel_voyage.sql.text:='select * from v_vessel_voyage where 英文船名='''+Trim(vessel)+''' and 航次='''+Trim(voyno)+''''; v_vessel_voyage.open; if not v_vessel_voyage.isempty then t_op_seae_assistant['开船日期']:=v_vessel_voyage['开船日期']; v_vessel_voyage.Close; end; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,12].Value); t_op_seae_assistant.FieldByName('装货港').AsString:=tmpstr; end; if (tmpexcel='Port of Discharge (卸货港)') then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,2].Value); t_op_seae_assistant.FieldByName('卸货港').AsString:=tmpstr; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+1,13].Value); t_op_seae_assistant.FieldByName('交货地点').AsString:=tmpstr; t_op_seae_assistant.FieldByName('目的地').AsString:=tmpstr; end; if pos('Container No.',tmpexcel)>0 then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+5,2].Value); t_op_seae_assistant.FieldByName('唛头').AsString:=tmpstr; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+5,11].Value); if (tmpstr<>'') then begin tmpstr:=UpperCase(StringReplace(tmpstr,',','',[rfReplaceAll])); t_op_seae_assistant.FieldByName('件数包装').AsString:=tmpstr; t_op_seae_assistant['件数']:=totalstr_num(tmpstr); t_op_seae_assistant['包装']:=totalstr_package(tmpstr); t_op_seae_assistant['件数大写'] :='SAY:'+ntoc(t_op_seae_assistant.FieldByName('件数').asfloat,true) +t_op_seae_assistant.FieldByName('包装').asstring+' ONLY.'; end; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+7,15].Value); t_op_seae_assistant.FieldByName('货物描述').AsString:=tmpstr; if (tmpstr<>'') then begin TempstrList.Text:=tmpstr; if (TempstrList.Count>3) then begin tmpstr:=TempstrList.Strings[TempstrList.Count-5]; t_op_seae_assistant.FieldByName('运输条款').AsString:=StringReplace(tmpstr,'/','-',[]); end; end; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+5,31].Value); if (tmpstr<>'') then begin tmpstr:=StringReplace(tmpstr,',','',[rfReplaceAll]); if (Pos('KGS',tmpstr)<=0) then tmpstr:=tmpstr+'KGS'; t_op_seae_assistant.FieldByName('货物重量').AsString:=tmpstr; t_op_seae_assistant['重量']:=totalstr_num(tmpstr); end; tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+5,35].Value); if (tmpstr<>'') then begin tmpstr:=StringReplace(tmpstr,',','',[rfReplaceAll]); if (Pos('CBM',tmpstr)<=0) then tmpstr:=tmpstr+'CBM'; t_op_seae_assistant.FieldByName('货物尺码').AsString:=tmpstr; t_op_seae_assistant['尺码']:=totalstr_num(tmpstr); end; end; if pos('TOTAL NUMBER OF CONTAINERS',tmpexcel)>0 then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline-3,18].Value); if (tmpstr<>'') then begin t_op_seae_assistant.Post; ctnnumstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline-3,22].Value); ctnnum:=0; if (ctnnumstr<>'') then begin ctnnum:=StrToIntDef(ctnnumstr,0); if (ctnnum<>0) then begin tmpstr:=Copy(tmpstr,0,4); ctnsize:=Copy(tmpstr,0,2); ctntype:=Copy(tmpstr,3,2); aQuery2:=createAdoQuery; try aQuery2.close;aQuery2.sql.Clear; aQuery2.SQL.Add('select * from t_code_ctn where EDI代码EXCEL='''+tmpstr+''''); aQuery2.Open; if aQuery.IsEmpty then begin if not aQuery2.isempty then begin t_op_ctn_fendan.Insert; t_op_ctn_fendan.FieldByName('AS_ID').AsString:=t_op_seae_assistant.fieldbyname('AS_ID').AsString; t_op_ctn_fendan.FieldByName('代码').AsString:=aQuery2.fieldbyname('代码').AsString; t_op_ctn_fendan.FieldByName('箱型').AsString:=aQuery2.fieldbyname('箱型').AsString; t_op_ctn_fendan.FieldByName('尺寸').AsString:=aQuery2.fieldbyname('尺寸').AsString; t_op_ctn_fendan.FieldByName('表现形式').AsString:=aQuery2.fieldbyname('表现形式').AsString; t_op_ctn_fendan.FieldByName('数量').AsInteger:=ctnnum; if aQuery2.fieldbyname('尺寸').AsString='20'then t_op_ctn_fendan.FieldByName('TEU').AsInteger:=1; if (aQuery2.fieldbyname('尺寸').AsString='40') OR (aQuery2.fieldbyname('尺寸').AsString='45') then t_op_ctn_fendan.FieldByName('TEU').AsInteger:=2; t_op_ctn_fendan.Post; if not (t_op_seae_assistant.State in [dsedit,dsinsert]) then t_op_seae_assistant.Edit; t_op_seae_assistant.FieldByName('集装箱').AsString:=aQuery2.fieldbyname('表现形式').AsString+'*'+IntToStr(ctnnum); end; end else begin if (t_op_seae_assistant.FieldByName('集装箱').AsString<>(aQuery2.fieldbyname('表现形式').AsString+'*'+IntToStr(ctnnum)))then ShowMessage('注意:箱型箱量不一致!'); end; finally end; end; end; end; end; if pos('FREIGHT & CHARGES',tmpexcel)>0 then begin tmpstr:=VartoStr(ExcelTemplet.ActiveSheet.Cells[excelline+2,2].Value); if (tmpstr<>'') then begin if not (t_op_seae_assistant.State in [dsedit,dsinsert]) then t_op_seae_assistant.Edit; if (UpperCase(tmpstr)='COLLECT') then t_op_seae_assistant.FieldByName('付费方式').AsString:='FREIGHT COLLECT'; if (UpperCase(tmpstr)='PREPAID') then t_op_seae_assistant.FieldByName('付费方式').AsString:='FREIGHT PREPAID'; // if not aQuery.IsEmpty then update_ctn(aQuery); end; end; end; finally ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 FreeAndNil(TempstrList); FreeAndNil(aQuery); end; end; end; t_op_seae_assistant.Post; MessageDlg('导入完成!', mtConfirmation, [mbYes],0); end; procedure Tfrm_op_seae_assistant.bsSkinButton18Click(Sender: TObject); var yardcode:string; IdHTTP1:TIdHTTP; strmsg,company:string; Url : string;//请求地址 ResponseStream : TStringStream; //返回信息 ResponseStr: string; RequestStr : string; //请求信息 RequestStream : TStringStream; jo:ISuperobject; tt:TSuperArray; i:Integer; CTNALL,s_ctnno,s_ctnType,pkgs,kgs,cbm:string; begin if Trim(t_op_seae_assistant.DataSource.DataSet.fieldbyname('场站').AsString)='' then begin ShowMessage('场站不能为空!'); exit; end; if Trim(t_op_seae_assistant.fieldbyname('主提单号').AsString)='' then begin ShowMessage('主提单号不能为空!'); exit; end; yardcode:=getYardCode(Trim(t_op_seae_assistant.DataSource.DataSet.fieldbyname('场站').AsString)); if (yardcode='') then begin ShowMessage('场站东胜代码不能为空!'); exit; end; company:=frm_data_share.t_sys_company.fieldbyname('简称').AsString; ResponseStream := TStringStream.Create(''); RequestStream := TStringStream.Create(''); IdHTTP1:=TIdHTTP.Create(Application); try IdHttp1.Request.Accept := '*/*'; IdHttp1.Request.AcceptLanguage:='zh-CN'; IdHttp1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)'; IdHttp1.Request.ContentType:='application/x-www-form-urlencoded'; Url:='http://47.104.90.170:5000/query'; try RequestStr:='webusername=&webuserpass=&mblno='+Trim(t_op_seae_assistant.fieldbyname('主提单号').AsString)+'&yardid='+yardcode+'&isweb=0&custname='+company+'&psw='; //孙小华 RequestStream.WriteString(RequestStr); IdHttp1.post(Url,RequestStream,ResponseStream); except on e : Exception do begin end; end; ResponseStr := ResponseStream.DataString; //获取网页返回的信息 ResponseStr := UTF8Decode(ResponseStr); //网页中的存在中文时,需要进行UTF8解码 jo:=so(ResponseStr); if (jo.O['status'].AsString='0') then begin showmessage('无法提取,'+jo.O['message'].AsString); end else begin tt:=jo.O['message'].AsArray; for i:=0 to tt.Length-1 do begin CTNALL:=tt.O[i].S['CTNALL']; if t_op_ctn_fendan.Locate('箱号',Trim(tt.O[i].S['CNTRNO']),[]) then begin t_op_ctn_fendan.Edit; s_ctnno:=Copy(CTNALL,1,2); s_ctnType:=Copy(CTNALL,3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn_fendan.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; pkgs:=tt.O[i].S['PKGS']; kgs:=tt.O[i].S['KGS']; cbm:=tt.O[i].S['CBM']; if pkgs='' then pkgs:='0'; if kgs='' then kgs:='0'; if cbm='' then cbm:='0'; t_op_ctn_fendan.FieldByName('封号').AsString:=tt.O[i].S['SEALNO']; t_op_ctn_fendan.FieldByName('件数').AsInteger:=StrToInt(pkgs); t_op_ctn_fendan.FieldByName('包装').AsString:=t_op_ctn_fendan.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn_fendan.FieldByName('重量').AsFloat:=StrToFloatDef(kgs,0); t_op_ctn_fendan.FieldByName('尺码').AsFloat:=StrToFloatDef(cbm,0); t_op_ctn_fendan.Post; end else begin t_op_ctn_fendan.append; s_ctnno:=Copy(CTNALL,1,2); s_ctnType:=Copy(CTNALL,3,2); pkgs:=tt.O[i].S['PKGS']; kgs:=tt.O[i].S['KGS']; cbm:=tt.O[i].S['CBM']; if pkgs='' then pkgs:='0'; if kgs='' then kgs:='0'; if cbm='' then cbm:='0'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn_fendan.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn_fendan.FieldByName('箱号').AsString:=tt.O[i].S['CNTRNO']; t_op_ctn_fendan.FieldByName('封号').AsString:=tt.O[i].S['SEALNO']; t_op_ctn_fendan.FieldByName('件数').AsInteger:=StrToInt(pkgs); t_op_ctn_fendan.FieldByName('包装').AsString:=t_op_ctn_fendan.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn_fendan.FieldByName('重量').AsFloat:=StrToFloatDef(kgs,0); t_op_ctn_fendan.FieldByName('尺码').AsFloat:=StrToFloatDef(cbm,0); t_op_ctn_fendan.Post; end; end; end; finally FreeAndNil(IdHTTP1); end; end; function Tfrm_op_seae_assistant.getYardCode(yard: string): string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 东胜代码 from t_crm_client where 客户简称='''+yard+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('东胜代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_assistant.Button3Click(Sender: TObject); var dsstr,PostUrl:string; i:integer; str:widestring; aQuery:TADOQuery; begin if t_op_seae_assistant.IsEmpty then exit; dsstr:='{'; dsstr:=dsstr+'"orderNo":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('委托编号').AsString+'"'; dsstr:=dsstr+',"status":"N"'; dsstr:=dsstr+',"bookingId":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"bookingIdDate":"'+FormatDateTime('YYYY-MM-DD hh:mm:ss',t_op_seae_assistant.DataSource.DataSet.FieldByName('录入日期').asdatetime)+'"'; dsstr:=dsstr+',"bookingNumber":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"loadingOrderNo":"'+t_op_seae_assistant.FieldByName('主提单号').AsString+'"'; dsstr:=dsstr+',"hawbNo":""'; dsstr:=dsstr+',"pickUpCode":""'; dsstr:=dsstr+',"shipName":"'+t_op_seae_assistant.FieldByName('船名').AsString+'"'; dsstr:=dsstr+',"voyageNum":"'+t_op_seae_assistant.FieldByName('航次').AsString+'"'; dsstr:=dsstr+',"imo":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('发货人编号').AsString+'"'; dsstr:=dsstr+',"expectSailDate":"'+t_op_seae_assistant.FieldByName('开船日期').AsString+'"'; dsstr:=dsstr+',"expectArrivalDate":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('预抵日期').AsString+'"'; dsstr:=dsstr+',"actualSailDate":""'; dsstr:=dsstr+',"actualArrivalDate":""'; dsstr:=dsstr+',"twoShipName":""'; dsstr:=dsstr+',"twoVoyageNum":""'; dsstr:=dsstr+',"twoexpectSailDate":""'; dsstr:=dsstr+',"twoexpectArrivalDate":""'; dsstr:=dsstr+',"twoactualSailDate":""'; dsstr:=dsstr+',"twoactualArrivalDate":""'; dsstr:=dsstr+',"station":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('场站').AsString+'"'; dsstr:=dsstr+',"stationAddress":""'; dsstr:=dsstr+',"stationContacts":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('场站联系人').AsString+'"'; dsstr:=dsstr+',"stationContactsPhone":""'; dsstr:=dsstr+',"portCutDate":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('截港日期').AsString+'"'; dsstr:=dsstr+',"orderCutDate":"'+t_op_seae_assistant.DataSource.DataSet.FieldByName('截单日期').AsString+'"'; dsstr:=dsstr+',"suitcaseDate":""'; dsstr:=dsstr+',"cutOffDate":""'; dsstr:=dsstr+',"ebdDate":""'; dsstr:=dsstr+',"hbrDate":""'; dsstr:=dsstr+',"remark":""'; dsstr:=dsstr+'}'; PostUrl:=get_parameters_value(2124,'http://47.104.90.170:6857/api/clp/bookingMsgReceipt'); TDsHaierThread.create(PostUrl,dsstr,'',t_op_seae_assistant.FieldByName('主提单号').AsString); InsertSysLog('上传海尔下货纸',t_op_seae_assistant.DataSource.DataSet.FieldByName('业务编号').asstring); if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae_assistant.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+'''' else str:=str+','+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+''''; end; end else begin str:='('+''''+t_op_seae_assistant.fieldbyname('AS_ID').asstring+''''; end; str:=str+')'; t_pt_fendan.close; t_pt_fendan.sql.clear; t_pt_fendan.sql.add('select * from t_op_seae_assistant ' +'where AS_ID in '+str +' order by 主提单号'); t_pt_fendan.open; mailSend.EmptyTable; mailSend.Open; mailSend.Insert; mailSend.FieldByName('收件人').AsString:=get_parameters_value(2125,''); mailSend.FieldByName('邮件签名').AsString:=MailSignName; mailsend.fieldbyname('邮件主题').AsString :=t_op_seae_assistant.fieldbyname('主提单号').AsString+'下货纸'; mailSend.FieldByName('附件名称').AsString:=t_op_seae_assistant.fieldbyname('主提单号').AsString; mailSend.FieldByName('邮件内容').AsString:=''; mailSend.FieldByName('单据类型').AsString:='PDF'; mailSend.FieldByName('编号').AsString:=t_op_seae_assistant.DataSource.DataSet.fieldbyname('编号').AsString; mailSend.FieldByName('主提单号').AsString:=t_op_seae_assistant.fieldbyname('主提单号').AsString;//t_op_letter.DataSource.DataSet.fieldbyname('主提单号').AsString; mailSend.Post; try sys_print('海运出口单证',5,t_pt_fendan1,t_op_seae_assistant.DataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,true,t_op_seae_assistant.DataSource.DataSet.FieldByName('委托单位').asstring,nil,nil,mailSend,'PDF','HAIER 订舱单'); except end; end; end.