unit u_op_seae_edi; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon, Dialogs, bsSkinCtrls, ExtCtrls, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ComCtrls, bsSkinTabs, RxLookup, StdCtrls, Mask,inifiles, DBCtrls, wwdbdatetimepicker, wwdblook, u_op_sate, u_fee, u_op_card, Menus, dxDBTLCl, dxGrClms, bsdbctrls, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, Grids, Wwdbigrd, Wwdbgrid, FtpCli, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdIntercept, IdLogBase, IdLogEvent, IdAntiFreezeBase, IdAntiFreeze, dxEditor, dxEdLib, dxDBELib, IdExplicitTLSClientServerBase; type Tfrm_op_seae_edi = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; Notebook1: TNotebook; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid1: TdxDBGrid; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label5: TLabel; Label38: TLabel; DBEdit1: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit9: TDBEdit; PopupMenu3: TPopupMenu; N37: TMenuItem; N38: TMenuItem; N62: TMenuItem; N25: TMenuItem; N64: TMenuItem; N63: TMenuItem; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridDateColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridColumn; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPanel2: TbsSkinPanel; Label47: TLabel; Label49: TLabel; Label51: TLabel; wwDBDateTimePicker9: TwwDBDateTimePicker; wwDBDateTimePicker11: TwwDBDateTimePicker; Edit3: TEdit; wwDBDateTimePicker12: TwwDBDateTimePicker; Label52: TLabel; wwDBDateTimePicker13: TwwDBDateTimePicker; Label53: TLabel; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; Label60: TLabel; DBEdit10: TDBEdit; bsSkinButton14: TbsSkinButton; PopupMenu1: TPopupMenu; N1: TMenuItem; dxDBGrid1Column65: TdxDBGridColumn; dxDBGrid1Column67: TdxDBGridColumn; wwDBComboBoxType: TwwDBComboBox; Label45: TLabel; Label48: TLabel; wwDBComboBox2: TwwDBComboBox; bsSkinGroupBox4: TbsSkinGroupBox; bsSkinPanel3: TbsSkinPanel; Label36: TLabel; DBEdit38: TDBEdit; Label37: TLabel; DBEdit39: TDBEdit; Label39: TLabel; DBEdit40: TDBEdit; Label40: TLabel; DBEdit41: TDBEdit; Label41: TLabel; bsSkinDBRadioGroup1: TbsSkinDBRadioGroup; Label42: TLabel; wwDBComboBox8: TwwDBComboBox; Label44: TLabel; DBEdit42: TDBEdit; DBEdit43: TDBEdit; Label46: TLabel; Label50: TLabel; DBEdit44: TDBEdit; Label54: TLabel; DBEdit45: TDBEdit; DBEdit46: TDBEdit; Label55: TLabel; DBEdit47: TDBEdit; DBEdit48: TDBEdit; Label56: TLabel; DBEdit49: TDBEdit; DBEdit50: TDBEdit; Label57: TLabel; DBEdit51: TDBEdit; DBEdit52: TDBEdit; Label58: TLabel; DBEdit53: TDBEdit; Label59: TLabel; wwDBComboBox4: TwwDBComboBox; bsSkinGroupBox6: TbsSkinGroupBox; bsSkinPanel4: TbsSkinPanel; t_op_ctn1: TDataSource; t_op_ctn: TADOQuery; strngfld_op_ctnDSDesigner2: TStringField; strngfld_op_ctnDSDesigner6: TStringField; intgrfld_op_ctnDSDesigner5: TIntegerField; strngfld_op_ctnDSDesigner7: TStringField; strngfld_op_ctnDSDesigner8: TStringField; intgrfld_op_ctnDSDesigner9: TIntegerField; strngfld_op_ctnDSDesigner10: TStringField; bcdfld_op_ctnDSDesigner11: TBCDField; bcdfld_op_ctnDSDesigner12: TBCDField; strngfld_op_ctnDSDesigner14: TStringField; intgrfld_op_ctnTEU: TIntegerField; strngfld_op_ctnDSDesigner4: TStringField; strngfld_op_ctnDSDesigner3: TStringField; atncfld_op_ctnctn_id: TAutoIncField; strngfld_op_ctnDSDesigner: TStringField; bsSkinPanel9: TbsSkinPanel; bsSkinButton56: TbsSkinButton; bsSkinButton57: TbsSkinButton; bsSkinButton58: TbsSkinButton; bsSkinButton59: TbsSkinButton; wwDBLookupCombo16: TwwDBLookupCombo; wwDBLookupComboctn: TwwDBLookupCombo; wwDBGrid1: TwwDBGrid; Label4: TLabel; wwDBComboBox3: TwwDBComboBox; Label43: TLabel; DBEdit18: TDBEdit; t_op_ctnDSDesigner: TStringField; t_op_ctnPO: TStringField; t_op_ctnSKU: TStringField; t_op_ctnSKU2: TStringField; t_op_ctnUN: TStringField; t_op_ctnHTS: TStringField; t_op_ctnDSDesigner2: TStringField; t_op_ctnDSDesigner3: TBCDField; bsSkinGroupBox9: TbsSkinGroupBox; Label68: TLabel; wwDBComboBox15: TwwDBComboBox; DBEdit81: TDBEdit; wwDBLookupCombo61: TwwDBLookupCombo; DBEdit82: TDBEdit; Label169: TLabel; DBEdit83: TDBEdit; Label170: TLabel; Label63: TLabel; DBMemo38: TDBMemo; DBMemo39: TDBMemo; btnMarks: TbsSkinButton; btnDesc: TbsSkinButton; Label64: TLabel; Label65: TLabel; Label66: TLabel; Label67: TLabel; Label104: TLabel; DBEdit54: TDBEdit; Label106: TLabel; DBEdit55: TDBEdit; Label105: TLabel; wwDBComboBox6: TwwDBComboBox; Label109: TLabel; DBEdit56: TDBEdit; Label108: TLabel; DBEdit57: TDBEdit; Label69: TLabel; bsSkinPanel5: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; bsSkinSpeedButton1: TbsSkinSpeedButton; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBEdit8: TDBEdit; DBEdit11: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; bsSkinGroupBox2: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label25: TLabel; bsSkinSpeedButton2: TbsSkinSpeedButton; DBEdit17: TDBEdit; DBEdit19: TDBEdit; DBEdit20: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; DBEdit26: TDBEdit; DBEdit27: TDBEdit; bsSkinGroupBox3: TbsSkinGroupBox; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label34: TLabel; Label35: TLabel; bsSkinSpeedButton3: TbsSkinSpeedButton; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBEdit30: TDBEdit; DBEdit31: TDBEdit; DBEdit32: TDBEdit; DBEdit33: TDBEdit; DBEdit34: TDBEdit; DBEdit35: TDBEdit; DBEdit36: TDBEdit; DBEdit37: TDBEdit; bsSkinGroupBox5: TbsSkinGroupBox; DBMemo3: TDBMemo; bsSkinGroupBox7: TbsSkinGroupBox; DBMemo1: TDBMemo; bsSkinGroupBox8: TbsSkinGroupBox; DBMemo2: TDBMemo; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinButton48: TbsSkinButton; t_op_ctnDSDesigner4: TStringField; wwDBComboBoxOwner: TwwDBComboBox; SaveDialog1: TSaveDialog; t_op_ctn_detail: TADOQuery; IntegerField1: TIntegerField; StringField8: TStringField; BCDField1: TBCDField; BCDField2: TBCDField; StringField12: TStringField; StringField13: TStringField; BCDField3: TBCDField; t_op_ctn_detail1: TDataSource; bsSkinGroupBox10: TbsSkinGroupBox; wwDBGrid2: TwwDBGrid; bsSkinPanel6: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton13: TbsSkinButton; t_op_ctn_detailctn_id: TIntegerField; bsSkinButton15: TbsSkinButton; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinButton19: TbsSkinButton; Label73: TLabel; bsSkinButton20: TbsSkinButton; Label74: TLabel; bsSkinButton21: TbsSkinButton; Label75: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; RxDBLookupCombo2: TRxDBLookupCombo; t_code_shiper: TADOQuery; t_code_shiper1: TDataSource; t_code_consignee: TADOQuery; t_code_consignee1: TDataSource; t_code_notifyparty: TADOQuery; t_code_notifyparty1: TDataSource; bsSkinGroupBox11: TbsSkinGroupBox; Label61: TLabel; Label62: TLabel; Label70: TLabel; Label71: TLabel; Label72: TLabel; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; EditType: TEdit; bsSkinButton16: TbsSkinButton; bsSkinButton17: TbsSkinButton; bsSkinButton18: TbsSkinButton; FtpClient1: TFtpClient; lblstatus: TLabel; IdFTP1: TIdFTP; IdLogEvent1: TIdLogEvent; DebugListBox: TListBox; StatusBar1: TStatusBar; ProgressBar1: TProgressBar; Label76: TLabel; bsSkinButton22: TbsSkinButton; PopupMenu4: TPopupMenu; N2: TMenuItem; N3: TMenuItem; wwDBDateTimePicker3: TwwDBDateTimePicker; Label77: TLabel; DBEdit2: TDBEdit; Label78: TLabel; DBEdit58: TDBEdit; DBEdit59: TDBEdit; bsSkinButton23: TbsSkinButton; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; wwDBComboBoxFILETYPE: TwwDBComboBox; Label79: TLabel; DBEdit60: TDBEdit; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; N7: TMenuItem; CN11011: TMenuItem; Label80: TLabel; Edit1: TEdit; Label217: TLabel; wwDBLookupCombo26: TwwDBLookupCombo; Label218: TLabel; Edit8: TEdit; Label81: TLabel; Edit2: TEdit; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinSpeedButton1Click(Sender: TObject); procedure bsSkinSpeedButton2Click(Sender: TObject); procedure bsSkinSpeedButton3Click(Sender: TObject); procedure DBEdit3Change(Sender: TObject); procedure bsSkinButton56Click(Sender: TObject); procedure bsSkinButton57Click(Sender: TObject); procedure bsSkinButton58Click(Sender: TObject); procedure bsSkinButton59Click(Sender: TObject); procedure wwDBLookupComboctnChange(Sender: TObject); procedure btnMarksClick(Sender: TObject); procedure btnDescClick(Sender: TObject); procedure t_op_ctnAfterInsert(DataSet: TDataSet); procedure wwDBGrid1ColEnter(Sender: TObject); procedure bsSkinButton48Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure t_op_ctn_detailAfterInsert(DataSet: TDataSet); procedure t_op_ctn_detailBeforePost(DataSet: TDataSet); procedure t_op_ctn_detailBeforeInsert(DataSet: TDataSet); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); procedure bsSkinButton20Click(Sender: TObject); procedure bsSkinButton21Click(Sender: TObject); procedure RxDBLookupCombo16Enter(Sender: TObject); procedure RxDBLookupCombo16Exit(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure RxDBLookupCombo1Exit(Sender: TObject); procedure RxDBLookupCombo2Enter(Sender: TObject); procedure RxDBLookupCombo2Exit(Sender: TObject); procedure RxDBLookupCombo16Change(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure RxDBLookupCombo2Change(Sender: TObject); procedure IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); procedure IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); procedure bsSkinButton22Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure bsSkinButton23Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure t_op_ctnBeforePost(DataSet: TDataSet); procedure CN11011Click(Sender: TObject); procedure IdFTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); procedure IdFTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); private { Private declarations } AbortTransfer: Boolean; TransferrignData: Boolean; BytesToTransfer: LongWord; STime: TDateTime; procedure setconcolor; //设置控件的颜色 function istrueAFR(Dataset:TDataSet):Boolean; procedure createAFR(bltype:string;filepath:string); function getCtnAfr(code:string):string; function getPkgAfr(code:string):string; function formatAfrstr(str:string):string; procedure PutToDebugLog(Operation, S1: String); public { Public declarations } end; var frm_op_seae_edi: Tfrm_op_seae_edi; AverageSpeed: Double = 0; implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, u_code_edicode, u_op_seae_edi_custom_cosco, u_op_seae_edi_custom_zt, u_op_seae_edi_custom_WaiDai, u_op_seae_edi_custom_WaiDai_1101; {$R *.dfm} procedure Tfrm_op_seae_edi.setconcolor; begin end; procedure Tfrm_op_seae_edi.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_edi.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_seae_edi.Hide; frm_op_seae_edi.ManualFloat(frm_op_seae_edi.BoundsRect ); frm_main.freeTabs('frm_op_seae_edi'); action:=cafree; frm_op_seae_edi:=nil; end; procedure Tfrm_op_seae_edi.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/14); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton11.Width:=i; bsSkinButton14.Width:=i; bsSkinButton15.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; bsSkinButton48.Width:=i; bsSkinButton22.Width:=i; end; procedure Tfrm_op_seae_edi.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae); end; procedure Tfrm_op_seae_edi.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae); end; procedure Tfrm_op_seae_edi.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_seae); end; procedure Tfrm_op_seae_edi.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; DBEdit3.OnChange(Sender); end else begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_op_seae.post; end; if answer=mrNo then begin t_op_seae.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_op_seae_edi.bsSkinButton4Click(Sender: TObject); var i,j:Integer; strno:string; aQuery:TADOQuery; begin j:=dxDBGrid1.SelectedCount; strno:=' where 1=2 '; for i:=0 to j-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); strno:=strno+' or 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; end; if MessageDlg('确定要删除选中的'+inttostr(j)+'票业务数据吗?',mtWarning,[mbyes,mbno],0)=mryes then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add(' delete from t_op_ctn_detail_edi where ctn_id in (select ctn_id from t_op_ctn_edi '+strno+')'); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_ctn_edi '+strno); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_seae_edi '+strno); ExecSQL; end; finally FreeAndNil(aQuery); end; t_op_seae.Refresh; end; end; procedure Tfrm_op_seae_edi.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae); end; procedure Tfrm_op_seae_edi.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_op_seae.GetBookmark; t_op_seae.Refresh; t_op_seae.GotoBookmark(book1); end; procedure Tfrm_op_seae_edi.FormShow(Sender: TObject); begin Notebook1.PageIndex:=0; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=28; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; //委托编号处理 t_op_seae.Close; t_op_seae.SQL.clear; t_op_seae.SQL.Add('select top 100 * from t_op_seae_edi where EDI类型<>''CN'' AND ' +'(录入人='+''''+employee+''''+') order by 录入日期 desc '); t_op_seae.open; t_op_ctn.Open; t_op_ctn_detail.Open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; loadreggrid(dxdbgrid1,false,caption); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_code_shiper.open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_code_consignee.open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_code_notifyparty.open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; procedure Tfrm_op_seae_edi.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_edi.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_edi.N12Click(Sender: TObject); begin // update_grid(dxdbgrid1,101); end; procedure Tfrm_op_seae_edi.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_edi.bsSkinButton8Click(Sender: TObject); VAR str:widestring; begin str:='where EDI类型<>''CN'' AND '+open_data('0001','录入人','no','no','no','no'); if Edit3.text<>''then str:=str+' and 主提单号 like '+''''+'%'+Edit3.text+'%'+''''; if Edit1.text<>''then str:=str+' and 分提单号 like '+''''+'%'+Edit1.text+'%'+''''; if wwDBComboBoxType.text<>''then str:=str+' and EDI类型 like '+''''+wwDBComboBoxType.text+''''; if wwDBComboBox2.text<>''then str:=str+' and EDI状态 like '+''''+wwDBComboBox2.text+''''; if wwDBDateTimePicker9.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker9.text+''''; if wwDBDateTimePicker12.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker12.text+''''; if wwDBDateTimePicker11.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker13.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker13.text+''''; str:=query_tiaojian(1,str,'船名','模糊',wwDBLookupCombo26.text); str:=query_tiaojian(1,str,'航次','模糊',Edit8.text); if Edit2.text<>''then str:=str+' and 编号 in ( select 编号 from t_op_ctn_edi where 箱号 like '+''''+'%'+Edit2.text+'%'+''')'; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add('select * from t_op_seae_edi '+str+' order by 主提单号'); t_op_seae.open; end; procedure Tfrm_op_seae_edi.bsSkinButton12Click(Sender: TObject); begin Edit3.text:=''; Edit8.text:=''; Edit2.text:=''; Edit1.text:=''; wwDBDateTimePicker9.text:=''; wwDBDateTimePicker12.text:=''; wwDBDateTimePicker11.text:=''; wwDBDateTimePicker13.text:=''; wwDBComboBoxType.Text:=''; wwDBComboBox2.Text:=''; wwDBLookupCombo26.Clear; end; procedure Tfrm_op_seae_edi.bsSkinButton14Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton14.ClientToScreen(Point(0,bsSkinButton14.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi.bsSkinSpeedButton1Click(Sender: TObject); begin if bsSkinGroupBox5.Visible then begin bsSkinGroupBox5.Visible:=false; bsSkinGroupBox2.Visible:=true; end else begin bsSkinGroupBox5.left:=bsSkinGroupBox2.Left; bsSkinGroupBox5.Top:=bsSkinGroupBox2.Top; bsSkinGroupBox5.Height:=bsSkinGroupBox2.Height; bsSkinGroupBox5.Width:=bsSkinGroupBox2.Width; bsSkinGroupBox2.Visible:=False; bsSkinGroupBox5.Visible:=True; end; end; procedure Tfrm_op_seae_edi.bsSkinSpeedButton2Click(Sender: TObject); begin if bsSkinGroupBox7.Visible then begin bsSkinGroupBox7.Visible:=false; bsSkinGroupBox3.Visible:=true; end else begin bsSkinGroupBox7.left:=bsSkinGroupBox3.Left; bsSkinGroupBox7.Top:=bsSkinGroupBox3.Top; bsSkinGroupBox7.Height:=bsSkinGroupBox3.Height; bsSkinGroupBox7.Width:=bsSkinGroupBox3.Width; bsSkinGroupBox3.Visible:=False; bsSkinGroupBox7.Visible:=True; end; end; procedure Tfrm_op_seae_edi.bsSkinSpeedButton3Click(Sender: TObject); begin if bsSkinGroupBox8.Visible then begin bsSkinGroupBox8.Visible:=false; bsSkinGroupBox2.Visible:=true; end else begin bsSkinGroupBox8.left:=bsSkinGroupBox2.Left; bsSkinGroupBox8.Top:=bsSkinGroupBox2.Top; bsSkinGroupBox8.Height:=bsSkinGroupBox2.Height; bsSkinGroupBox8.Width:=bsSkinGroupBox2.Width; bsSkinGroupBox2.Visible:=False; bsSkinGroupBox8.Visible:=True; end; end; procedure Tfrm_op_seae_edi.DBEdit3Change(Sender: TObject); begin if (Trim(DBEdit3.Text)='AFR') or (Trim(DBEdit3.Text)='AMR') then begin Label15.font.color:=clGreen; Label40.Font.Color:=clGreen; Label10.Font.Color:=clGreen; if (Trim(DBEdit3.Text)='AMR') then Label44.Font.Color:=clBlack else Label44.Font.Color:=clGreen; Label12.Font.Color:=clGreen; Label50.Font.Color:=clGreen; Label25.font.color:=clGreen; Label20.Font.Color:=clGreen; Label22.Font.Color:=clGreen; Label35.font.color:=clGreen; Label30.Font.Color:=clGreen; Label32.Font.Color:=clGreen; Label77.font.color:=clGreen; Label78.Font.Color:=clGreen; Label79.Font.Color:=clGreen; DBEdit9.Hint:='最长20位'; DBEdit10.Hint:='最长20位'; DBEdit43.Hint:='最长9位'; DBEdit38.Hint:='最长20位'; DBEdit39.Hint:='最长5位'; DBEdit40.Hint:='最长4位'; DBEdit5.Hint:='最长40位'; DBEdit6.Hint:='最长35位'; DBEdit7.Hint:='最长35位'; DBEdit8.Hint:='最长30位'; DBEdit15.Hint:='最长2位'; DBEdit12.Hint:='最长10位'; DBEdit14.Hint:='最长14位'; DBEdit17.Hint:='最长40位'; DBEdit19.Hint:='最长35位'; DBEdit20.Hint:='最长35位'; DBEdit21.Hint:='最长30位'; DBEdit26.Hint:='最长2位'; DBEdit23.Hint:='最长10位'; DBEdit25.Hint:='最长14位'; DBEdit28.Hint:='最长40位'; DBEdit29.Hint:='最长35位'; DBEdit30.Hint:='最长35位'; DBEdit31.Hint:='最长30位'; DBEdit36.Hint:='最长2位'; DBEdit33.Hint:='最长10位'; DBEdit35.Hint:='最长14位'; DBEdit33.Hint:='最长10位'; DBEdit35.Hint:='最长14位'; DBEdit52.Hint:='最长5位'; DBEdit46.Hint:='最长5位'; DBEdit48.Hint:='最长5位'; DBEdit50.Hint:='最长5位'; Label68.font.color:=clGreen; Label104.Font.Color:=clGreen; Label106.Font.Color:=clGreen; Label105.font.color:=clGreen; Label109.Font.Color:=clGreen; Label108.Font.Color:=clGreen; Label66.font.color:=clGreen; Label67.Font.Color:=clGreen; Label63.Font.Color:=clGreen; Label69.Font.Color:=clGreen; Label64.font.color:=clGreen; Label65.Font.Color:=clGreen; Label11.Font.Color:=clGreen; Label21.Font.Color:=clGreen; Label31.Font.Color:=clGreen; // wwDBGrid1.ColumnByName('货值')..DisplayLabel.font.Color:=clGreen; // Label61.Color:=clRed; // Label62.Color:=clRed; // bsSkinDBCheckRadioBox1.Font.:=clRed; bsSkinGroupBox6.Caption:='集装箱详细信息(AFR 箱号/封号/尺寸/所有者/货描/唛头/HTS/件数/包装/重量/尺码为必填)' end else begin Label15.font.color:=clBlack; Label40.Font.Color:=clBlack; Label10.Font.Color:=clBlack; Label44.Font.Color:=clBlack; Label12.Font.Color:=clBlack; Label50.Font.Color:=clBlack; Label25.font.color:=clBlack; Label20.Font.Color:=clBlack; Label22.Font.Color:=clBlack; Label35.font.color:=clBlack; Label30.Font.Color:=clBlack; Label32.Font.Color:=clBlack; Label77.font.color:=clBlack; Label78.Font.Color:=clBlack; Label79.Font.Color:=clBlack; Label11.Font.Color:=clBlack; Label21.Font.Color:=clBlack; Label31.Font.Color:=clBlack; DBEdit9.Hint:=''; DBEdit10.Hint:=''; DBEdit43.Hint:=''; DBEdit38.Hint:=''; DBEdit39.Hint:=''; DBEdit40.Hint:=''; DBEdit5.Hint:=''; DBEdit6.Hint:=''; DBEdit7.Hint:=''; DBEdit8.Hint:=''; DBEdit15.Hint:=''; DBEdit12.Hint:=''; DBEdit14.Hint:=''; DBEdit17.Hint:=''; DBEdit19.Hint:=''; DBEdit20.Hint:=''; DBEdit21.Hint:=''; DBEdit26.Hint:=''; DBEdit23.Hint:=''; DBEdit25.Hint:=''; DBEdit28.Hint:=''; DBEdit29.Hint:=''; DBEdit30.Hint:=''; DBEdit31.Hint:=''; DBEdit36.Hint:=''; DBEdit33.Hint:=''; DBEdit35.Hint:=''; DBEdit33.Hint:=''; DBEdit35.Hint:=''; DBEdit52.Hint:=''; DBEdit46.Hint:=''; DBEdit48.Hint:=''; DBEdit50.Hint:=''; // Label61.Color:=clRed; // Label62.Color:=clRed; // bsSkinDBCheckRadioBox1.Font.:=clRed; bsSkinGroupBox6.Caption:='集装箱详细信息(AFR 箱号/封号/尺寸/所有者/货描/唛头/HTS/件数/包装/重量/尺码为必填)' end; end; procedure Tfrm_op_seae_edi.bsSkinButton56Click(Sender: TObject); begin t_op_ctn.insert; end; procedure Tfrm_op_seae_edi.bsSkinButton57Click(Sender: TObject); begin table_post(t_op_ctn); end; procedure Tfrm_op_seae_edi.bsSkinButton58Click(Sender: TObject); begin table_delete(t_op_ctn); end; procedure Tfrm_op_seae_edi.bsSkinButton59Click(Sender: TObject); begin table_cancel(t_op_ctn); end; procedure Tfrm_op_seae_edi.wwDBLookupComboctnChange(Sender: TObject); begin if (t_op_ctn.State=dsedit)or(t_op_ctn.State=dsinsert) then begin if frm_data_share.t_code_ctn.Locate('代码',wwDBLookupComboctn.text,[]) then begin t_op_ctn['表现形式']:=frm_data_share.t_code_ctn['表现形式']; t_op_ctn['箱型']:=frm_data_share.t_code_ctn['箱型']; t_op_ctn['尺寸']:=frm_data_share.t_code_ctn['尺寸']; end else begin t_op_ctn['表现形式']:=''; t_op_ctn['箱型']:=''; t_op_ctn['尺寸']:=''; end; end; end; procedure Tfrm_op_seae_edi.btnMarksClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'唛头'); end; procedure Tfrm_op_seae_edi.btnDescClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'货描'); end; procedure Tfrm_op_seae_edi.t_op_ctnAfterInsert(DataSet: TDataSet); begin t_op_ctn['编号']:=DBEdit35.DataSource.DataSet['编号']; t_op_ctn['数量']:=1; t_op_ctn['TEU']:=0; end; procedure Tfrm_op_seae_edi.wwDBGrid1ColEnter(Sender: TObject); begin if (wwDBGrid1.GetActiveField.FieldName='唛头') then begin // bsSkinPanel4.Visible:=true; // Label62.Visible:=True; // Label61.Visible:=false; // DBMemo5.Visible:=true; // DBMemo4.Visible:=false; end else if (wwDBGrid1.GetActiveField.FieldName='货描') then begin // bsSkinPanel4.Visible:=true; // Label62.Visible:=false; // Label61.Visible:=True; // DBMemo5.Visible:=false; // DBMemo4.Visible:=true; end else begin // bsSkinPanel4.Visible:=False; end; end; procedure Tfrm_op_seae_edi.bsSkinButton48Click(Sender: TObject); begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要保存EDI数据的业务!!'); exit; end; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; if (t_op_seae.FieldByName('EDI类型').AsString='AFR') or (t_op_seae.FieldByName('EDI类型').AsString='AMR') then createAFR(t_op_seae.FieldByName('EDI类型').AsString,''); end; procedure Tfrm_op_seae_edi.createAFR(bltype:string;filepath:string); var Str:TStrings; i:integer; istrue:Boolean; aQuery,aQuery2:TADOQuery; mblno:string; begin str:=Tstringlist.Create; aQuery:=CreateAdoQuery; aQuery2:=CreateAdoQuery; try for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); istrue:=istrueAFR(t_op_seae); if not istrue then Abort; end; Str.Add(''); Str.Add(''); for i:=0 to dxDBGrid1.SelectedCount-1 do begin Str.Add(''); t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); Str.Add(''+t_op_seae.fieldbyname('文件类型').AsString+''); mblno:=t_op_seae.fieldbyname('主提单号').AsString; if Pos(t_op_seae.fieldbyname('船公司代码').AsString,mblno)=1 then mblno:=Copy(mblno,Length(t_op_seae.fieldbyname('船公司代码').AsString)+1,length(mblno)-Length(t_op_seae.fieldbyname('船公司代码').AsString)); if bltype='AMR' then begin Str.Add(''+mblno+''); Str.Add(''+mblno+''); end else begin Str.Add(''+t_op_seae.fieldbyname('分提单号').AsString+''); Str.Add(''+mblno+''); end; Str.Add(''+t_op_seae.fieldbyname('订舱号码').AsString+''); if t_op_seae.fieldbyname('传输目的').AsString='D' then Str.Add('Delete') else Str.Add('AddReplace'); Str.Add(''); Str.Add(''+t_op_seae.fieldbyname('装运类型').AsString+''); Str.Add('Yes'); Str.Add('DOOR'); Str.Add('DOOR'); Str.Add(''); Str.Add(''); Str.Add(''+t_op_seae.fieldbyname('船名').AsString+''); Str.Add(''); Str.Add(''); Str.Add(''+t_op_seae.fieldbyname('航次').AsString+''); Str.Add(''+t_op_seae.fieldbyname('船舶IMO').AsString+''); Str.Add(''); Str.Add('PlaceOfReceipt'); Str.Add(''+t_op_seae.fieldbyname('交货代码').AsString+''); Str.Add('UN'); // Str.Add(''); // Str.Add(''); // Str.Add(''); // Str.Add(''); Str.Add(''); Str.Add(''); Str.Add('PortOfLoading'); Str.Add(''+t_op_seae.fieldbyname('装港代码').AsString+''); Str.Add('UN'); Str.Add(''+formatdatetime('YYYYMMDD',t_op_seae.fieldbyname('开船日期').Asdatetime)+''); if bltype='AMR' then begin Str.Add(''+formatdatetime('HHMM',t_op_seae.fieldbyname('开船日期').Asdatetime)+''); END; // Str.Add(''); // Str.Add(''); Str.Add(''); Str.Add(''); Str.Add('PortOfDischarge'); Str.Add(''+t_op_seae.fieldbyname('卸货代码').AsString+''); Str.Add('UN'); if t_op_seae.fieldbyname('预抵日期').AsString<>'' then Str.Add(''+formatdatetime('YYYYMMDD',t_op_seae.fieldbyname('预抵日期').Asdatetime)+''); // Str.Add(''); // Str.Add(''); // Str.Add(''); Str.Add(''); Str.Add(''); Str.Add('PlaceOfDelivery'); Str.Add(''+t_op_seae.fieldbyname('目的代码').AsString+''); Str.Add('UN'); // Str.Add(''); // Str.Add(''); // Str.Add(''); // Str.Add(''); Str.Add(''); Str.Add(''); Str.Add(''); Str.Add('Shipper'); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('发货人名称').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('发货人地址1').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('发货人地址2').AsString)+''); Str.Add(''+t_op_seae.fieldbyname('发货人城市').AsString+''); Str.Add(''+t_op_seae.fieldbyname('发货人州').AsString+''); Str.Add(''+t_op_seae.fieldbyname('发货人邮编').AsString+''); Str.Add(''+t_op_seae.fieldbyname('发货人国家代码').AsString+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('发货人联系人').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('发货人电话').AsString)+''); Str.Add(''); Str.Add(''); Str.Add('Consignee'); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人名称').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人地址1').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人地址2').AsString)+''); Str.Add(''+t_op_seae.fieldbyname('收货人城市').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人州').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人邮编').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人国家代码').AsString+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人联系人').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人电话').AsString)+''); Str.Add(''); if t_op_seae.FieldByName('同收货人').AsBoolean then begin Str.Add(''); Str.Add('Notify'); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人名称').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人地址1').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人地址2').AsString)+''); Str.Add(''+t_op_seae.fieldbyname('收货人城市').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人州').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人邮编').AsString+''); Str.Add(''+t_op_seae.fieldbyname('收货人国家代码').AsString+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人联系人').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('收货人电话').AsString)+''); Str.Add(''); end else begin Str.Add(''); Str.Add('Notify'); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人名称').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人地址1').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人地址2').AsString)+''); Str.Add(''+t_op_seae.fieldbyname('通知人城市').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人州').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人邮编').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人国家代码').AsString+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人联系人').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人电话').AsString)+''); Str.Add(''); end; if trim(t_op_seae.FieldByName('通知人2名称').AsString)<>'' then begin Str.Add(''); Str.Add('Notify2'); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人2名称').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人2地址1').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人2地址2').AsString)+''); Str.Add(''+t_op_seae.fieldbyname('通知人2城市').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人2州').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人2邮编').AsString+''); Str.Add(''+t_op_seae.fieldbyname('通知人2国家代码').AsString+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人2联系人').AsString)+''); Str.Add(''+formatAfrstr(t_op_seae.fieldbyname('通知人2电话').AsString)+''); Str.Add(''); end; Str.Add(''); Str.Add('AFR'); Str.Add(''+t_op_seae.fieldbyname('船公司代码').AsString+''); Str.Add(''+t_op_seae.fieldbyname('运输方式').AsString+''); if t_op_seae.fieldbyname('文件类型').AsString='House' then begin if t_op_seae.fieldbyname('是否最后分票').AsBoolean then Str.Add('Yes') else Str.Add('No'); end; if bltype='AMR' then begin Str.Add('NACCS'); Str.Add(''+t_op_seae.fieldbyname('代理代码').AsString+''); end; Str.Add(''); aQuery.Close; aQuery.SQL.text:='select * from t_op_ctn_edi where 编号='''+t_op_seae.fieldbyname('编号').AsString+''''; aQuery.Open; aQuery.First; while not aQuery.Eof do begin Str.Add(''); Str.Add(''+aQuery.fieldbyname('箱号').AsString+''); Str.Add(''+aQuery.fieldbyname('封号').AsString+''); Str.Add(''+getCtnAfr(aQuery.fieldbyname('代码').AsString)+''); Str.Add(''+aQuery.fieldbyname('箱子所有者').AsString+''); Str.Add(''); Str.Add(''+formatAfrstr(aQuery.fieldbyname('货描').AsString)+''); Str.Add(''+formatAfrstr(aQuery.fieldbyname('唛头').AsString)+''); aQuery2.Close; aQuery2.SQL.text:='select * from t_op_ctn_detail_edi where ctn_id='+aQuery.fieldbyname('ctn_id').AsString; aQuery2.Open; aQuery2.First; while not aQuery2.eof do begin Str.Add(''); // Str.Add(''+aQuery.fieldbyname('PO').AsString+''); // Str.Add(''+aQuery.fieldbyname('SKU').AsString+''); // Str.Add(''+formatAfrstr(aQuery.fieldbyname('SKU描述').AsString)+''); Str.Add(''+aQuery2.fieldbyname('公害行UN号').AsString+''); Str.Add(''+aQuery2.fieldbyname('HTS号').AsString+''); Str.Add(''); Str.Add(''+aQuery2.fieldbyname('件数').AsString+''); Str.Add(''+getPkgAfr(aQuery2.fieldbyname('包装').AsString)+''); Str.Add(''+formatfloat('0.00',aQuery2.fieldbyname('重量').AsFloat)+''); Str.Add(''+formatfloat('0.000',aQuery2.fieldbyname('尺码').AsFloat)+''); Str.Add(''); aQuery2.Next; end; Str.Add(''); aQuery.Next; end; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已生成文件'; t_op_seae.Post; Str.Add(''); end; Str.Add(''); if filepath='' then begin SaveDialog1.FileName:=t_op_seae.fieldbyname('分提单号').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.XML'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; end else begin Str.SaveToFile(filepath); end; finally FreeAndNil(aQuery); FreeAndNil(aQuery2); FreeAndNil(Str) end; end; function Tfrm_op_seae_edi.istrueAFR(Dataset: TDataSet): Boolean; var cntrs:String; aQuery,aQuery2:TADOQuery; begin result:=true; if Dataset.fieldbyname('文件类型').AsString='' then begin result:=false; MessageDlg('文件类型不能为空',mtWarning,[mbOk],0); exit; end else begin if Dataset.fieldbyname('文件类型').AsString='House' then begin if Dataset.fieldbyname('分提单号').AsString='' then begin result:=false; MessageDlg('House提单号不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('分提单号').AsString))>20 then begin result:=false; MessageDlg('House提单号长度不能超过20个字符',mtWarning,[mbOk],0); exit; end; end; end; end; if Dataset.fieldbyname('主提单号').AsString='' then begin result:=false; MessageDlg('主提单号不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('主提单号').AsString))>20 then begin result:=false; MessageDlg('主提单号长度不能超过20个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('船舶IMO').AsString='' then begin result:=false; MessageDlg('船舶呼号不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('船舶IMO').AsString))>9 then begin result:=false; MessageDlg('船舶呼号长度不能超过9个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('装运类型').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'装运类型不能为空',mtWarning,[mbOk],0); exit; end; {* if Dataset.fieldbyname('文件类型').AsString<>'House' then begin if Dataset.fieldbyname('运输条款').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'CY状态不能为空',mtWarning,[mbOk],0); exit; end; end; *} if Dataset.fieldbyname('船名').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'船名不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('船名').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'船名长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end; if length(Trim(Dataset.fieldbyname('航次').AsString))>10 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'航次长度不能超过10个字符',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('文件类型').AsString<>'House' then begin if trim(DataSet.fieldbyname('开船日期').asstring)='' then begin result:=false; MessageDlg('开船日期不能为空',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('交货代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货港代码不能为空',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('装港代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'装港代码不能为空',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('卸货代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'卸货代码不能为空',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('目的代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'目的地代码不能为空',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('船公司代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'船公司代码不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('船公司代码').AsString))>4 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'船公司代码长度不能超过4个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('发货人名称').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人名称不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('发货人名称').AsString))>40 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人名称长度不能超过40个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('发货人地址1').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人地址1不能为空',mtWarning,[mbOk],0); exit; end else begin if Dataset.fieldbyname('文件类型').AsString='House' then begin if length(Trim(Dataset.fieldbyname('发货人地址1').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人地址1长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end else begin if length(Trim(Dataset.fieldbyname('发货人地址1').AsString))>50 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人地址1长度不能超过50个字符',mtWarning,[mbOk],0); exit; end; end; end; if Dataset.fieldbyname('发货人城市').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人城市不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('发货人城市').AsString))>30 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人城市长度不能超过30个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('发货人国家代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人国家代码不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('发货人国家代码').AsString))>2 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人国家代码长度不能超过2个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('发货人电话').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人电话不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('发货人电话').AsString))>14 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人电话长度不能超过14个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('发货人邮编').AsString='' then begin // result:=false; // MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人邮编不能为空',mtWarning,[mbOk],0); // exit; end else begin if length(Trim(Dataset.fieldbyname('发货人邮编').AsString))>10 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人邮编长度不能超过10个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('文件类型').AsString='House' then begin if length(Trim(Dataset.fieldbyname('发货人地址2').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人地址2长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end else begin if length(Trim(Dataset.fieldbyname('发货人地址2').AsString))>50 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人地址2长度不能超过50个字符',mtWarning,[mbOk],0); exit; end; end; if length(Trim(Dataset.fieldbyname('发货人州').AsString))>3 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'发货人州长度不能超过3个字符',mtWarning,[mbOk],0); exit; end; if Dataset.fieldbyname('收货人名称').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人名称不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('收货人名称').AsString))>40 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人名称长度不能超过40个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('收货人地址1').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人地址1不能为空',mtWarning,[mbOk],0); exit; end else begin if Dataset.fieldbyname('文件类型').AsString='House' then begin if length(Trim(Dataset.fieldbyname('收货人地址1').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人地址1长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end else begin if length(Trim(Dataset.fieldbyname('收货人地址1').AsString))>50then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人地址1长度不能超过50个字符',mtWarning,[mbOk],0); exit; end; end; end; if Dataset.fieldbyname('收货人城市').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人城市不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('收货人城市').AsString))>30 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人城市长度不能超过30个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('收货人国家代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人国家代码不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('收货人国家代码').AsString))>2 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人国家代码长度不能超过2个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('收货人电话').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人电话不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('收货人电话').AsString))>14 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人电话长度不能超过23个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('收货人邮编').AsString='' then begin // result:=false; // MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人邮编不能为空',mtWarning,[mbOk],0); // exit; end else begin if length(Trim(Dataset.fieldbyname('收货人邮编').AsString))>10 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人邮编长度不能超过10个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('文件类型').AsString='House' then begin if length(Trim(Dataset.fieldbyname('收货人地址2').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人地址2长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end else begin if length(Trim(Dataset.fieldbyname('收货人地址2').AsString))>50 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人地址2长度不能超过50个字符',mtWarning,[mbOk],0); exit; end; end; if length(Trim(Dataset.fieldbyname('收货人州').AsString))>3 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'收货人州长度不能超过3个字符',mtWarning,[mbOk],0); exit; end; if not Dataset.FieldByName('同收货人').AsBoolean then begin if Dataset.fieldbyname('通知人名称').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人名称不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('通知人名称').AsString))>40 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人名称长度不能超过40个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('通知人地址1').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人地址1不能为空',mtWarning,[mbOk],0); exit; end else begin if Dataset.fieldbyname('文件类型').AsString='House' then begin if length(Trim(Dataset.fieldbyname('通知人地址1').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人地址1长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; end else begin if length(Trim(Dataset.fieldbyname('通知人地址1').AsString))>50 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人地址1长度不能超过50个字符',mtWarning,[mbOk],0); exit; end; end; end; if Dataset.fieldbyname('通知人城市').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人城市不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('通知人城市').AsString))>30 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人城市长度不能超过30个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('通知人国家代码').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人国家代码不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('通知人国家代码').AsString))>2 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人国家代码长度不能超过2个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('通知人电话').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人电话不能为空',mtWarning,[mbOk],0); exit; end else begin if length(Trim(Dataset.fieldbyname('通知人电话').AsString))>14 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人电话长度不能超过14个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('通知人邮编').AsString='' then begin // result:=false; // MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人邮编不能为空',mtWarning,[mbOk],0); // exit; end else begin if length(Trim(Dataset.fieldbyname('通知人邮编').AsString))>10 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人邮编长度不能超过10个字符',mtWarning,[mbOk],0); exit; end; end; if length(Trim(Dataset.fieldbyname('通知人地址2').AsString))>35 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人地址2长度不能超过35个字符',mtWarning,[mbOk],0); exit; end; if length(Trim(Dataset.fieldbyname('通知人州').AsString))>3 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'通知人州长度不能超过3个字符',mtWarning,[mbOk],0); exit; end; end; if Dataset.fieldbyname('运输方式').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'运输方式不能为空',mtWarning,[mbOk],0); exit; end; aQuery:=CreateAdoQuery; aQuery2:=CreateAdoQuery; try with aQuery do begin Close; SQL.Text:='select * from t_op_ctn_edi where 编号='''+dataset.fieldbyname('编号').AsString+''''; Open; if IsEmpty then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱信息不能为空',mtWarning,[mbOk],0); exit; end else begin aQuery.First; while not aQuery.Eof do begin if aQuery.fieldbyname('箱号').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'箱号不能为空',mtWarning,[mbOk],0); exit; end else begin if length(aQuery.fieldbyname('箱号').AsString)<>11 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'箱号录入不正确',mtWarning,[mbOk],0); exit; end; end; if aQuery.fieldbyname('封号').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'封号不能为空',mtWarning,[mbOk],0); exit; end else begin if length(aQuery.fieldbyname('封号').AsString)>15 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'封号长度不能超过15个字符',mtWarning,[mbOk],0); exit; end; end; if getCtnAfr(aQuery.fieldbyname('代码').AsString)='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱AFR代码不能为空',mtWarning,[mbOk],0); exit; end; if aQuery.fieldbyname('箱子所有者').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'箱子所有者不能为空',mtWarning,[mbOk],0); exit; end; if aQuery.fieldbyname('货描').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货描不能为空',mtWarning,[mbOk],0); exit; end else begin if length(aQuery.fieldbyname('货描').AsString)>180 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货描长度不能超过180个字符',mtWarning,[mbOk],0); exit; end; end; if aQuery.fieldbyname('唛头').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱唛头不能为空',mtWarning,[mbOk],0); exit; end else begin if length(aQuery.fieldbyname('唛头').AsString)>180 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱唛头不能超过180个字符',mtWarning,[mbOk],0); exit; end; end; aQuery2.Close; aQuery2.SQL.Text:='select * from t_op_ctn_detail_edi where ctn_id='''+aQuery.fieldbyname('ctn_id').AsString+''''; aQuery2.Open; if aQuery2.IsEmpty then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱内货物信息不能为空',mtWarning,[mbOk],0); exit; end else begin aQuery2.First; while not aQuery2.Eof do begin if aQuery2.fieldbyname('HTS号').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物HTS号码不能为空',mtWarning,[mbOk],0); exit; end else begin if length(aQuery2.fieldbyname('HTS号').AsString)>6 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物HTS号码不能超过6个字符',mtWarning,[mbOk],0); exit; end; end; if aQuery2.fieldbyname('件数').AsInteger=0 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物件数不能为空',mtWarning,[mbOk],0); exit; end; if aQuery2.fieldbyname('包装').AsString='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物包装不能为空',mtWarning,[mbOk],0); exit; end else begin if getPkgAfr(aQuery2.fieldbyname('包装').AsString)='' then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物包装的AFR代码不能为空',mtWarning,[mbOk],0); exit; end; end; if aQuery2.fieldbyname('重量').AsFloat=0 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物重量不能为空',mtWarning,[mbOk],0); exit; end; if aQuery2.fieldbyname('尺码').AsFloat=0 then begin result:=false; MessageDlg('提单号:'+Dataset.fieldbyname('主提单号').AsString+'集装箱货物尺码不能为空',mtWarning,[mbOk],0); exit; end; aQuery2.Next; end; end; aQuery.Next; end; end; end; finally FreeAndNil(aQuery); FreeAndNil(aQuery2); end; end; function Tfrm_op_seae_edi.getCtnAfr(code: string): string; var aQuery:TADOQuery; begin result:=''; aQuery:=CreateAdoQuery; try with aQuery do begin Close; SQL.Text:='select AFR代码 from t_code_ctn where 代码='''+code+''''; Open; Result:=aQuery.fieldbyname('AFR代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi.getPkgAfr(code: string): string; var aQuery:TADOQuery; begin result:=''; aQuery:=CreateAdoQuery; try with aQuery do begin Close; SQL.Text:='select AFR代码 from t_code_package where 代码='''+code+''''; Open; if not IsEmpty then Result:=aQuery.fieldbyname('AFR代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi.formatAfrstr(str: string): string; begin Result:=Trim(str); Result:=StringReplace(Result,'&','&',[rfReplaceAll]); Result:=StringReplace(Result,'<','<',[rfReplaceAll]); Result:=StringReplace(Result,'"','"',[rfReplaceAll]); Result:=StringReplace(Result,'>','>',[rfReplaceAll]); Result:=StringReplace(Result,'''',''',[rfReplaceAll]); end; procedure Tfrm_op_seae_edi.bsSkinButton1Click(Sender: TObject); begin t_op_ctn_detail.insert; end; procedure Tfrm_op_seae_edi.bsSkinButton9Click(Sender: TObject); begin table_post(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi.bsSkinButton10Click(Sender: TObject); begin table_delete(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi.bsSkinButton13Click(Sender: TObject); begin table_cancel(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi.t_op_ctn_detailAfterInsert(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi.t_op_ctn_detailBeforePost(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi.t_op_ctn_detailBeforeInsert(DataSet: TDataSet); begin if t_op_ctn.State in [dsedit,dsinsert] then t_op_ctn.Post; end; procedure Tfrm_op_seae_edi.bsSkinButton15Click(Sender: TObject); var inifile1:Tinifile; issend:Boolean; i:Integer; begin issend:=false; for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if t_op_seae.FieldByName('EDI状态').AsString='已发送' then issend:=True; end; if issend then begin if MessageDlg('所选择的舱单中存在已发送的报文,确实要重新发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then Abort; end; EditType.Text:=t_op_seae.FieldByName('EDI类型').AsString; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); // edit1.text:=inifile1.ReadString('customEDI','SEND',''); // edit2.text:=inifile1.ReadString('customEDI','RECIEVE',''); // edit3.text:=inifile1.ReadString('customEDI','SENDNAME',''); edit4.text:=inifile1.ReadString('custom'+EditType.Text,'FTPSERVER',''); edit5.text:=inifile1.ReadString('custom'+EditType.Text,'FTPPATH','/'); edit6.text:=inifile1.ReadString('custom'+EditType.Text,'FTPNAME',''); edit7.text:=inifile1.ReadString('custom'+EditType.Text,'FTPPASS',''); inifile1.free; bsSkinGroupBox11.Height:=220; DebugListBox.Visible:=false; StatusBar1.Visible:=false; bsSkinGroupBox11.Visible:=true; end; procedure Tfrm_op_seae_edi.bsSkinButton17Click(Sender: TObject); begin try if IdFTP1.Connected then begin IdFTP1.Abort; IdFTP1.Quit; end; finally bsSkinGroupBox11.Visible:=false; bsSkinButton16.Enabled:=True; end; end; procedure Tfrm_op_seae_edi.bsSkinButton16Click(Sender: TObject); var strpath:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; i:integer; SenderCode,ReciverCode,strType:String; issend:Boolean; begin ScriptPath:=ExtractFilePath(ParamStr(0))+'CUSTOMEDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(edit4.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(edit6.Text); if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(edit7.Text); if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(edit5.Text); strpath:=ScriptPath +t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.XML'; str_file:=t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.XML'; if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要保存EDI数据的业务!!'); exit; end; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; if (t_op_seae.FieldByName('EDI类型').AsString='AFR') or (t_op_seae.FieldByName('EDI类型').AsString='AMR') then createAFR(t_op_seae.FieldByName('EDI类型').AsString,strpath); { FtpClient1.UserName:=ftpname; FtpClient1.PassWord:=ftppass; FtpClient1.HostName:=ftpar; FtpClient1.Passive:=False; FtpClient1.MultiThreaded:=True; FtpClient1.Port:='21'; FtpClient1.DisplayFileFlag:=True; FtpClient1.Timeout:=5; try if (FtpClient1.Open) and (FtpClient1.User) and (FtpClient1.Pass) then begin lblstatus.Caption:='用户连接成功!'; FtpClient1.HostDirName:=ftppath; if FtpClient1.Cwd then end else begin showmessage('用户连接失败!'); end; if FtpClient1.Connected then begin try FtpClient1.TransferMode := ftpTransModeStream; FtpClient1.LocalFileName:=strpath; FtpClient1.HostFileName:= str_file; try if FtpClient1.Put then begin ShowMessage('上传成功'); lblstatus.Caption:='上传成功!'; bsSkinGroupBox11.Visible:=false; end; except FtpClient1.Abort; ShowMessage('上传失败!'); lblstatus.Caption:='上传失败!'; end; finally FtpClient1.Abort; end; end; except on e:exception do begin FtpClient1.Abort; lblstatus.Caption:='用户连接失败!'; end; end; } try try bsSkinButton16.Enabled:=false; bsSkinGroupBox11.Height:=385; DebugListBox.Visible:=True; DebugListBox.Clear; StatusBar1.Visible:=true; ProgressBar1.Parent := StatusBar1; ProgressBar1.Top := 2; ProgressBar1.Left := 1; ProgressBar1.Align := alClient; with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(strpath,str_file); showmessage('文件上传成功!'); bsSkinGroupBox11.Visible:=false; bsSkinButton16.Enabled:=true; for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; try idftp1.Disconnect; except end; except bsSkinButton16.Enabled:=true; deletefile(strpath); showmessage('文件上传错误!'); end; finally bsSkinButton16.Enabled:=true; end; end; procedure Tfrm_op_seae_edi.bsSkinButton18Click(Sender: TObject); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); // inifile1.WriteString('customEDI','SEND',edit1.text); // inifile1.WriteString('customEDI','RECIEVE',edit2.text); // inifile1.WriteString('customEDI','SENDNAME',edit3.text); inifile1.WriteString('custom'+EditType.text,'FTPSERVER',edit4.text); inifile1.WriteString('custom'+EditType.text,'FTPPATH',edit5.text); inifile1.WriteString('custom'+EditType.text,'FTPNAME',edit6.text); inifile1.WriteString('custom'+EditType.text,'FTPPASS',edit7.text); inifile1.free; end; procedure Tfrm_op_seae_edi.bsSkinButton19Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo16.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('发货人').AsString; frm_code_edicode.t_code_edicode.FieldByName('发货人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('发货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('发货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('发货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('发货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('发货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('发货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('发货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('发货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('发货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('发货人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('发货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('发货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('发货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('发货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('发货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('发货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('发货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('发货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('发货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('发货人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_shiper.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi.bsSkinButton20Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo1.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('收货人').AsString; frm_code_edicode.t_code_edicode.FieldByName('收货人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_consignee.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi.bsSkinButton21Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo2.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('通知人').AsString; frm_code_edicode.t_code_edicode.FieldByName('通知人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('通知人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('通知人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('通知人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('通知人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('通知人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('通知人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('通知人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('通知人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('通知人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('通知人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('通知人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('通知人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('通知人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('通知人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('通知人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('通知人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('通知人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('通知人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('通知人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('通知人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_notifyparty.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo16Enter(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo16Exit(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo1Enter(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo1Exit(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo2Enter(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo2Exit(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo16Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo16.DisplayValue<>'' then begin t_op_seae.fieldbyname('发货人名称').AsString:=t_code_shiper.FieldByName('名称').AsString; t_op_seae.fieldbyname('发货人地址1').AsString:=t_code_shiper.FieldByName('地址1').AsString; t_op_seae.fieldbyname('发货人地址2').AsString:=t_code_shiper.FieldByName('地址2').AsString; t_op_seae.fieldbyname('发货人地址3').AsString:=t_code_shiper.FieldByName('地址3').AsString; t_op_seae.fieldbyname('发货人城市').AsString:=t_code_shiper.FieldByName('城市').AsString; t_op_seae.fieldbyname('发货人邮编').AsString:=t_code_shiper.FieldByName('邮编').AsString; t_op_seae.fieldbyname('发货人国家代码').AsString:=t_code_shiper.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('发货人联系人').AsString:=t_code_shiper.FieldByName('联系人').AsString; t_op_seae.fieldbyname('发货人电话').AsString:=t_code_shiper.FieldByName('电话').AsString; t_op_seae.fieldbyname('发货人州').AsString:=t_code_shiper.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo1Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo1.DisplayValue<>'' then begin t_op_seae.fieldbyname('收货人名称').AsString:=t_code_consignee.FieldByName('名称').AsString; t_op_seae.fieldbyname('收货人地址1').AsString:=t_code_consignee.FieldByName('地址1').AsString; t_op_seae.fieldbyname('收货人地址2').AsString:=t_code_consignee.FieldByName('地址2').AsString; t_op_seae.fieldbyname('收货人地址3').AsString:=t_code_consignee.FieldByName('地址3').AsString; t_op_seae.fieldbyname('收货人城市').AsString:=t_code_consignee.FieldByName('城市').AsString; t_op_seae.fieldbyname('收货人邮编').AsString:=t_code_consignee.FieldByName('邮编').AsString; t_op_seae.fieldbyname('收货人国家代码').AsString:=t_code_consignee.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('收货人联系人').AsString:=t_code_consignee.FieldByName('联系人').AsString; t_op_seae.fieldbyname('收货人电话').AsString:=t_code_consignee.FieldByName('电话').AsString; t_op_seae.fieldbyname('收货人州').AsString:=t_code_consignee.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi.RxDBLookupCombo2Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo2.DisplayValue<>'' then begin t_op_seae.fieldbyname('通知人名称').AsString:=t_code_notifyparty.FieldByName('名称').AsString; t_op_seae.fieldbyname('通知人地址1').AsString:=t_code_notifyparty.FieldByName('地址1').AsString; t_op_seae.fieldbyname('通知人地址2').AsString:=t_code_notifyparty.FieldByName('地址2').AsString; t_op_seae.fieldbyname('通知人地址3').AsString:=t_code_notifyparty.FieldByName('地址3').AsString; t_op_seae.fieldbyname('通知人城市').AsString:=t_code_notifyparty.FieldByName('城市').AsString; t_op_seae.fieldbyname('通知人邮编').AsString:=t_code_notifyparty.FieldByName('邮编').AsString; t_op_seae.fieldbyname('通知人国家代码').AsString:=t_code_notifyparty.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('通知人联系人').AsString:=t_code_notifyparty.FieldByName('联系人').AsString; t_op_seae.fieldbyname('通知人电话').AsString:=t_code_notifyparty.FieldByName('电话').AsString; t_op_seae.fieldbyname('通知人州').AsString:=t_code_notifyparty.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi.PutToDebugLog(Operation, S1: String); Var S: String; begin while Length(S1) > 0 do begin if Pos(#13, S1) > 0 then begin S := Copy(S1, 1, Pos(#13, S1) - 1); Delete(S1, 1, Pos(#13, S1)); if S1[1] = #10 then Delete(S1, 1, 1); end else S := S1; DebugListBox.ItemIndex := DebugListBox.Items.Add(Operation + S); end; end; procedure Tfrm_op_seae_edi.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); begin DebugListBox.ItemIndex := DebugListBox.Items.Add(AStatusText); end; procedure Tfrm_op_seae_edi.IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); begin StatusBar1.Panels[1].Text := '传输完毕.'; BytesToTransfer := 0; TransferrignData := false; ProgressBar1.Position := 0; AverageSpeed := 0; end; procedure Tfrm_op_seae_edi.bsSkinButton22Click(Sender: TObject); var Pnt:Tpoint; begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.State=dsinsert)or(t_op_seae1.DataSet.State=dsedit) then t_op_seae1.DataSet.post; Pnt:=bsSkinButton22.ClientToScreen(Point(0,bsSkinButton22.Height)); PopupMenu4.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi.N3Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_cosco) then frm_op_seae_edi_custom_cosco:=tfrm_op_seae_edi_custom_cosco.Create(application); frm_op_seae_edi_custom_cosco.ShowModal; finally frm_op_seae_edi_custom_cosco.free; frm_op_seae_edi_custom_cosco:=nil; end; end; procedure Tfrm_op_seae_edi.bsSkinButton23Click(Sender: TObject); begin t_op_seae.fieldbyname('通知人名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString;; t_op_seae.fieldbyname('通知人地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; t_op_seae.fieldbyname('通知人地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; t_op_seae.fieldbyname('通知人地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; t_op_seae.fieldbyname('通知人城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; t_op_seae.fieldbyname('通知人邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; t_op_seae.fieldbyname('通知人国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; t_op_seae.fieldbyname('通知人联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; t_op_seae.fieldbyname('通知人电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; t_op_seae.fieldbyname('通知人州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; end; procedure Tfrm_op_seae_edi.N5Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_custom_edi_zt) then frm_op_seae_custom_edi_zt:=tfrm_op_seae_custom_edi_zt.Create(application); frm_op_seae_custom_edi_zt.ShowModal; finally frm_op_seae_custom_edi_zt.free; frm_op_seae_custom_edi_zt:=nil; end; end; procedure Tfrm_op_seae_edi.N6Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_waidai) then frm_op_seae_edi_custom_waidai:=tfrm_op_seae_edi_custom_waidai.Create(application); frm_op_seae_edi_custom_waidai.ShowModal; finally frm_op_seae_edi_custom_waidai.free; frm_op_seae_edi_custom_waidai:=nil; end; end; procedure Tfrm_op_seae_edi.t_op_ctnBeforePost(DataSet: TDataSet); begin if length(t_op_ctn.FieldByName('唛头').AsString)>180 then begin MessageDlg('唛头长度不能超过180个字符',mtWarning,[mbOk],0); Abort; end; if length(t_op_ctn.FieldByName('货描').AsString)>180 then begin MessageDlg('货描长度不能超过180个字符',mtWarning,[mbOk],0); Abort; end; end; procedure Tfrm_op_seae_edi.CN11011Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_waidai_1101) then frm_op_seae_edi_custom_waidai_1101:=tfrm_op_seae_edi_custom_waidai_1101.Create(application); frm_op_seae_edi_custom_waidai_1101.ShowModal; finally frm_op_seae_edi_custom_waidai_1101.free; frm_op_seae_edi_custom_waidai_1101:=nil; end; end; procedure Tfrm_op_seae_edi.IdFTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); begin TransferrignData := true; AbortTransfer := false; STime := Now; if AWorkCountMax > 0 then ProgressBar1.Max := AWorkCountMax else ProgressBar1.Max := BytesToTransfer; AverageSpeed := 0; end; procedure Tfrm_op_seae_edi.IdFTP1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); Var S: String; TotalTime: TDateTime; H, M, Sec, MS: Word; DLTime: Double; begin TotalTime := Now - STime; DecodeTime(TotalTime, H, M, Sec, MS); Sec := Sec + M * 60 + H * 3600; DLTime := Sec + MS / 1000; if DLTime > 0 then AverageSpeed := {(AverageSpeed + }(AWorkCount / 1024) / DLTime{) / 2}; if AverageSpeed > 0 then begin Sec := Trunc(((ProgressBar1.Max - AWorkCount) / 1024) / AverageSpeed); S := Format('%2d:%2d:%2d', [Sec div 3600, (Sec div 60) mod 60, Sec mod 60]); S := '剩余时间 ' + S; end else S := ''; S := FormatFloat('0.00 KB/s', AverageSpeed) + '; ' + S; case AWorkMode of wmRead: StatusBar1.Panels[1].Text := '下载速度 ' + S; wmWrite: StatusBar1.Panels[1].Text := '上传速度 ' + S; end; if AbortTransfer then IdFTP1.Abort; ProgressBar1.Position := AWorkCount; AbortTransfer := false; end; end.