unit u_op_seae_edi_data; 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, DBCtrlsEh,ComObj, bsSkinBoxCtrls, IdExplicitTLSClientServerBase,ShellAPI, Excel; type Tfrm_op_seae_edi_data = 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; Label42: TLabel; wwDBComboBox8: TwwDBComboBox; Label44: TLabel; DBEdit42: TDBEdit; DBEdit43: TDBEdit; Label46: TLabel; Label50: TLabel; DBEdit44: TDBEdit; Label54: TLabel; DBEdit46: TDBEdit; Label55: TLabel; DBEdit48: TDBEdit; Label56: TLabel; DBEdit50: TDBEdit; Label59: TLabel; bsSkinGroupBox6: TbsSkinGroupBox; 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; 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; t_op_ctn_detailctn_id: TIntegerField; 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; DebugListBox: TListBox; StatusBar1: TStatusBar; ProgressBar1: TProgressBar; Label76: TLabel; bsSkinButton22: TbsSkinButton; PopupMenu4: TPopupMenu; N2: TMenuItem; NZY: TMenuItem; wwDBDateTimePicker3: TwwDBDateTimePicker; Label77: TLabel; Label78: TLabel; bsSkinButton23: TbsSkinButton; N4: TMenuItem; NZT: TMenuItem; NWD2101: TMenuItem; wwDBComboBoxFILETYPE: TwwDBComboBox; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; N7: TMenuItem; NWD1101: TMenuItem; Label80: TLabel; Edit1: TEdit; Label217: TLabel; wwDBLookupCombo26: TwwDBLookupCombo; Label218: TLabel; Edit8: TEdit; Label81: TLabel; Edit2: TEdit; N8: TMenuItem; N9: TMenuItem; N19: TMenuItem; NWY: TMenuItem; N21: TMenuItem; NLD: TMenuItem; NHG: TMenuItem; NYD: TMenuItem; Label41: TLabel; DBEdit59: TDBEdit; wwDBLookupCombo21: TwwDBLookupCombo; RxDBLookupCombo15: TRxDBLookupCombo; wwDBLookupCombo20: TwwDBLookupCombo; btnSeal: TbsSkinButton; bsSkinExPanel1: TbsSkinExPanel; bsSkinPanel6: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton13: TbsSkinButton; wwDBGrid2: TwwDBGrid; N3: TMenuItem; NHF: TMenuItem; Label58: TLabel; wwDBComboBoxOP: TwwDBComboBox; N5: TMenuItem; NHGYDT: TMenuItem; wwDBLookupCombo3: TwwDBLookupCombo; bsSkinButton15: TbsSkinButton; bsSkinButton24: TbsSkinButton; OpenDialog1: TOpenDialog; wwDBLookupCombo52: TwwDBLookupCombo; wwDBLookupCombo17: TwwDBLookupCombo; bsSkinButton65: TbsSkinButton; bsSkinButton25: TbsSkinButton; Label57: TLabel; bsSkinButton26: TbsSkinButton; DBMemo4: TDBMemo; N6: TMenuItem; N20: TMenuItem; N22: TMenuItem; N23: TMenuItem; N24: TMenuItem; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid4: TdxDBGrid; dxDBGrid4Column2: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGrid4Column3: TdxDBGridColumn; bsSkinGroupBox13: TbsSkinGroupBox; bsSkinPanel14: TbsSkinPanel; bsSkinButton48: TbsSkinButton; bsSkinButton49: TbsSkinButton; bsSkinButton50: TbsSkinButton; bsSkinButton51: TbsSkinButton; bsSkinButton66: TbsSkinButton; dxDBGrid3: TdxDBGrid; dxDBGrid2fid: TdxDBGridMaskColumn; dxDBGrid2rl_id: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; t_op_file_data: TADOQuery; dsrFuJian: TDataSource; t_op_file_items_data1: TDataSource; t_op_file_items_data: TADOQuery; bsSkinButton27: TbsSkinButton; t_crm_emloyee_link1: TDataSource; t_crm_emloyee_link: TADOQuery; RxDBLookupCombo3: TRxDBLookupCombo; dxDBGrid1Column23: TdxDBGridColumn; bsSkinButton28: TbsSkinButton; dxDBGrid2: TdxDBGrid; t_op_seae_sum: TADOQuery; t_op_seae_sum1: TDataSource; dxDBGrid2Column1: TdxDBGridColumn; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; Label79: TLabel; N26: TMenuItem; N27: TMenuItem; dxDBGrid1Column25: TdxDBGridColumn; Label82: TLabel; DBEdit41: TDBEdit; Label83: TLabel; DBEdit45: TDBEdit; Label84: TLabel; DBEdit47: TDBEdit; DBEdit49: TDBEdit; Label85: TLabel; Label86: TLabel; DBEdit51: TDBEdit; Label87: TLabel; DBEdit52: TDBEdit; bsSkinButton29: TbsSkinButton; bsSkinButton30: TbsSkinButton; wwDBComboBox20: TwwDBComboBox; EXCEL1: TMenuItem; N28: TMenuItem; dxDBGrid1Column26: TdxDBGridColumn; N29: TMenuItem; EXCEL2: TMenuItem; Excel3: TExcel; SaveDialog: TSaveDialog; Label88: TLabel; DBEdit2: TDBEdit; DBEdit53: TDBEdit; Label89: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; Label90: TLabel; dxDBGrid1Column27: TdxDBGridColumn; N30: TMenuItem; N31: TMenuItem; N32: TMenuItem; N33: TMenuItem; 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 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 IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); procedure IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); procedure bsSkinButton22Click(Sender: TObject); procedure NZYClick(Sender: TObject); procedure bsSkinButton23Click(Sender: TObject); procedure NZTClick(Sender: TObject); procedure NWD2101Click(Sender: TObject); procedure NWD1101Click(Sender: TObject); procedure NYDClick(Sender: TObject); procedure NLDClick(Sender: TObject); procedure NWYClick(Sender: TObject); procedure NHGClick(Sender: TObject); procedure btnSealClick(Sender: TObject); procedure NHFClick(Sender: TObject); procedure wwDBComboBoxOPDropDown(Sender: TObject); procedure NHGYDTClick(Sender: TObject); procedure wwDBLookupCombo3Exit(Sender: TObject); procedure wwDBLookupCombo3Change(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton24Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure wwDBLookupCombo52Exit(Sender: TObject); procedure wwDBLookupCombo17Exit(Sender: TObject); procedure wwDBLookupCombo52Change(Sender: TObject); procedure wwDBLookupCombo17Change(Sender: TObject); procedure bsSkinButton65Click(Sender: TObject); procedure bsSkinButton25Click(Sender: TObject); procedure bsSkinButton26Click(Sender: TObject); procedure t_op_seaeBeforeEdit(DataSet: TDataSet); procedure t_op_ctnBeforeEdit(DataSet: TDataSet); procedure N20Click(Sender: TObject); procedure N23Click(Sender: TObject); procedure N26Click(Sender: TObject); procedure dxDBGrid4Click(Sender: TObject); procedure t_op_file_items_dataAfterDelete(DataSet: TDataSet); procedure t_op_file_items_dataAfterInsert(DataSet: TDataSet); procedure t_op_file_items_dataAfterPost(DataSet: TDataSet); procedure bsSkinButton66Click(Sender: TObject); procedure bsSkinButton49Click(Sender: TObject); procedure bsSkinButton50Click(Sender: TObject); procedure bsSkinButton51Click(Sender: TObject); procedure bsSkinButton27Click(Sender: TObject); procedure dxDBGrid1CustomDraw(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 t_op_file_dataAfterPost(DataSet: TDataSet); procedure bsSkinPageControl1Change(Sender: TObject); procedure DBEdit1Change(Sender: TObject); procedure bsSkinButton28Click(Sender: TObject); procedure N27Click(Sender: TObject); procedure bsSkinButton29Click(Sender: TObject); procedure bsSkinButton30Click(Sender: TObject); procedure EXCEL1Click(Sender: TObject); procedure t_op_seaeBeforePost(DataSet: TDataSet); procedure dxDBGrid1Column26GetText(Sender: TObject; ANode: TdxTreeListNode; var AText: String); procedure EXCEL2Click(Sender: TObject); procedure RxDBLookupCombo4Enter(Sender: TObject); procedure RxDBLookupCombo4Exit(Sender: TObject); procedure N31Click(Sender: TObject); procedure N33Click(Sender: TObject); procedure Edit3KeyPress(Sender: TObject; var Key: Char); 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 } naspath:widestring; isexcel:BOOL; procedure UpdateCTN(BSNO:STRING); procedure UpLoadPro(fname: string); procedure UpLoadProFile(fname,RemotePathName,Users,pw,mblNo: string); //fname包含完整路径、文件名 procedure DownLoadPro(fname: string); procedure DownLoadProFils(RemotePathName,Users,pw,fname: string); //从数据库的表中下载 end; var frm_op_seae_edi_data: Tfrm_op_seae_edi_data; AverageSpeed: Double = 0; frm_op_seae_data_create:boolean; opsqlstr,opsumsqlstr:string; implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, 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, u_op_seae_edi_custom_yd, u_op_seae_edi_custom_LD, u_op_seae_edi_custom_wy, u_op_seae_edi_custom_hg, u_code_edicode, u_op_seae_edi_custom_hgydt, u_op_seae, u_op_customername_change, u_op_vesselvoy_cdchange; {$R *.dfm} procedure Tfrm_op_seae_edi_data.setconcolor; begin end; procedure Tfrm_op_seae_edi_data.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_edi_data.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_seae_edi_data.Hide; frm_op_seae_edi_data.ManualFloat(frm_op_seae_edi_data.BoundsRect ); frm_main.freeTabs('frm_op_seae_edi_data'); frm_op_seae_data_create:=false; action:=cafree; frm_op_seae_edi_data:=nil; end; procedure Tfrm_op_seae_edi_data.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/14); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton11.Width:=i; bsSkinButton14.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; bsSkinButton22.Width:=i; bsSkinButton28.Width:=i; end; procedure Tfrm_op_seae_edi_data.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton2Click(Sender: TObject); begin t_op_seae.fieldbyname('预抵日期').AsDateTime:=t_op_seae.fieldbyname('开船日期').AsDateTime+7; table_post(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin isexcel:=False; 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_data.bsSkinButton4Click(Sender: TObject); var i,j:Integer; strno:string; aQuery:TADOQuery; begin if employee='查看' then begin ShowMessage('查看用户只能查看不能修改和新增'); exit; end; 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+''''; InsertSysLog('舱单删除',t_op_seae.fieldbyname('主提单号').asstring+'--'+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_data.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae); end; procedure Tfrm_op_seae_edi_data.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_data.FormShow(Sender: TObject); begin Notebook1.PageIndex:=0; isexcel:=false; 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; //委托编号处理 naspath:=get_parameters_value(175,'\\223.223.95.160\data'); t_op_seae.Close; t_op_seae.SQL.clear; t_op_seae.SQL.Add('select top 100 * from t_op_seae_edi where ' +'(录入人='+''''+employee+''''+') order by 录入日期 desc '); t_op_seae.open; opsqlstr:=t_op_seae.sql.Text; t_op_ctn.Open; t_op_ctn_detail.Open; t_op_file_data.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_op_seae_data_create:=true; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; with t_crm_emloyee_link do begin Close;SQL.Clear; SQL.Add('select * from t_crm_emloyee_link'); SQL.Add('where 姓名=:姓名'); Parameters.ParamByName('姓名').Value:=employee; Open; // ShowMessage(IntToStr(RecordCount)); end; frm_sys_progress.close; frm_sys_progress:=nil; if if_reg(20301) then //外代 begin NWD2101.Visible:=True; //NWD1101.Visible:=True; end else begin NWD2101.Visible:=False; //NWD1101.Visible:=False; end; if if_reg(20302) then //外运 begin NWY.Visible:=True; end else begin NWY.Visible:=False; end; if if_reg(20303) then //联代 begin NLD.Visible:=True; end else begin NLD.Visible:=False; end; if if_reg(20304) then //华港 begin // NHG.Visible:=True; end else begin // NHG.Visible:=False; end; if if_reg(20305) then //远大 begin NYD.Visible:=True; end else begin NYD.Visible:=False; end; if if_reg(20306) then //中远 begin // NZY.Visible:=True; end else begin // NZY.Visible:=False; end; if if_reg(20307) then //中通 begin // NZT.Visible:=True; end else begin // NZT.Visible:=False; end; if if_reg(20309) then //海丰 begin NHF.Visible:=True; end else begin NHF.Visible:=False; end; end; procedure Tfrm_op_seae_edi_data.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.N12Click(Sender: TObject); begin // update_grid(dxdbgrid1,101); end; procedure Tfrm_op_seae_edi_data.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.bsSkinButton8Click(Sender: TObject); VAR str:widestring; ini:TIniFile; s1,s2:string; 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+''''; if wwDBComboBoxOP.text<>''then str:=str+' and 录入人='+''''+wwDBComboBoxOP.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; //if opsqlstr<>t_op_seae.sql.Text then opsqlstr:=t_op_seae.sql.Text; t_op_seae_sum.Close; t_op_seae_sum.sql.clear; t_op_seae_sum.sql.add('select 订舱号码,count(*) 票数 from t_op_seae_edi '+str+' group by 订舱号码 order by 订舱号码'); t_op_seae_sum.open; opsumsqlstr:= t_op_seae_sum.sql.Text; ini:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); s1:=Ini.ReadString('EDI_DATA','t_op_seae',''); s2:=Ini.ReadString('EDI_DATA','t_op_seae_sum',''); if opsqlstr<>s1 then begin Ini.WriteString('EDI_DATA','t_op_seae',t_op_seae.SQL.CommaText); opsqlstr:=s1; end; if opsumsqlstr<>s2 then begin Ini.WriteString('EDI_DATA','t_op_seae_sum',t_op_seae_sum.SQL.CommaText); opsumsqlstr:=s2; end; Ini.Free; end; procedure Tfrm_op_seae_edi_data.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_data.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_data.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_data.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_data.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_data.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; 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位'; 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:='集装箱信息' 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; 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:=''; DBEdit46.Hint:=''; DBEdit48.Hint:=''; DBEdit50.Hint:=''; // Label61.Color:=clRed; // Label62.Color:=clRed; // bsSkinDBCheckRadioBox1.Font.:=clRed; bsSkinGroupBox6.Caption:='集装箱详细信息' end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton56Click(Sender: TObject); begin t_op_ctn.insert; end; procedure Tfrm_op_seae_edi_data.bsSkinButton57Click(Sender: TObject); begin table_post(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.bsSkinButton58Click(Sender: TObject); begin table_delete(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.bsSkinButton59Click(Sender: TObject); begin table_cancel(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.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_data.btnMarksClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'唛头'); end; procedure Tfrm_op_seae_edi_data.btnDescClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'货描'); end; procedure Tfrm_op_seae_edi_data.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_data.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_data.bsSkinButton48Click(Sender: TObject); var FileStream:TFileStream; fsize:double; begin { if t_op_file.RecordCount <=0 then begin ShowMessage('请点<提取类型>按钮'); Exit; end; } if t_op_file_data.RecordCount<=0 then begin { t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='舱单'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; } t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='海关数据'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.First; end; with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; //上传附件 if OpenDialog1.Execute then begin if Length(Opendialog1.FileName)<=95 then begin FileStream:=TFileStream.Create(Opendialog1.FileName,fmopenRead); //打开文件 try fsize:=FileStream.size; finally freeandnil(FileStream); end; if fsize>5000000 then begin MessageDlg('文件不能超过5M!!',mtWarning,[mbyes],0); end else UpLoadProFile(Opendialog1.FileName,naspath,'user','user',frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').AsString); end else begin MessageDlg('文件名太长,不能超过95个字符!!',mtWarning,[mbyes],0); exit ; end; end else exit ; end; {procedure Tfrm_op_seae_edi_data.bsSkinButton48Click(Sender: TObject); var FileStream:TFileStream; fsize:double; begin if t_op_file_data.RecordCount<=0 then begin t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='舱单'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='海关数据'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.First; end; with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; //上传附件 if OpenDialog1.Execute then begin if Length(Opendialog1.FileName)<=95 then begin FileStream:=TFileStream.Create(Opendialog1.FileName,fmopenRead); //打开文件 try fsize:=FileStream.size; finally freeandnil(FileStream); end; if fsize>500000 then begin MessageDlg('文件不能超过500K!!',mtWarning,[mbyes],0); end else UpLoadPro(Opendialog1.FileName); end else begin MessageDlg('文件名太长,不能超过95个字符!!',mtWarning,[mbyes],0); exit ; end; end else exit ; end; } procedure Tfrm_op_seae_edi_data.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(''); 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('PortOfOrigin'); 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'); if bltype='AMR' then begin Str.Add(''+formatdatetime('YYYYMMDD',t_op_seae.fieldbyname('开船日期').Asdatetime)+''); 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_data.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_data.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_data.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_data.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_data.bsSkinButton1Click(Sender: TObject); begin t_op_ctn_detail.insert; end; procedure Tfrm_op_seae_edi_data.bsSkinButton9Click(Sender: TObject); begin table_post(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.bsSkinButton10Click(Sender: TObject); begin table_delete(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.bsSkinButton13Click(Sender: TObject); begin table_cancel(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.t_op_ctn_detailAfterInsert(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi_data.t_op_ctn_detailBeforePost(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi_data.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_data.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_data.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_data.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_data.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_data.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_data.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_data.RxDBLookupCombo16Enter(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo16Exit(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo1Enter(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo1Exit(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo2Enter(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo2Exit(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.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_data.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_data.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_data.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_data.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); begin DebugListBox.ItemIndex := DebugListBox.Items.Add(AStatusText); end; procedure Tfrm_op_seae_edi_data.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); 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; procedure Tfrm_op_seae_edi_data.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); 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_data.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_data.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; if trim(t_op_seae.fieldbyname('订舱号码').AsString)='' then begin showmessage('申报人为空,不能发送!'); exit; end; Pnt:=bsSkinButton22.ClientToScreen(Point(0,bsSkinButton22.Height)); PopupMenu4.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi_data.NZYClick(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_data.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_data.NZTClick(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_data.NWD2101Click(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_data.NWD1101Click(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_data.NYDClick(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('远大舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; { if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_yd) then frm_op_seae_edi_custom_yd:=tfrm_op_seae_edi_custom_yd.Create(application); frm_op_seae_edi_custom_yd.ShowModal; finally frm_op_seae_edi_custom_yd.free; frm_op_seae_edi_custom_yd:=nil; end; } procedure Tfrm_op_seae_edi_data.NLDClick(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('联代舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; { if t_op_seae.isempty then begin showmessage('对不起,没有托单信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_ld) then frm_op_seae_edi_custom_ld:=tfrm_op_seae_edi_custom_ld.Create(application); frm_op_seae_edi_custom_ld.ShowModal; finally frm_op_seae_edi_custom_ld.free; frm_op_seae_edi_custom_ld:=nil; end; } end; procedure Tfrm_op_seae_edi_data.NWYClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_wy) then frm_op_seae_edi_custom_wy:=tfrm_op_seae_edi_custom_wy.Create(application); frm_op_seae_edi_custom_wy.ShowModal; finally frm_op_seae_edi_custom_wy.free; frm_op_seae_edi_custom_wy:=nil; end; end; procedure Tfrm_op_seae_edi_data.NHGClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_hg) then frm_op_seae_edi_custom_hg:=tfrm_op_seae_edi_custom_hg.Create(application); frm_op_seae_edi_custom_hg.ShowModal; finally frm_op_seae_edi_custom_hg.free; frm_op_seae_edi_custom_hg:=nil; end; end; procedure Tfrm_op_seae_edi_data.btnSealClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'封号'); end; procedure Tfrm_op_seae_edi_data.NHFClick(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('海丰舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.wwDBComboBoxOPDropDown(Sender: TObject); var AdoQuery1:TAdoQuery; begin wwDBComboBoxOP.items.clear; AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try Close;sql.Clear; SQL.Add('select * from t_sys_employee where 状态=''在职'''); SQL.Add('Order by 姓名'); Open;first; while not Eof do begin wwDBComboBoxOP.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); Next; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.NHGYDTClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_hgYDT) then frm_op_seae_edi_custom_hgYDT:=tfrm_op_seae_edi_custom_hgYDT.Create(application); frm_op_seae_edi_custom_hgYDT.ShowModal; finally frm_op_seae_edi_custom_hgYDT.free; frm_op_seae_edi_custom_hgYDT:=nil; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton15Click(Sender: TObject); var aAdoQuery:TAdoQuery; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select sum(件数) 件数, sum(重量) 重量,sum(尺码) 尺码 from t_op_ctn_edi'); sql.add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.fieldbyname('编号').asstring; open;First; if not IsEmpty then begin if t_op_seae=nil then exit; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; t_op_seae.Edit; t_op_seae.FieldByName('件数').AsInteger:=FieldByName('件数').AsInteger; t_op_seae.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_seae.FieldByName('尺码').AsFloat:=FieldByName('尺码').AsFloat; t_op_seae.Post; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.UpdateCTN(BSNO:STRING); var aAdoQuery:TAdoQuery; p:Integer; w,c:Double; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select sum(件数) 件数, sum(重量) 重量,sum(尺码) 尺码 from t_op_ctn_edi'); sql.add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=BSNO; open;First; if not IsEmpty then begin t_op_seae.Edit; p:=FieldByName('件数').AsInteger; w:=FieldByName('重量').AsFloat; c:=FieldByName('尺码').AsFloat; t_op_seae.Post; close; sql.clear; sql.add('Update t_op_seae_edi set 件数=:件数, 重量=:重量,尺码=:尺码'); sql.add('where 编号=:编号'); Parameters.ParamByName('件数').Value:=p; Parameters.ParamByName('重量').Value:=w; Parameters.ParamByName('尺码').Value:=c; Parameters.ParamByName('编号').Value:=BSNO; ExecSQL; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton24Click(Sender: TObject); begin with t_op_ctn do begin First; while not eof do begin Edit; FieldByName('尺码').AsFloat:=s_w(0,FieldByName('尺码').AsFloat); post; Next; end; end; end; procedure Tfrm_op_seae_edi_data.N1Click(Sender: TObject); var Ext,adate,bsno,corp,vslvoy,mblno,id,cntNo,ctnName,s:String; ExcelTemplet:Variant; i,j,k:integer; M,D,Y:Word; imp,seae_apply_add_total:boolean; aAdoQuery,t_op_ctn_edi:TAdoQuery; alist:TStringList; function getcustedi(cust:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select EDI代码 from t_crm_client where 客户简称='''+cust+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('EDI代码').AsString; finally FreeAndNil(aQuery); end; end; function GetvesselEdi(avessel: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 船舶呼号 from t_code_vessel where 英文船名='''+avessel+''''); Open; if IsEmpty then Result:='a' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; function getETD(VSL,VOY:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select * from v_vessel_voyage where 英文船名='''+VSL+''' and 航次='''+VOY+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('开船日期').AsString; finally FreeAndNil(aQuery); end; end; begin // id:=get_id; j:=1; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin close;SQL.Clear; SQL.Add('select * from t_op_seae_edi'); SQL.Add('where 主提单号=:主提单号'); Parameters.ParamByName('主提单号').Value:=''; end; alist:=TStringList.Create; t_op_ctn_edi:=CreateAdoQuery; t_op_ctn_edi.close; t_op_ctn_edi.sql.Text:='select * from t_op_ctn_edi where 编号=:编号'; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); isexcel:=true; try frm_main.db.BeginTrans; t_op_seae.DisableControls; t_op_ctn.DisableControls; I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value)<>'' do begin mblno:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('主提单号').Value:=mblno; aAdoQuery.Open; if aAdoQuery.IsEmpty then begin j:=j+1; id:=get_id; t_op_seae.Insert; t_op_seae['编号']:=id; t_op_seae['业务编号']:=mblno; t_op_seae['主编号']:=''; t_op_seae['EDI类型']:='CN'; t_op_seae['EDI状态']:='未发送'; t_op_seae['录入人']:=employee; t_op_seae['录入日期']:=now; t_op_seae['主提单号']:=Trim(mblno); t_op_seae['付费方式']:='FREIGHT COLLECT'; t_op_seae['签单地点']:='QINGDAO,CHINA'; t_op_seae['发货人代码']:=''; t_op_seae['舱单来源']:='EXCEL引入'; // t_op_seae['船公司']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value); t_op_seae['船公司代码']:=getcustedi(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,13].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['发货人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,14].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['发货人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['发货人地址2']:=''; t_op_seae['发货人地址3']:=''; t_op_seae['发货人']:=''; t_op_seae['发货人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,15].Value); t_op_seae['发货人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,16].Value); t_op_seae['发货人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,17].Value); t_op_seae['发货人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,18].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,19].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['收货人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,20].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['收货人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['收货人地址2']:=''; t_op_seae['收货人地址3']:=''; t_op_seae['收货人代码']:=''; t_op_seae['收货人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,21].Value); t_op_seae['收货人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,22].Value); t_op_seae['收货人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); t_op_seae['收货人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,24].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,25].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['通知人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,26].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['通知人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['通知人地址2']:=''; t_op_seae['通知人地址3']:=''; t_op_seae['通知人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,27].Value); t_op_seae['通知人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); t_op_seae['通知人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value); t_op_seae['通知人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); t_op_seae['船名']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)); t_op_seae['航次']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)); t_op_seae['船舶IMO']:=GetvesselEdi(t_op_seae['船名']); if getETD(t_op_seae['船名'],t_op_seae['航次'])<>'' then t_op_seae['开船日期']:=getETD(t_op_seae['船名'],t_op_seae['航次']); t_op_seae.fieldbyname('预抵日期').AsDateTime:=t_op_seae.fieldbyname('开船日期').AsDateTime+7; t_op_seae['装货港']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value)); if frm_data_share.t_code_loaport.Locate('英文名',t_op_seae['装货港'],[]) then begin t_op_seae['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end else t_op_seae['装港代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); t_op_seae['卸货港']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,9].Value)); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['卸货代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,10].Value); t_op_seae['目的地']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,11].Value)); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['目的代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,12].Value); // t_op_seae['运输条款']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); t_op_seae['运输条款']:='CY-CY'; t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,40].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,39].Value; t_op_seae['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,38].Value; t_op_seae['货物描述']:=alist.Text; t_op_seae['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); t_op_seae['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,34].Value); t_op_seae['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,36].Value); t_op_seae['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); t_op_seae['危险品分类']:=''; t_op_seae['危险品编号']:=''; t_op_seae['冷藏通风量']:=''; t_op_seae['温度单位']:=''; t_op_seae['设置温度']:=''; t_op_seae['最低温度']:=''; t_op_seae['最高温度']:=''; t_op_seae['货物标识']:=''; t_op_seae['运费协议号']:=''; t_op_seae['湿度']:=''; t_op_seae['订舱号码']:=''; t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,40].Value); if pos('冻',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,41].Value))>0 then begin t_op_seae['货物标识']:='R'; t_op_seae['温度单位']:='C'; t_op_seae['设置温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,42].Value); t_op_seae['最低温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,42].Value); t_op_seae['最高温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,42].Value); end else if pos('危',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,41].Value))>0 then begin t_op_seae['货物标识']:='D'; t_op_seae['危险品分类']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,43].Value); t_op_seae['危险品编号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,44].Value); end else t_op_seae['货物标识']:='S'; t_op_seae['文件类型']:='Master'; t_op_seae.Post; t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=id; t_op_ctn_edi.Open; t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=id; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,31].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,31].Value),3,2); // showmessage(mblno+' '+cntNo+'--'+ctnName); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,32].Value)); t_op_ctn_edi['封号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,33].Value)); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,34].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,36].Value); t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,39].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,38].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; end else begin t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=aAdoQuery.fieldbyname('编号').asstring; t_op_ctn_edi.Open; if not t_op_ctn_edi.Locate('箱号;封号',VarArrayOf([Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,32].Value)),Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,33].Value))]),[]) then begin t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=aAdoQuery.fieldbyname('编号').asstring; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,31].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,31].Value),3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,32].Value)); t_op_ctn_edi['封号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,33].Value)); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,34].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,36].Value); t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,39].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,38].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; t_op_seae.Edit; t_op_seae['货物描述']:=t_op_seae.fieldbyname('货物描述').AsString+t_op_ctn_edi['货描']; t_op_seae.Post; end; UpdateCTN(aAdoQuery.fieldbyname('编号').asstring); end; i:=i+1; end; frm_main.db.CommitTrans; finally isexcel:=false; t_op_seae.EnableControls; t_op_ctn.EnableControls; ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 MessageDlg('导入:'+IntTostr(i-2)+'行 '+'票数:'+IntTostr(j-1)+'票 ', mtConfirmation, [mbYes],0); if frm_main.db.InTransaction then begin ShowMessage('导入时出错,请刷新重试!'); frm_main.db.RollbackTrans; end; end; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo3Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_loaport.Locate('英文名',wwDBLookupCombo3.text,[]) then begin t_op_seae1.DataSet['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo3Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_loaport.Locate('英文名',wwDBLookupCombo3.text,[]) then begin t_op_seae1.DataSet['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo52Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo52.text,[]) then begin t_op_seae1.DataSet['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo17Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo17.text,[]) then begin t_op_seae1.DataSet['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo52Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo52.text,[]) then begin t_op_seae1.DataSet['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo17Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo17.text,[]) then begin t_op_seae1.DataSet['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton65Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'唛头'); end; procedure Tfrm_op_seae_edi_data.bsSkinButton25Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'货物描述'); end; procedure Tfrm_op_seae_edi_data.bsSkinButton26Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'备注'); end; procedure Tfrm_op_seae_edi_data.t_op_seaeBeforeEdit(DataSet: TDataSet); begin if employee='查看' then begin ShowMessage('查看用户只能查看不能修改和新增'); abort; end; if t_op_seae.fieldbyname('录入人').AsString<>employee then begin ShowMessage('您不能修改:'+t_op_seae.fieldbyname('录入人').AsString+' 录入的舱单'); abort; end; end; procedure Tfrm_op_seae_edi_data.t_op_ctnBeforeEdit(DataSet: TDataSet); begin if employee='查看' then begin ShowMessage('查看用户只能查看不能修改和新增'); abort; end; if t_op_seae.fieldbyname('录入人').AsString<>employee then begin ShowMessage('您不能修改:'+t_op_seae.fieldbyname('录入人').AsString+' 录入的舱单'); abort; end; end; procedure Tfrm_op_seae_edi_data.N20Click(Sender: TObject); var afield,afieldfee : variant; aOR_ID:integer; aQuery:TAdoQuery; i:integer; bsno,id:string; Boolean_Ctn:Boolean; begin if t_op_seae.IsEmpty then begin exit; MessageDlg('没有复制的信息,不能复制添加!',mtWarning,[mbok],0); end; afield := vararraycreate([0,t_op_seae.fieldcount-1],varvariant); for i := 0 to (t_op_seae.fieldcount-1) do begin afield[i] :=t_op_seae.fields[i].value ; end; bsno:=t_op_seae.fieldbyname('编号').AsString; t_op_seae.append; for i := 0 to (t_op_seae.fieldcount-1) do begin if t_op_seae.fields[i].FieldName<>'编号' then t_op_seae.fields[i].value := afield[i] ; end; id:=get_id; t_op_seae.fieldbyname('录入人').Value:=employee; t_op_seae.fieldbyname('录入日期').Value:=date; t_op_seae.fieldbyname('EDI状态').Value:='未发送'; t_op_seae.fieldbyname('编号').Value:=id; t_op_seae.fieldbyname('主编号').Value:=id; t_op_seae.fieldbyname('EDI类型').AsString:='CN'; t_op_seae['舱单来源']:='舱单部舱单'; t_op_seae.fieldbyname('上传文件').AsBoolean:=False; t_op_seae['装货港']:='CNQGD'; t_op_seae['装港代码']:='CNQGD/4218'; t_op_seae['生成费用']:=0; t_op_seae.Post; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select * from t_op_ctn_edi where 编号=:编号'); Parameters.ParamByName('编号').Value:=bsno; open; if not t_op_ctn.active then t_op_ctn.Open; first; while not eof do begin t_op_ctn.Insert; t_op_ctn['编号']:=id; t_op_ctn['代码']:=aQuery['代码']; t_op_ctn['尺寸']:=aQuery['尺寸']; t_op_ctn['箱型']:=aQuery['箱型']; t_op_ctn['数量']:=1; t_op_ctn['表现形式']:=aQuery['表现形式']; t_op_ctn['箱号']:=aQuery['箱号']; t_op_ctn['封号']:=aQuery['封号']; t_op_ctn['件数']:=aQuery['件数']; t_op_ctn['包装']:=aQuery['包装']; t_op_ctn['重量']:=aQuery['重量']; t_op_ctn['尺码']:=aQuery['尺码']; t_op_ctn['货描']:=aQuery['货描']; t_op_ctn['唛头']:=aQuery['唛头']; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45') then t_op_ctn['TEU']:=2; end; t_op_ctn.Post; next; end; end; finally freeandnil(aQuery); showmessage('复制完成'); end; end; procedure Tfrm_op_seae_edi_data.N23Click(Sender: TObject); var id:string; begin t_op_seae.append; id:=get_id; t_op_seae.fieldbyname('录入人').Value:=employee; t_op_seae.fieldbyname('录入日期').Value:=date; t_op_seae.fieldbyname('EDI状态').Value:='未发送'; t_op_seae.fieldbyname('编号').Value:=id; t_op_seae.fieldbyname('主编号').Value:=id; t_op_seae.fieldbyname('业务编号').Value:=id; t_op_seae.fieldbyname('EDI类型').AsString:='CN'; t_op_seae['舱单来源']:='舱单部舱单'; t_op_seae['运输条款']:='CY-CY'; t_op_seae['付费方式']:='FREIGHT COLLECT'; end; procedure Tfrm_op_seae_edi_data.N26Click(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('远大舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.dxDBGrid4Click(Sender: TObject); begin with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; end; procedure Tfrm_op_seae_edi_data.t_op_file_items_dataAfterDelete( DataSet: TDataSet); begin t_op_file_data.Edit; t_op_file_data.FieldByName('大小').AsInteger:=t_op_file_items_data.RecordCount; t_op_file_data.Post; end; procedure Tfrm_op_seae_edi_data.t_op_file_items_dataAfterInsert( DataSet: TDataSet); begin t_op_file_items_data.FieldByName('PID').AsInteger:=t_op_file_data.FieldByName('fID').AsInteger; t_op_file_items_data.FieldByName('编号').AsString:=t_op_file_data.FieldByName('编号').AsString; end; procedure Tfrm_op_seae_edi_data.t_op_file_items_dataAfterPost( DataSet: TDataSet); begin t_op_file_data.Edit; t_op_file_data.FieldByName('大小').AsInteger:=t_op_file_items_data.RecordCount; t_op_file_data.Post; end; procedure Tfrm_op_seae_edi_data.bsSkinButton66Click(Sender: TObject); begin if t_op_file_data.RecordCount<=0 then begin { t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='舱单'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; } t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='海关数据'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.First; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton49Click(Sender: TObject); begin if t_op_file_data.IsEmpty then exit; //下载附件 if t_op_file_items_data.fieldbyname('文件存储').AsBoolean then begin DownLoadProFils(naspath,'user','user',t_op_file_items_data.fieldbyname('名称').asstring); end else begin if SaveDialog1.Execute then begin DownLoadPro(Savedialog1.FileName+t_op_file_items_data.fieldbyname('类型').asstring); end else exit ; end; { if t_op_file_data.IsEmpty then exit; //下载附件 if SaveDialog1.Execute then begin DownLoadPro(Savedialog1.FileName+t_op_file_data.fieldbyname('类型').asstring); end else exit ; } end; procedure Tfrm_op_seae_edi_data.bsSkinButton50Click(Sender: TObject); var arr: array[0..MAX_PATH] of Char; num: DWORD; tmpfile:string ; begin if t_op_file_data.IsEmpty then exit; //打开文件 try GetTempPath(MAX_PATH, arr); tmpfile:=arr+t_op_file_items_data.fieldbyname('名称').asstring ; DownLoadPro(tmpfile) ; ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL); except showmessage('不能打开文件,请检查!'); end ; end; procedure Tfrm_op_seae_edi_data.bsSkinButton51Click(Sender: TObject); begin if t_op_file_data.IsEmpty then exit; //删除附件 if application.MessageBox('您确定要删除附件吗?','警告:',MB_OKCANCEL)=IDOK then t_op_file_items_data.delete ; end; procedure Tfrm_op_seae_edi_data.DownLoadPro(fname: string); const MaxBufSize=$F000; var myfilename:string;//保存文件的路径和文件名 myfileStream,exeBlobStream:TStream; Count,BufSize,N: Integer; Buffer:PChar; begin //下载文件 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.Update; myfilename:=FName ; with t_op_file_items_data do begin myfilename:=myfilename ; //+fieldbyname('类型').asstring ; myfileStream :=TFileStream.Create(myfilename,fmCreate);//创建文件 try //SaveToStream(Stream); ExeBlobStream:=CreateBlobStream(FieldByName('内容'),bmRead); //从数据库中取得记录 Count:=0; try if Count=0 then begin ExeBlobStream.Position:=0; Count:=ExeBlobStream.Size;//showmessage(inttostr(count)); end; if Count>MaxBufSize then BufSize:=MaxBufSize else BufSize:=Count; GetMem(Buffer,BufSize); frm_sys_progress.bsSkinGauge1.MaxValue:=(Count div BufSize)+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; try while Count<>0 do begin if Count>BufSize then N:=BufSize else N:=Count; ExeBlobStream.ReadBuffer(Buffer^,N);//从数据库表中取数据流 MyFileStream.WriteBuffer(Buffer^,N);//将数据流写入文件 Dec(Count,N); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; finally FreeMem(Buffer,BufSize); end; finally ExeBlobStream.Free; end; finally myfileStream.Free; // frm_sys_progress.close; //frm_sys_progress:=nil; //frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; end; end; procedure Tfrm_op_seae_edi_data.DownLoadProFils(RemotePathName,Users,pw,fname: string); var path,newpath,Filters:string; NetSource :TNetResource; begin with NetSource do begin dwType := RESOURCETYPE_ANY; lpLocalName :=''; // 将远程资源映射到此驱动器 lpRemoteName:=pChar(RemotePathName); // 远程网络资源 lpProvider :=''; end; WnetAddConnection2(NetSource, pChar(Users),pChar(pw),CONNECT_UPDATE_PROFILE); with SaveDialog1 do begin FileName:=ExtractFileName(fname); Filters:=ExtractFileExt(fname); Filter:='*'+ExtractFileExt(fname); if Execute then begin path:=fname; newpath:=SaveDialog1.FileName+Filters; if CopyFile(pChar(path),pChar(newpath),false) then //showmessage('下载成功') else showmessage('下载失败'); end; end; try finally WNetCancelConnection2(pChar(RemotePathName),CONNECT_UPDATE_PROFILE,True); end; end; procedure Tfrm_op_seae_edi_data.UpLoadProFile(fname,RemotePathName,Users,pw,mblNo: string); var path,newpath:string; NetSource :TNetResource; filename,fileExt,filePath:string; begin //上传文件 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.Update; filename:=ExtractFileName(fname) ; fileExt:=ExtractFileExt(filename) ; with NetSource do begin dwType := RESOURCETYPE_ANY; lpLocalName :=''; // 将远程资源映射到此驱动器 lpRemoteName:=pChar(RemotePathName); // 远程网络资源 lpProvider :=''; end; WnetAddConnection2(NetSource, pChar(Users),pChar(pw),CONNECT_UPDATE_PROFILE); filePath:=FormatDateTime('YYYYMM',DatabaseDateTime); if not DirectoryExists(RemotePathName+'\'+filePath) then MkDir(RemotePathName+'\'+filePath); if not DirectoryExists(RemotePathName+'\'+filePath+'\'+mblNo) then MkDir(RemotePathName+'\'+filePath+'\'+mblNo); newpath:=RemotePathName+'\'+filePath+'\'+mblNo+'\'+filename; if CopyFile(pChar(fname),pChar(newpath),false) then // showmessage('备份成功') else showmessage('备份失败'); { if not DirectoryExists(RemotePathName+'\'+mblNo) then MkDir(RemotePathName+'\'+mblNo); newpath:=RemotePathName+'\'+mblNo+'\'+filename; if CopyFile(pChar(fname),pChar(newpath),false) then // showmessage('备份成功') else showmessage('备份失败'); } try finally WNetCancelConnection2(pChar(RemotePathName),CONNECT_UPDATE_PROFILE,True); end; with t_op_file_items_data do begin Open; append; try FieldByName('名称').AsString:=newpath; FieldByName('上传日期').AsDateTime:=now(); FieldByName('所有者').Asstring:=employee; FieldByName('类型').Asstring:=fileExt; FieldByName('文件存储').AsBoolean:=true; Post; Application.MessageBox('程序上传至服务器成功!','提示',MB_OK+MB_IconInformation); finally frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; end; end; procedure Tfrm_op_seae_edi_data.UpLoadPro(fname: string); const BufSize=$F000; var Counter, N: Integer; Buffer: PAnsiChar; FieldStrm: TStream; ExeFileStream:TFileStream; //ExeFileStream:TMemoryStream; size_tmp: Double; filename,fileExt:string ; begin //上传文件 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.Update; filename:=ExtractFileName(fname) ; fileExt:=ExtractFileExt(filename) ; ExeFileStream:=TFileStream.Create(fname,fmopenRead); //打开文件 // ExeFileStream:=TCompressionStream.Create(clMax,TStream(ExeFileStream)); with t_op_file_items_data do begin Open; append; try FieldStrm := CreateBlobStream(FieldByName('内容'),bmWrite); GetMem(Buffer,BufSize); try Counter := ExeFileStream.Size; size_tmp :=ExeFileStream.Size; frm_sys_progress.bsSkinGauge1.MaxValue:=(Counter div BufSize)+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; while Counter<>0 do begin if Counter>BufSize then N :=BufSize else N:=Counter; ExeFileStream.ReadBuffer(Buffer^,N); FieldStrm.WriteBuffer(Buffer^, N); Dec(Counter, N); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; // Application.ProcessMessages; end; finally FreeMem(Buffer,BufSize); FieldStrm.Free; end; FieldByName('名称').AsString:=filename; FieldByName('大小').AsFloat:=size_tmp; FieldByName('上传日期').AsDateTime:=now(); FieldByName('所有者').Asstring:=employee; FieldByName('类型').Asstring:=fileExt; Post; Application.MessageBox('程序上传至服务器成功!','提示',MB_OK+MB_IconInformation); finally frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; ExeFileStream.Free; end; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton27Click(Sender: TObject); begin if trim(t_op_seae.fieldbyname('订舱号码').AsString)='' then begin showmessage('申报人为空,不能做费用!'); exit; end; if not assigned(frm_op_seae) then frm_op_seae:=tfrm_op_seae.Create (self); frm_op_seae.ManualDock(frm_main.SearchTabs('frm_op_seae',frm_op_seae.caption,'101'),nil,alClient); frm_op_seae.show; { // showmessage(inttostr(frm_data_share.t_code_fee.RecordCount)); frm_data_share.t_code_fee.Filtered:=False; frm_data_share.t_code_fee.Filter:='中文名=''舱单费'''; frm_data_share.t_code_fee.Filtered:=true; frm_data_share.t_code_fee.Requery(); // showmessage(inttostr(frm_data_share.t_code_fee.RecordCount)); } frm_op_seae.Edit2.Text:=t_op_seae.FieldByName('主提单号').AsString; frm_op_seae.bsSkinButton44.OnClick(Sender); OpFeeName:=trim(t_op_seae.fieldbyname('订舱号码').AsString); { if frm_op_seae.t_op_seae.Active then begin frm_op_seae.t_op_seae.Requery(); frm_op_seae.t_op_seae.Locate('主提单号',t_op_seae.FieldByName('主提单号').AsString,[]); frm_op_seae.ManualDock(frm_main.SearchTabs('frm_op_seae',frm_op_seae.caption,'101'),nil,alClient); frm_op_seae.show; end else begin // frm_op_seae.t_op_seae.Requery(); frm_op_seae.ManualDock(frm_main.SearchTabs('frm_op_seae',frm_op_seae.caption,'101'),nil,alClient); frm_op_seae.show; frm_op_seae.t_op_seae.Locate('主提单号',t_op_seae.FieldByName('主提单号').AsString,[]); end; } end; procedure Tfrm_op_seae_edi_data.dxDBGrid1CustomDraw(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 uppercase(ANode.Strings[dxDBGrid1Column23.Index])='TRUE' then begin AColor:=clSkyBlue; exit; end; end; procedure Tfrm_op_seae_edi_data.t_op_file_dataAfterPost(DataSet: TDataSet); var aAdoQuery:TAdoQuery; begin // if t_op_seae.FieldByName('编号').AsString<>'' then begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('select sum(大小) sums from t_op_file_data where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open; if FieldByName('sums').AsInteger>=1 then begin t_op_seae.Edit; t_op_seae.FieldByName('上传文件').AsBoolean:=True; t_op_seae.Post; end; finally Free; end; end; end; procedure Tfrm_op_seae_edi_data.bsSkinPageControl1Change(Sender: TObject); begin if frm_op_seae_data_create=false then exit; if bsSkinPageControl1.ActivePage=bsSkinTabSheet2 then begin t_op_file_data.Close; t_op_file_data.Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').asstring; if not t_op_file_data.Active then t_op_file_data.open; end else begin if t_op_file_data.State in [dsedit,dsinsert] then t_op_file_data.Post; t_op_file_data.close; end; end; procedure Tfrm_op_seae_edi_data.DBEdit1Change(Sender: TObject); begin t_op_file_items_data.Close; end; procedure Tfrm_op_seae_edi_data.bsSkinButton28Click(Sender: TObject); begin grid_save_xls(dxdbgrid2); end; procedure Tfrm_op_seae_edi_data.N27Click(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('青港舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton29Click(Sender: TObject); begin t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add(opsqlstr); t_op_seae.Open; {t_op_seae_sum.close; t_op_seae_sum.sql.clear; t_op_seae_sum.sql.add(opsumsqlstr); t_op_seae_sum.Open;} end; procedure Tfrm_op_seae_edi_data.bsSkinButton30Click(Sender: TObject); 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; sys_print('舱单申报2',2,t_op_seae1,t_op_ctn1,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_edi_data.EXCEL1Click(Sender: TObject); var Ext,adate,bsno,corp,vslvoy,mblno,id,cntNo,ctnName,s:String; ExcelTemplet:Variant; i,j,k:integer; M,D,Y:Word; imp,seae_apply_add_total:boolean; aAdoQuery,t_op_ctn_edi:TAdoQuery; alist:TStringList; function getcustedi(cust:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select EDI代码 from t_crm_client where 客户简称='''+cust+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('EDI代码').AsString; finally FreeAndNil(aQuery); end; end; function GetvesselEdi(avessel: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 船舶呼号 from t_code_vessel where 英文船名='''+avessel+''''); Open; if IsEmpty then Result:='a' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; function getETD(VSL,VOY:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select * from v_vessel_voyage where 英文船名='''+VSL+''' and 航次='''+VOY+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('开船日期').AsString; finally FreeAndNil(aQuery); end; end; begin // id:=get_id; j:=1; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin close;SQL.Clear; SQL.Add('select * from t_op_seae_edi'); SQL.Add('where 主提单号=:主提单号'); Parameters.ParamByName('主提单号').Value:=''; end; alist:=TStringList.Create; t_op_ctn_edi:=CreateAdoQuery; t_op_ctn_edi.close; t_op_ctn_edi.sql.Text:='select * from t_op_ctn_edi where 编号=:编号'; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); isexcel:=True; try frm_main.db.BeginTrans; t_op_seae.DisableControls; t_op_ctn.DisableControls; I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value)<>'' do begin mblno:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('主提单号').Value:=mblno; aAdoQuery.Open; if aAdoQuery.IsEmpty then begin j:=j+1; id:=get_id; t_op_seae.Insert; t_op_seae['编号']:=id; t_op_seae['业务编号']:=mblno; t_op_seae['主编号']:=''; t_op_seae['EDI类型']:='CN'; t_op_seae['EDI状态']:='未发送'; t_op_seae['录入人']:=employee; t_op_seae['录入日期']:=now; t_op_seae['主提单号']:=Trim(mblno); t_op_seae['付费方式']:='FREIGHT COLLECT'; t_op_seae['签单地点']:='QINGDAO,CHINA'; t_op_seae['发货人代码']:=''; t_op_seae['舱单来源']:='EXCEL引入'; // t_op_seae['船公司']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value); t_op_seae['船公司代码']:=getcustedi(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,13].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['发货人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,14].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['发货人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['发货人地址2']:=''; t_op_seae['发货人地址3']:=''; t_op_seae['发货人']:=''; t_op_seae['发货人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,15].Value); // t_op_seae['发货人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,16].Value); // t_op_seae['发货人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,17].Value); t_op_seae['发货人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,16].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,17].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['收货人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,18].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['收货人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['收货人地址2']:=''; t_op_seae['收货人地址3']:=''; t_op_seae['收货人代码']:=''; t_op_seae['收货人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,19].Value); // t_op_seae['收货人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,20.Value); // t_op_seae['收货人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); t_op_seae['收货人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,20].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,21].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['通知人名称']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,22].Value; { s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; } t_op_seae['通知人地址1']:=StringReplace(Trim(alist.Text),#13#10,' ',[rfReplaceAll]); t_op_seae['通知人地址2']:=''; t_op_seae['通知人地址3']:=''; t_op_seae['通知人国家代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); // t_op_seae['通知人代码类型']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); // t_op_seae['通知人企业代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value); t_op_seae['通知人电话']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,24].Value); t_op_seae['船名']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)); t_op_seae['航次']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)); t_op_seae['船舶IMO']:=GetvesselEdi(t_op_seae['船名']); if getETD(t_op_seae['船名'],t_op_seae['航次'])<>'' then t_op_seae['开船日期']:=getETD(t_op_seae['船名'],t_op_seae['航次']); t_op_seae.fieldbyname('预抵日期').AsDateTime:=t_op_seae.fieldbyname('开船日期').AsDateTime+7; t_op_seae['装货港']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value)); if frm_data_share.t_code_loaport.Locate('英文名',t_op_seae['装货港'],[]) then begin t_op_seae['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end else t_op_seae['装港代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); t_op_seae['卸货港']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,9].Value)); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['卸货代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,10].Value); t_op_seae['目的地']:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,11].Value)); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['目的代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,12].Value); // t_op_seae['运输条款']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); t_op_seae['运输条款']:='CY-CY'; t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,40].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,32].Value; t_op_seae['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,31].Value; t_op_seae['货物描述']:=alist.Text; t_op_seae['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value); t_op_seae['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); t_op_seae['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); // t_op_seae['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); t_op_seae['危险品分类']:=''; t_op_seae['危险品编号']:=''; t_op_seae['冷藏通风量']:=''; t_op_seae['温度单位']:=''; t_op_seae['设置温度']:=''; t_op_seae['最低温度']:=''; t_op_seae['最高温度']:=''; t_op_seae['货物标识']:=''; t_op_seae['运费协议号']:=''; t_op_seae['湿度']:=''; t_op_seae['订舱号码']:=''; t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,33].Value); if pos('冻',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,34].Value))>0 then begin t_op_seae['货物标识']:='R'; t_op_seae['温度单位']:='C'; t_op_seae['设置温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); t_op_seae['最低温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); t_op_seae['最高温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,35].Value); end else if pos('危',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,34].Value))>0 then begin t_op_seae['货物标识']:='D'; t_op_seae['危险品分类']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,36].Value); t_op_seae['危险品编号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); end else t_op_seae['货物标识']:='S'; t_op_seae['文件类型']:='Master'; t_op_seae.Post; t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=id; t_op_ctn_edi.Open; t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=id; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value),3,2); // showmessage(mblno+' '+cntNo+'--'+ctnName); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,26].Value)); t_op_ctn_edi['封号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,27].Value)); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); // t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,32].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,31].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; end else begin t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=aAdoQuery.fieldbyname('编号').asstring; t_op_ctn_edi.Open; if not t_op_ctn_edi.Locate('箱号;封号',VarArrayOf([Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,26].Value)),Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,27].Value))]),[]) then begin t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=aAdoQuery.fieldbyname('编号').asstring; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value),3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,26].Value)); t_op_ctn_edi['封号']:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,27].Value)); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); // t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,37].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,32].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,31].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; t_op_seae.Edit; t_op_seae['货物描述']:=t_op_seae.fieldbyname('货物描述').AsString+t_op_ctn_edi['货描']; t_op_seae.Post; end; UpdateCTN(aAdoQuery.fieldbyname('编号').asstring); end; i:=i+1; end; frm_main.db.CommitTrans; finally isexcel:=False; t_op_seae.EnableControls; t_op_ctn.EnableControls; ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 MessageDlg('导入:'+IntTostr(i-2)+'行 '+'票数:'+IntTostr(j-1)+'票 ', mtConfirmation, [mbYes],0); if frm_main.db.InTransaction then begin ShowMessage('导入时出错,请刷新重试!'); frm_main.db.RollbackTrans; end; end; end; end; end; procedure Tfrm_op_seae_edi_data.t_op_seaeBeforePost(DataSet: TDataSet); begin if (not isexcel) then table_before_post(t_op_seae,'船代'); end; procedure Tfrm_op_seae_edi_data.dxDBGrid1Column26GetText(Sender: TObject; ANode: TdxTreeListNode; var AText: String); begin if AText='True' then AText:='是' else AText:=''; end; procedure Tfrm_op_seae_edi_data.EXCEL2Click(Sender: TObject); var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr:string; begin if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=6; excel3.Connect; excel3.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'ZHENHUA.xls'+'"'+')]'); excel3.putstr(2,1,aAdoQuery.FieldByName('主提单号').AsString); First; while not eof do begin excel3.putstr(j,1,aAdoQuery.FieldByName('船名').AsString); excel3.putstr(j,2,aAdoQuery.FieldByName('航次').AsString); excel3.putstr(j,3,aAdoQuery.FieldByName('船公司代码').AsString); excel3.putstr(j,4,''); excel3.putstr(j,5,aAdoQuery.FieldByName('主提单号').AsString); excel3.putstr(j,6,aAdoQuery.FieldByName('箱号').AsString); excel3.putstr(j,7,aAdoQuery.FieldByName('封号').AsString); poststr:=aAdoQuery.FieldByName('装货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel3.putstr(j,8,poststr); poststr:=aAdoQuery.FieldByName('卸货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel3.putstr(j,10,poststr); poststr:=aAdoQuery.FieldByName('目的地').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel3.putstr(j,11,poststr); excel3.putstr(j,12,aAdoQuery.FieldByName('件数').AsString); excel3.putstr(j,13,aAdoQuery.FieldByName('包装').AsString); excel3.putstr(j,14,aAdoQuery.FieldByName('重量').AsString); excel3.putstr(j,15,aAdoQuery.FieldByName('尺码').AsString); excel3.putstr(j,16,aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString); excel3.putstr(j,17,aAdoQuery.FieldByName('货物描述').AsString); excel3.putstr(j,18,aAdoQuery.FieldByName('发货人名称').AsString); excel3.putstr(j,19,aAdoQuery.FieldByName('收货人名称').AsString); excel3.putstr(j,20,aAdoQuery.FieldByName('通知人名称').AsString); if Pos('COLLECT',aAdoQuery.FieldByName('付费方式').AsString)>0 THEN excel3.putstr(j,21,'COLLECT') else excel3.putstr(j,21,'PREPAID'); excel3.putstr(j,22,aAdoQuery.FieldByName('唛头_1').AsString); excel3.putstr(j,24,aAdoQuery.FieldByName('发货人地址1').AsString+#13#10+aAdoQuery.FieldByName('发货人地址2').AsString+#13#10+aAdoQuery.FieldByName('发货人地址3').AsString); excel3.putstr(j,25,''); excel3.putstr(j,26,aAdoQuery.FieldByName('发货人国家代码').AsString); excel3.putstr(j,27,'TE'); excel3.putstr(j,28,aAdoQuery.FieldByName('发货人电话').AsString); excel3.putstr(j,30,aAdoQuery.FieldByName('收货人地址1').AsString+#13#10+aAdoQuery.FieldByName('收货人地址2').AsString+#13#10+aAdoQuery.FieldByName('收货人地址3').AsString); excel3.putstr(j,31,''); excel3.putstr(j,32,aAdoQuery.FieldByName('收货人国家代码').AsString); excel3.putstr(j,33,'TE'); excel3.putstr(j,34,aAdoQuery.FieldByName('收货人电话').AsString); excel3.putstr(j,36,aAdoQuery.FieldByName('通知人地址1').AsString+#13#10+aAdoQuery.FieldByName('通知人地址2').AsString+#13#10+aAdoQuery.FieldByName('通知人地址3').AsString); excel3.putstr(j,37,''); excel3.putstr(j,38,aAdoQuery.FieldByName('通知人国家代码').AsString); excel3.putstr(j,39,'TE'); excel3.putstr(j,40,aAdoQuery.FieldByName('通知人电话').AsString); if (aAdoQuery.FieldByName('货物标识').AsString='D') then excel3.putstr(j,42,'是') else excel3.putstr(j,42,'否'); excel3.putstr(j,43,aAdoQuery.FieldByName('危险品编号').AsString); excel3.putstr(j,44,aAdoQuery.FieldByName('危险品分类').AsString); excel3.putstr(j,45,aAdoQuery.FieldByName('危险品联系人').AsString); excel3.putstr(j,46,aAdoQuery.FieldByName('危险品电话').AsString); j:=j+1; Next; end; SaveDialog.Filter := '(*.xls)|*.xls'; SaveDialog.FileName := aAdoQuery.fieldbyname('主提单号').asstring+'.xls'; if SaveDialog.Execute then begin excel3.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]'); excel3.Exec('[CLOSE(false)]'); // excel2.Exec('[open("'+SaveDialog.FileName+'")]'); // excel2.Exec('[APP.maxIMIZE()]'); //最大化excel end; // updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo4Enter(Sender: TObject); begin RxDBLookupCombo4.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo4Exit(Sender: TObject); begin RxDBLookupCombo4.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.N31Click(Sender: TObject); begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要修改的业务!!'); exit; end; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; try frm_op_customername_change:=tfrm_op_customername_change.Create (self); frm_op_customername_change.ShowModal; finally frm_op_customername_change.Free; frm_op_customername_change:=nil; end; end; procedure Tfrm_op_seae_edi_data.N33Click(Sender: TObject); begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要修改的业务!!'); exit; end; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; try frm_op_vesselvoy_cdchange:=tfrm_op_vesselvoy_cdchange.Create (self); frm_op_vesselvoy_cdchange.ShowModal; finally frm_op_vesselvoy_cdchange.Free; frm_op_vesselvoy_cdchange:=nil; end; end; procedure Tfrm_op_seae_edi_data.Edit3KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; end.