unit u_op_seae_edi; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, DB, ADODB, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs, DBCtrls, wwdblook, wwdbdatetimepicker, RxLookup, Menus, XPMenu, Mask, wwdbedit, Wwdotdot, Wwdbcomb,inifiles, kbmMemTable; type Tfrm_op_seae_edi = class(TForm) Panel2: TPanel; t_op_seae: TADOQuery; t_op_seae1: TDataSource; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; XPMenu1: TXPMenu; bsSkinPanel1: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton5: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; Label10: TLabel; Label5: TLabel; Label125: TLabel; Label30: TLabel; Label1: TLabel; Label8: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBLookupCombo49: TwwDBLookupCombo; Edit7: TEdit; Edit2: TEdit; RxDBLookupCombo6: TRxDBLookupCombo; bsSkinPanel5: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; Label38: TLabel; DBEdit9: TDBEdit; Label36: TLabel; DBEdit7: TDBEdit; t_code_sendedi: TADOQuery; t_code_sendedi1: TDataSource; bsSkinButton1: TbsSkinButton; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column114: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridDateColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column81: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column17: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridDateColumn; dxDBGrid1Column20: TdxDBGridDateColumn; dxDBGrid1Column22: TdxDBGridMaskColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column28: TdxDBGridMaskColumn; dxDBGrid1Column29: TdxDBGridMaskColumn; dxDBGrid1Column30: TdxDBGridMaskColumn; dxDBGrid1Column31: TdxDBGridMaskColumn; dxDBGrid1Column32: TdxDBGridMaskColumn; dxDBGrid1Column33: TdxDBGridDateColumn; dxDBGrid1Column34: TdxDBGridMaskColumn; dxDBGrid1Column35: TdxDBGridMaskColumn; dxDBGrid1Column36: TdxDBGridMaskColumn; dxDBGrid1Column37: TdxDBGridMaskColumn; dxDBGrid1Column38: TdxDBGridMaskColumn; dxDBGrid1Column39: TdxDBGridMaskColumn; dxDBGrid1Column40: TdxDBGridMaskColumn; dxDBGrid1Column41: TdxDBGridColumn; dxDBGrid1Column42: TdxDBGridColumn; dxDBGrid11: TdxDBGridMaskColumn; dxDBGrid12: TdxDBGridMaskColumn; dxDBGrid13: TdxDBGridMaskColumn; dxDBGrid14: TdxDBGridMaskColumn; dxDBGrid15: TdxDBGridMaskColumn; dxDBGrid16: TdxDBGridMaskColumn; dxDBGrid17: TdxDBGridMaskColumn; dxDBGrid18: TdxDBGridMaskColumn; dxDBGrid19: TdxDBGridMaskColumn; dxDBGrid110: TdxDBGridMaskColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1TEU: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridMaskColumn; dxDBGrid1Column66: TdxDBGridMaskColumn; dxDBGrid1Column67: TdxDBGridDateColumn; dxDBGrid1Column68: TdxDBGridMaskColumn; dxDBGrid1Column69: TdxDBGridMaskColumn; dxDBGrid1Column70: TdxDBGridMaskColumn; dxDBGrid1Column71: TdxDBGridMaskColumn; dxDBGrid1Column72: TdxDBGridMaskColumn; dxDBGrid1Column97: TdxDBGridMaskColumn; dxDBGrid1Column119: TdxDBGridColumn; dxDBGrid1Column120: TdxDBGridColumn; dxDBGrid1Column122: TdxDBGridCheckColumn; dxDBGrid1Column124: TdxDBGridColumn; dxDBGrid1Column125: TdxDBGridColumn; dxDBGrid1Column126: TdxDBGridColumn; SaveDialog1: TSaveDialog; t_op_ctn1: TDataSource; t_op_ctn: TADOQuery; Label20: TLabel; Label124: TLabel; RxDBLookupCombo28: TRxDBLookupCombo; Label35: TLabel; bsSkinButton9: TbsSkinButton; RxDBLookupCombo22: TRxDBLookupCombo; RxDBLookupCombo8: TRxDBLookupCombo; memtotal: TkbmMemTable; memtotal1: TDataSource; memtotalField20: TIntegerField; memtotalField40: TIntegerField; memtotalField40HC: TIntegerField; memtotalField45: TIntegerField; memtotalField202: TIntegerField; memtotalField402: TIntegerField; memtotalField40HC2: TIntegerField; memtotalField452: TIntegerField; memtotalField203: TIntegerField; memtotalField403: TIntegerField; memtotalField40HC3: TIntegerField; memtotalField453: TIntegerField; memtotalField204: TIntegerField; memtotalField404: TIntegerField; memtotalField40HC4: TIntegerField; memtotalField454: TIntegerField; memtotalField: TIntegerField; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure dxDBGrid1Column4CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinButton2Click(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinCheckRadioBox1Click(Sender: TObject); private { Private declarations } seaestr,seaedelstr:string ; function findstr:string ; procedure setFootermsg; function CreateIFCSUMEdiFile:TStrings; function CreateVOSTOCHNYEdiFile:TStrings; function CreateEdiFile:TStrings; public { Public declarations } end; var frm_op_seae_edi: Tfrm_op_seae_edi; implementation {$R *.dfm} uses u_main,my_sys_function,u_data_share ; procedure Tfrm_op_seae_edi.bsSkinButton5Click(Sender: TObject); begin close ; end; procedure Tfrm_op_seae_edi.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); frm_op_seae_edi.Hide; frm_op_seae_edi.ManualFloat(frm_op_seae_edi.BoundsRect ); frm_main.freeTabs('frm_op_seae_edi'); action:=cafree; frm_op_seae_edi:=nil; end; procedure Tfrm_op_seae_edi.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_edi.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_edi.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,210); end; procedure Tfrm_op_seae_edi.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_edi.FormShow(Sender: TObject); var i:integer ; begin loadreggrid(dxdbgrid1,true,caption+'1'); bsSkinCheckRadioBox2.checked:=True; end; procedure Tfrm_op_seae_edi.bsSkinButton6Click(Sender: TObject); begin edit2.text:='' ; edit7.Text:='' ; wwDBDateTimePicker1.Clear ; wwDBDateTimePicker2.Clear ; RxDBLookupCombo6.ClearValue ; wwDBLookupCombo49.clear ; RxDBLookupCombo22.ClearValue ; RxDBLookupCombo8.ClearValue ; end; function Tfrm_op_seae_edi.findstr: string; begin end; procedure Tfrm_op_seae_edi.setFootermsg; var backteu,ggteu,thcteu:integer ; i,teu1,teu2,teu3,teu4,teu5,teu6,teu7,teu8,teu9,teu10,teuot,teuall:integer; steu:string; teu:Array [1..10] of integer; begin { lblcount.Caption:='票数 共: '+inttostr(t_op_seae.recordcount) ; ggteu:=0 ; backteu:=0 ;thcteu:=0 ; teu[1]:=0; teu[2]:=0; teu[3]:=0; teu[4]:=0; teu[5]:=0; teu[6]:=0; teu[7]:=0; teu[8]:=0; teu[9]:=0; teu[10]:=0; teuot:=0; teuall:=0; with t_op_seae do begin disablecontrols ; first ; while not eof do begin teu[1]:=teu[1]+fieldbyname('箱型1').AsInteger; teu[2]:=teu[2]+fieldbyname('箱型2').AsInteger; teu[3]:=teu[3]+fieldbyname('箱型3').AsInteger; teu[4]:=teu[4]+fieldbyname('箱型4').AsInteger; teu[5]:=teu[5]+fieldbyname('箱型5').AsInteger; teu[6]:=teu[6]+fieldbyname('箱型6').AsInteger; teu[7]:=teu[7]+fieldbyname('箱型7').AsInteger; teu[8]:=teu[8]+fieldbyname('箱型8').AsInteger; teu[9]:=teu[9]+fieldbyname('箱型9').AsInteger; teu[10]:=teu[10]+fieldbyname('箱型10').AsInteger; teuot:=teuot+fieldbyname('其他箱型').AsInteger; teuall:=teuall+fieldbyname('箱TEU').AsInteger; next ; end ; enablecontrols ; steu:='集装箱:'; for i:=1 to 10 do begin try if trim(frm_data_share.t_code_ctn_de.fieldbyname('箱型'+inttostr(i)).asstring)<>'' then begin if frm_data_share.t_code_ctn.locate('代码',trim(frm_data_share.t_code_ctn_de.fieldbyname('箱型'+inttostr(i)).asstring),[]) then begin steu:=steu+' '+trim(frm_data_share.t_code_ctn.fieldbyname('表现形式').asstring)+': '+inttostr(teu[i]); end; end else begin end; except ; end; end; steu:=steu+' '+'其他箱型: '+inttostr(teuot); steu:=steu+' '+'合计TEU: '+inttostr(teuall); lblcount.Caption:='票数共: '+inttostr(t_op_seae.recordcount) ; lblcount.Caption:=lblcount.Caption+' '+steu; end ; } end; procedure Tfrm_op_seae_edi.dxDBGrid1Column4CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); begin AColor:=dxgrid_color('海运出口',ANode.Strings[dxDBGrid1Column4.Index]); AFont.Color:=clblack; end; procedure Tfrm_op_seae_edi.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_seae,'编号'); end; procedure Tfrm_op_seae_edi.bsSkinButton2Click(Sender: TObject); var str,delstr:string ; begin str:='where 装运方式<>''拼箱主票'' and 装运方式<>''分票主票'' and 装运方式<>''合票分票'' ' ; if edit2.text<>'' then str:=str+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if edit7.text<>'' then str:=str+' and 航次 like '+''''+'%'+Edit7.text+'%'+''''; if wwDBLookupCombo49.text<>''then str:=str+' and 船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo22.DisplayValue<>''then str:=str+' and 装港代码='+''''+RxDBLookupCombo22.DisplayValues[2]+''''; if RxDBLookupCombo8.DisplayValue<>''then str:=str+' and 卸货代码='+''''+RxDBLookupCombo8.DisplayValues[2]+''''; if RxDBLookupCombo6.DisplayValues[1]<>'' then str:=str+' and 船公司='+''''+RxDBLookupCombo6.DisplayValues[1]+''''; screen.Cursor:=crSQLwait ; try with t_op_seae,SQL do begin close ; Clear ; add('select * from t_op_seae '); add(str); open ; end ; setfootermsg ; finally screen.Cursor:=crDefault ; end ; end; procedure Tfrm_op_seae_edi.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if t_code_sendedi.State in [dsedit,dsinsert] then t_code_sendedi.post; end; procedure Tfrm_op_seae_edi.bsSkinCheckRadioBox2Click(Sender: TObject); begin if t_code_sendedi.State in [dsedit,dsinsert] then t_code_sendedi.post; if bsSkinCheckRadioBox2.Checked then begin t_code_sendedi.close; t_code_sendedi.SQL.Text:='select * from t_code_sendedi where EDI类别='''+bsSkinCheckRadioBox2.Caption+''''; t_code_sendedi.Open; if t_code_sendedi.IsEmpty then begin t_code_sendedi.Insert; t_code_sendedi.FieldByName('EDI类别').AsString:=bsSkinCheckRadioBox2.Caption; t_code_sendedi.post; end; end; end; function Tfrm_op_seae_edi.CreateEdiFile: TStrings; begin end; function Tfrm_op_seae_edi.CreateIFCSUMEdiFile: TStrings; var Str,sl1,sl:TStringList; i,l,M:integer; SenderCode,ReciverCode,strtemp:String; aQuery:TADOQuery; function GetShipperString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('发货人代码').AsString); GetLengthTString(TempStr,35); Result:='16:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('收货人代码').AsString); GetLengthTString(TempStr,35); Result:='17:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('通知人代码').AsString); GetLengthTString(TempStr,35); Result:='18:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetMARKSString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('唛头').AsString); GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; begin str:=Tstringlist.Create; sl1:=Tstringlist.Create; sl:=Tstringlist.Create; aQuery:=CreateAdoQuery; try SenderCode:=trim(DBEdit9.Text) ; ReciverCode:=trim(DBEdit7.Text) ; str.Add('00:IFCSUM:MANIFEST:9:'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); str.Add('10::' + trim(t_op_seae.fieldbyname('船名').asstring) +'::' + trim(t_op_seae.fieldbyname('航次').asstring)+':::' + GetDatetime(datetimetostr(t_op_seae.fieldbyname('预抵日期').asdatetime),0)+':' + GetDatetime(datetimetostr(t_op_seae.fieldbyname('开船日期').asdatetime),0)+':' +trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' +trim(t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+#39); if SenderCode<>'' then str.Add('11:'+ SenderCode+#39); t_op_seae.First; while not t_op_seae.eof do begin if frm_data_share.t_code_free.locate('付费方式',t_op_seae.fieldbyname('付费方式').asstring,[]) then begin strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1); end else begin strtemp:='P'; end; str.Add('12:' + trim(t_op_seae.fieldbyname('主提单号').asstring) +'::::' +':' +':' +trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' + trim(t_op_seae.fieldbyname('运输条款').asstring) +':' + strtemp+':' + GetDatetime(trim(t_op_seae.fieldbyname('开船日期').asstring),0)+'::' + GetDatetime(trim(t_op_seae.fieldbyname('签单日期').asstring),0)+':' +'::' +#39); //船舶经营人 str.Add ('13:'+trim(t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+':' +trim(t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(t_op_seae.fieldbyname('交货地点').asstring) +'::::' +#39); Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); aQuery.Close; aQuery.SQL.Text:='select * from t_op_yp_ctn where 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; aQuery.Open; if not aQuery.IsEmpty then begin while not aQuery.Eof do begin str.Add ('21:'+Trim(GetCntrEdi(aQuery.fieldbyname('代码').asstring))+':'+trim(aQuery.fieldbyname('数量').asstring)+':' +':'+trim(aQuery.fieldbyname('箱状态').asstring)+':' +':::::'+'''' ); aQuery.Next; end; end; str.Add ('41:1::'+trim(t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(t_op_seae.fieldbyname('包装').asstring))+':' +trim(t_op_seae.fieldbyname('包装').asstring) +':' //第一层包装说明 +trim(t_op_seae.fieldbyname('重量').asstring) +'::' //第一层包装说明 +trim(t_op_seae.fieldbyname('尺码').asstring) +#39); IF trim(t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +':' +trim(t_op_seae.fieldbyname('温度单位').asstring) +':' +trim(t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(t_op_seae.fieldbyname('最高温度').asstring) +#39); END; IF trim(t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(t_op_seae.fieldbyname('危险品分类').asstring) +':' +trim(t_op_seae.fieldbyname('危险品页号').asstring) +':' +trim(t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +#39); END; Str.Add(GetMARKSString); sl1.Text:=FormatEdiString(t_op_seae.fieldbyname('货物描述').AsString); GetLengthTString(sl1,35); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; strtemp:=''; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin strtemp:='47:'+sl.Strings[L]+':'; end else begin if M=5 then strtemp:=strtemp+sl.Strings[L] else strtemp:=strtemp+sl.Strings[L]+':'; end; end else begin strtemp:=strtemp+''''; Str.Add(strtemp); M:=1; strtemp:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; strtemp:=strtemp+''''; Str.Add(strtemp); aQuery.Close; aQuery.SQL.Text:='select * from t_op_ctn where 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; aQuery.Open; if not aQuery.IsEmpty then begin while not aQuery.Eof do begin str.Add ('51:1:'+trim(aQuery.fieldbyname('箱号').asstring)+':'+trim(aQuery.fieldbyname('封号').asstring)+':' +Trim(GetCntrEdi(aQuery.fieldbyname('代码').asstring))+':'+trim(aQuery.fieldbyname('箱状态').asstring) +':'+trim(IntToStr(aQuery.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(aQuery.fieldbyname('重量').AsFloat))+':' +trim(FloatToStr(aQuery.fieldbyname('箱皮重').AsFloat))+':'+trim(FloatToStr(aQuery.fieldbyname('尺码').AsFloat))+'::::::' +trim(aQuery.fieldbyname('贝位').asstring)+'''' ); aQuery.Next; end; end; t_op_seae.Next; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); { for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; } SaveDialog1.FileName:=t_op_seae.fieldbyname('船名').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str); end; end; function Tfrm_op_seae_edi.CreateVOSTOCHNYEdiFile: TStrings; var Str,sl1,sl:TStringList; i,l,M:integer; SenderCode,ReciverCode,strtemp:String; aQuery:TADOQuery; function GetShipperString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('发货人代码').AsString); GetLengthTString(TempStr,35); Result:='16:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('收货人代码').AsString); GetLengthTString(TempStr,35); Result:='17:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('通知人代码').AsString); GetLengthTString(TempStr,35); Result:='18:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; function GetMARKSString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_seae.fieldbyname('唛头').AsString); GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; begin str:=Tstringlist.Create; sl1:=Tstringlist.Create; sl:=Tstringlist.Create; aQuery:=CreateAdoQuery; try SenderCode:=trim(DBEdit9.Text) ; ReciverCode:=trim(DBEdit7.Text) ; str.Add('00:IFCSUM:MANIFEST:9:'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); str.Add('10::' + trim(t_op_seae.fieldbyname('船名').asstring) +'::' + trim(t_op_seae.fieldbyname('航次').asstring)+':::' + GetDatetime(datetimetostr(t_op_seae.fieldbyname('预抵日期').asdatetime),0)+':' + GetDatetime(datetimetostr(t_op_seae.fieldbyname('开船日期').asdatetime),0)+':' +trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' +trim(GetPortREdi(t_op_seae.fieldbyname('卸货代码').asstring)) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+#39); if SenderCode<>'' then str.Add('11:'+ SenderCode+#39); t_op_seae.First; while not t_op_seae.eof do begin if frm_data_share.t_code_free.locate('付费方式',t_op_seae.fieldbyname('付费方式').asstring,[]) then begin strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1); end else begin strtemp:='P'; end; str.Add('12:' + trim(t_op_seae.fieldbyname('主提单号').asstring) +'::::' +':' +':' +trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' + trim(t_op_seae.fieldbyname('运输条款').asstring) +':' + strtemp+':' + GetDatetime(trim(t_op_seae.fieldbyname('开船日期').asstring),0)+'::' + GetDatetime(trim(t_op_seae.fieldbyname('签单日期').asstring),0)+':' +'::' +#39); //船舶经营人 str.Add ('13:'+trim(GetPortREdi(t_op_seae.fieldbyname('卸货代码').asstring)) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+':' +trim(GetPortREdi(t_op_seae.fieldbyname('交货代码').asstring)) +':' +trim(t_op_seae.fieldbyname('交货地点').asstring) +'::::' +#39); Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); str.Add ('41:1:'+trim(t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(t_op_seae.fieldbyname('包装').asstring))+':' +trim(t_op_seae.fieldbyname('包装').asstring) +':' //第一层包装说明 +trim(t_op_seae.fieldbyname('重量').asstring) +'::' //第一层包装说明 +trim(t_op_seae.fieldbyname('尺码').asstring) +#39); IF trim(t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +':' +trim(t_op_seae.fieldbyname('温度单位').asstring) +':' +trim(t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(t_op_seae.fieldbyname('最高温度').asstring) +#39); END; IF trim(t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(t_op_seae.fieldbyname('危险品分类').asstring) +':' +trim(t_op_seae.fieldbyname('危险品页号').asstring) +':' +trim(t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +#39); END; Str.Add(GetMARKSString); sl1.Text:=FormatEdiString(t_op_seae.fieldbyname('货物描述').AsString); GetLengthTString(sl1,35); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; if sl.Text<>'' then begin strtemp:=''; M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin strtemp:='47:'+sl.Strings[L]+':'; end else begin if M=10 then strtemp:=strtemp+sl.Strings[L] else strtemp:=strtemp+sl.Strings[L]+':'; end; end else begin strtemp:=strtemp+''''; Str.Add(strtemp); M:=1; strtemp:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; strtemp:=strtemp+''''; Str.Add(strtemp); end; aQuery.Close; aQuery.SQL.Text:='select * from t_op_ctn where 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; aQuery.Open; if not aQuery.IsEmpty then begin i:=1; while not aQuery.Eof do begin str.Add ('51:'+inttostr(i)+':'+trim(aQuery.fieldbyname('箱号').asstring)+':'+trim(aQuery.fieldbyname('封号').asstring)+':' +Trim(GetCntrEdi2(aQuery.fieldbyname('代码').asstring))+':'+trim(aQuery.fieldbyname('箱状态').asstring) +':'+trim(IntToStr(aQuery.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(aQuery.fieldbyname('重量').AsFloat))+':' +trim(FloatToStr(aQuery.fieldbyname('箱皮重').AsFloat))+':'+trim(FloatToStr(aQuery.fieldbyname('尺码').AsFloat))+'::::::' +trim(aQuery.fieldbyname('贝位').asstring)+'''' ); aQuery.Next; Inc(i); end; end; t_op_seae.Next; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); { for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; } SaveDialog1.FileName:=t_op_seae.fieldbyname('船名').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str); end; end; procedure Tfrm_op_seae_edi.bsSkinButton1Click(Sender: TObject); begin if bsSkinCheckRadioBox2.Checked then CreateIFCSUMEdiFile else if bsSkinCheckRadioBox1.Checked then CreateVOSTOCHNYEdiFile; end; procedure Tfrm_op_seae_edi.bsSkinButton9Click(Sender: TObject); begin if not t_op_ctn.Active then t_op_ctn.Open; if not memtotal.Active then memtotal.Open; memtotal.EmptyTable; t_op_seae.First; while not t_op_seae.Eof do begin memtotal.edit; memtotal.FieldByName('记录数').AsInteger:=memtotal.FieldByName('记录数').AsInteger+1; memtotal.post; if t_op_seae.FieldByName('业务来源').AsString='国际中转' then begin t_op_ctn.First; while not t_op_ctn.Eof do begin memtotal.edit; if t_op_ctn.FieldByName('尺寸').AsString='20' then begin memtotal.FieldByName('国际中转20').AsInteger:=memtotal.FieldByName('国际中转20').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱20').AsInteger:=memtotal.FieldByName('空箱20').AsInteger+1; end; if t_op_ctn.FieldByName('尺寸').AsString='45' then begin memtotal.FieldByName('国际中转45').AsInteger:=memtotal.FieldByName('国际中转45').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱45').AsInteger:=memtotal.FieldByName('空箱45').AsInteger+1; end; if t_op_ctn.FieldByName('尺寸').AsString='40' then begin if t_op_ctn.FieldByName('箱型').AsString='HC' THEN begin memtotal.FieldByName('国际中转40HC').AsInteger:=memtotal.FieldByName('国际中转40HC').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40HC').AsInteger:=memtotal.FieldByName('空箱40HC').AsInteger+1; end else begin memtotal.FieldByName('国际中转40').AsInteger:=memtotal.FieldByName('国际中转40').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40').AsInteger:=memtotal.FieldByName('空箱40').AsInteger+1; end; end; memtotal.post; t_op_ctn.Next; end; end else if t_op_seae.FieldByName('业务来源').AsString='国内中转' then begin t_op_ctn.First; while not t_op_ctn.Eof do begin memtotal.edit; if t_op_ctn.FieldByName('尺寸').AsString='20' then BEGIN memtotal.FieldByName('国内中转20').AsInteger:=memtotal.FieldByName('国内中转20').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱20').AsInteger:=memtotal.FieldByName('空箱20').AsInteger+1; END; if t_op_ctn.FieldByName('尺寸').AsString='45' then BEGIN memtotal.FieldByName('国内中转45').AsInteger:=memtotal.FieldByName('国内中转45').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱45').AsInteger:=memtotal.FieldByName('空箱45').AsInteger+1; END; if t_op_ctn.FieldByName('尺寸').AsString='40' then begin if t_op_ctn.FieldByName('箱型').AsString='HC' THEN BEGIN memtotal.FieldByName('国内中转40HC').AsInteger:=memtotal.FieldByName('国内中转40HC').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40HC').AsInteger:=memtotal.FieldByName('空箱40HC').AsInteger+1; end else begin memtotal.FieldByName('国内中转40').AsInteger:=memtotal.FieldByName('国内中转40').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40').AsInteger:=memtotal.FieldByName('空箱40').AsInteger+1; END; end; memtotal.post; t_op_ctn.Next; end; end else if pos('本地',t_op_seae.FieldByName('业务来源').AsString)>0 then begin t_op_ctn.First; while not t_op_ctn.Eof do begin memtotal.edit; if t_op_ctn.FieldByName('尺寸').AsString='20' then BEGIN memtotal.FieldByName('本地20').AsInteger:=memtotal.FieldByName('本地20').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱20').AsInteger:=memtotal.FieldByName('空箱20').AsInteger+1; END; if t_op_ctn.FieldByName('尺寸').AsString='45' then begin memtotal.FieldByName('本地45').AsInteger:=memtotal.FieldByName('本地45').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱45').AsInteger:=memtotal.FieldByName('空箱45').AsInteger+1; END; if t_op_ctn.FieldByName('尺寸').AsString='40' then begin if t_op_ctn.FieldByName('箱型').AsString='HC' THEN begin memtotal.FieldByName('本地40HC').AsInteger:=memtotal.FieldByName('本地40HC').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40HC').AsInteger:=memtotal.FieldByName('空箱40HC').AsInteger+1; END else begin memtotal.FieldByName('本地40').AsInteger:=memtotal.FieldByName('本地40').AsInteger+1; if t_op_ctn.FieldByName('箱状态').AsString='E' then memtotal.FieldByName('空箱40').AsInteger:=memtotal.FieldByName('空箱40').AsInteger+1; END; end; memtotal.post; t_op_ctn.Next; end; end; t_op_seae.Next; end; try sys_print('海运出口舱单',2,t_op_seae1,memtotal1,nil,nil,t_op_seae1,t_op_ctn1,nil,nil,nil,nil,nil); finally t_op_ctn.Close; end; memtotal.close; end; procedure Tfrm_op_seae_edi.bsSkinCheckRadioBox1Click(Sender: TObject); begin if t_code_sendedi.State in [dsedit,dsinsert] then t_code_sendedi.post; if bsSkinCheckRadioBox1.Checked then begin t_code_sendedi.close; t_code_sendedi.SQL.Text:='select * from t_code_sendedi where EDI类别='''+bsSkinCheckRadioBox1.Caption+''''; t_code_sendedi.Open; if t_code_sendedi.IsEmpty then begin t_code_sendedi.Insert; t_code_sendedi.FieldByName('EDI类别').AsString:=bsSkinCheckRadioBox1.Caption; t_code_sendedi.post; end; end; end; end.