unit u_op_seae_edi_nbcd; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon, Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB; type Tfrm_op_seae_edi_nbcd = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; Label2: TLabel; Edit2: TEdit; Edit1: TEdit; Label1: TLabel; SaveDialog1: TSaveDialog; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; t_op_ctn: TADOQuery; t_op_ctn1: TDataSource; bsSkinRadioGroup1: TbsSkinRadioGroup; Label3: TLabel; Edit3: TEdit; bsSkinRadioGroup2: TbsSkinRadioGroup; bsSkinButton4: TbsSkinButton; bsSkinGroupBox1: TbsSkinGroupBox; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; t_op_ams: TADOQuery; t_op_ams1: TDataSource; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; t_op_seae_assistant: TADOQuery; ADOQueryTemp: TADOQuery; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); private function isEditrue(DataSet:TDataSet): boolean; //判断必填项 function GetvesselEdi(avessel: String): String; function GetStrNum(str:String):integer;//判断数字位数 function FormatListString(Old:TStrings;mCount,Strlength:integer):String;//根据长度要求格式化字符串 function FormatEdiString(str:String;Strlength:integer=0):String;//特殊字符加 : function CreateEdiFile:TStrings;//订舱报文 function CreateZHUEdiFile(bstype:integer):TStrings;//主票订舱报文 function CreateSIEdiFile:TStrings; //SI报文 function CreateSIZHUEdiFile(bstype:integer):TStrings; //主票SI报文 function GetCntrEdi(cntrsize: String):String; //箱型EDI代码 function GetpkgsEdi(pkgs:String):String;//包装EDI代码 function GetlineEdi(aline:String):String;//航线EDI代码 function GetLengthword(var s: String; l: Integer;str:String): String;//根据长度要求截取字符串 procedure GetLengthTString(var sl:TStringList;l:integer);//根据长度格式化 tstringlist function IsZhongwen(Str:String):Boolean;//是否包含中文或双字节字符 function ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String; { Private declarations } public { Public declarations } QUOTATIONNO,CARGOGROSSWT,SoRemarks,SIRemarks:string; function GetPortEdiID(Port:String): String; function GetShipEdiNO(Ship:String): String; function CreateVgmEdiFile:TStrings; end; var frm_op_seae_edi_nbcd: Tfrm_op_seae_edi_nbcd; implementation uses u_op_seae, u_main, my_sys_function, u_data_share, u_op_seae_edi_nor, u_op_seae_assistant; {$R *.dfm} function Tfrm_op_seae_edi_nbcd.ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String; begin Result:=''; if LinesCount>5 then begin case CorpTypeid of 0:begin case BsTypeid of 0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:+加多出部分'; 1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:+加多出部分'; end; end; 1:begin case BsTypeid of 0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:++加多出部分'; 1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:++加多出部分'; end; end; 2:begin case BsTypeid of 0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:+++加多出部分'; 1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:+++加多出部分'; end; end; end; end; end; function Tfrm_op_seae_edi_nbcd.GetPortEdiID(Port:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码 from t_code_disport where 英文名='''+Port+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_nbcd.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:='' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_nbcd.IsZhongwen(Str: String): Boolean; var i:Integer; begin Result:=false; if Str='' then Exit; for i:=1 to Length(Str) do begin if (Str[i]>Chr(127)) or (Str[i]=Chr(42)) then begin // if Str[i]>Chr(127) then begin Result:=True; Exit; end; end; end; function Tfrm_op_seae_edi_nbcd.GetLengthword(var s: String; l: Integer;str:String): String; var i:Integer; b:Boolean; begin s:=''; if Length(str)<=l then begin result:=str; end else begin b:=true; s:=Copy(str,l+1,Length(str)-l); str:=Copy(str,1,l); result:=''; for i:=Length(str) downto 1 do begin if ( not (str[i] in [' ',';',',','.',':','/','(',')','?','+','-'])) and b then s:=str[i]+s else begin b:=false; result:=str[i]+Result; end; end; s:=s+' '; end; end; procedure Tfrm_op_seae_edi_nbcd.GetLengthTString(var sl: TStringList; l: integer); var i:integer; str_head,S:String; Stemp:TStrings; begin Stemp:=TStringList.Create; try str_head:=''; S:=''; for i:=0 to sl.Count-1 do begin if sl[i]<>'' then stemp.add(GetLengthword(str_head,l,s+sl[i])); S:=Str_head; end; while S<>'' do begin stemp.add(GetLengthword(str_head,l,s)); S:=Str_head; end; SL.Assign(Stemp); finally FreeAndNil(Stemp); end; end; function Tfrm_op_seae_edi_nbcd.FormatEdiString(str:String;Strlength:integer=0):String; var i:integer; strC:widestring; begin strC:=''; for i:=1 to length(str) do begin if ((str[i]=#39) or (str[i]=':') or (str[i]='+') or (str[i]='?') or (str[i]=';')) then begin strC:=strC+'?'+str[i]; end else begin strC:=strC+str[i]; end; end; result:=strC; end; function Tfrm_op_seae_edi_nbcd.FormatListString(Old:TStrings;mCount,Strlength:integer):String; var i:integer; NewStrs:TStrings; mStr:String; begin Result:=''; NewStrs:=TStringList.Create; for i:=0 to old.Count-1 do begin if Length(old.Strings[i])<=Strlength then begin NewStrs.Add(old.Strings[i]); end else begin mStr:=old.Strings[i]; while length(mStr)>Strlength do begin newStrs.Add(copy(mStr,1,Strlength)); system.Delete(mStr,1,Strlength); end; newStrs.Add(mStr); end; end; try for i:=0 to mCount-1 do begin if i4 then begin result:=false; MessageDlg('危险品编号必须是4位数字',mtWarning,[mbOk],0); exit; end; end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='R' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring)='' then begin result:=false; MessageDlg('设置温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)='' then begin result:=false; MessageDlg('冷藏通风量不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring)='' then begin result:=false; MessageDlg('最低温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring)='' then begin result:=false; MessageDlg('最高温度不能为空',mtWarning,[mbOk],0); exit; end; end; if bsSkinRadioGroup2.ItemIndex=1 then begin s_error:=''; sl_error.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); for i:=0 to sl_error.Count-1 do begin if IsZhongwen(sl_error[i]) then begin result:=false; if s_error='' then s_error:='EDI信息中发货人中有中文字符或TAB键或*!' else s_error:=s_error+#13#10+'EDI信息中发货人中有中文字符或TAB键或*!'; end; if Length(sl_error[i])>34 then begin result:=false; if s_error='' then s_error:='发货人中每行字符不能超过34个字符或*!' else s_error:=s_error+#13#10+'发货人中每行字符不能超过34个字符或*!'; end; end; Lines:=''; Lines:=ControlLines(sl_error.Count,1,0,'发货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; if s_error='' then s_error:='EDI信息中'+Lines+'!' else s_error:=s_error+#13#10+'EDI信息中'+Lines+'!'; end; if s_error<>'' then begin MessageDlg(s_error,mtWarning,[mbOk],0); Exit; end; s_error:=''; sl_error.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); for i:=0 to sl_error.Count-1 do begin if IsZhongwen(sl_error[i]) then begin result:=false; if s_error='' then s_error:='EDI信息中收货人中有中文字符或TAB键或*!' else s_error:=s_error+#13#10+'EDI信息中收货人中有中文字符或TAB键或*!'; end; if Length(sl_error[i])>34 then begin result:=false; if s_error='' then s_error:='收货人中每行字符不能超过34个字符或*!' else s_error:=s_error+#13#10+'收货人中每行字符不能超过34个字符或*!'; end; end; Lines:=''; Lines:=ControlLines(sl_error.Count,1,0,'收货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; if s_error='' then s_error:='EDI信息中'+Lines+'!' else s_error:=s_error+#13#10+'EDI信息中'+Lines+'!'; end; if s_error<>'' then begin MessageDlg(s_error,mtWarning,[mbOk],0); Exit; end; s_error:=''; sl_error.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); for i:=0 to sl_error.Count-1 do begin if IsZhongwen(sl_error[i]) then begin result:=false; if s_error='' then s_error:='EDI信息中通知人中有中文字符或TAB键或*!' else s_error:=s_error+#13#10+'EDI信息中通知人中有中文字符或TAB键或*!'; end; if Length(sl_error[i])>34 then begin result:=false; if s_error='' then s_error:='通知人中每行字符不能超过34个字符或*!' else s_error:=s_error+#13#10+'通知人中每行字符不能超过34个字符或*!'; end; end; Lines:=''; Lines:=ControlLines(sl_error.Count,1,0,'通知人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; if s_error='' then s_error:='EDI信息中'+Lines+'!' else s_error:=s_error+#13#10+'EDI信息中'+Lines+'!'; end; if s_error<>'' then begin MessageDlg(s_error,mtWarning,[mbOk],0); Exit; end; end; if bsSkinRadioGroup2.ItemIndex=1 then begin t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; if t_op_ctn.IsEmpty then begin result:=false; MessageDlg('集装箱不能为空',mtWarning,[mbOk],0); exit; end; t_op_ctn.First; while not t_op_ctn.Eof do begin if Trim(t_op_ctn.fieldbyname('箱号').asstring)='' then begin result:=false; MessageDlg('箱号不能为空!',mtWarning,[mbOk],0); exit; end; if Trim(t_op_ctn.fieldbyname('封号').asstring)='' then begin result:=false; MessageDlg('封号不能为空!',mtWarning,[mbOk],0); exit; end; t_op_ctn.Next; end; end; sl_error.Free; end; function Tfrm_op_seae_edi_nbcd.CreateEdiFile:TStrings; var str,sl,sl1:Tstringlist; i,j,Count,l,M:integer; strsql,strRmain,strtemp,S,socstr,fenshu:string; rs:Tadoquery; wide_str:widestring; k:integer; strType:string; strDatetime:string; SenderCode,ReciverCode,zzNo,zzName:string; function GetShipperString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then TempStr.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').AsString) else TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString); GetLengthTString(TempStr,70); Result:='20:'; // Result:=Result+':'; Result:=Result+FormatListString(TempStr,12,70)+''''; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then TempStr.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').AsString) else TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString); GetLengthTString(TempStr,70); Result:='21:'; // Result:=Result+':'; Result:=Result+FormatListString(TempStr,12,70)+''''; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then TempStr.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('通知人代码').AsString) else TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString); GetLengthTString(TempStr,70); Result:='22:'; // Result:=Result+':'; Result:=Result+FormatListString(TempStr,12,70)+''''; finally FreeAndNil(TempStr); end; end; function GetMARKSString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then TempStr.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').AsString) else TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString); GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; function GetRemarksString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(SoRemarks); GetLengthTString(TempStr,70); Result:='70:'; Result:=Result+FormatListString(TempStr,5,70)+''''; finally FreeAndNil(TempStr); end; end; begin // if not isEditrue(frm_op_seae.t_op_seae) then exit; SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; if bsSkinCheckRadioBox2.Checked then if not frm_op_seae_assistant.t_op_seae_assistant.active then frm_op_seae_assistant.t_op_seae_assistant.open; zzNo:=''; zzName:=''; str.Clear; str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+':::3.0'+#39); Count:=0; str.Add('10:' + trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)+':' +'::' + ':'+#39); //船舶经营人 if trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)<>'' then begin zzNo:=GetPortEdiID(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring); zzName:=trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring); end; str.Add ('12:' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring) +':' +':' +':'+trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+SenderCode+'::B:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'::::'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('运输条款').asstring+':' +frm_data_share.t_code_free.fieldbyname('代码').asstring+':'+QUOTATIONNO +':::::::'+#39); end else begin str.Add ('14:'+SenderCode+'::B:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'::::'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('运输条款').asstring+':' +'P:'+QUOTATIONNO +':::::::'+#39); end; end else begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+SenderCode+'::B:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'::::'+frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+':' +frm_data_share.t_code_free.fieldbyname('代码').asstring+':'+QUOTATIONNO +':::::::'+#39); end else begin str.Add ('14:'+SenderCode+'::B:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'::::'+frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+':' +'P:'+QUOTATIONNO +':::::::'+#39); end; end; Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then socstr:='T' else socstr:='F'; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin strsql:='select AS_ID,代码,sum(数量) as 数量 from t_op_ctn_fendan group by AS_ID,代码 having AS_ID=' +#39+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').asstring+#39; end else begin strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; end; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; M:=1; while not rs.Eof do begin str.Add ('40:'+inttostr(M)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':F:::'+ socstr); Count:=Count+1; M:=M+1; rs.Next; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin str.Add ('41:1:'+trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('运输方式').asstring) +':'+trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring) +':' // 第一层包装皮重 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring) +':::::::::' // 第一层包装尺码 +#39); end else begin str.Add ('41:1:'+trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring) +':'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +':::::::::' // 第一层包装尺码 +#39); end; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN str.Add ('43:1:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').AsString) else sl1.Text:=FormatEdiString(frm_op_seae.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; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='44:'+sl.Strings[L]+':'; end else begin if M=5 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').AsString) else sl1.Text:=FormatEdiString(frm_op_seae.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; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+sl.Strings[L]+':'; end else begin if M=5 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); // Str.Add(GetCARGODESCRIPTIONString); Count:=Count+11; strRmain:=''; if trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then begin try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then strsql:='select * from t_op_ctn_fendan where AS_ID=' +#39+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').asstring+#39 else strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; while not rs.Eof do begin str.Add ('48:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':' +Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':F:' +trim(IntToStr(rs.fieldbyname('件数').AsInteger))+trim(GetpkgsEdi(rs.fieldbyname('包装').asstring)) +':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::'+trim(FloatToStr(rs.fieldbyname('尺码').AsFloat))+'''' ); rs.Next; end; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end else begin str.Add('48:::L:::::N'+''''); Count:=Count+1; end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring,[]) then begin str.Add ('60:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring+#39); end else begin str.Add ('60:P:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring+#39); end; Count:=Count+1; end else begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then begin str.Add ('60:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring+#39); end else begin str.Add ('60:P:'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring+#39); end; Count:=Count+1; end; str.Add(GetRemarksString); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单方式').asstring)='正本' then begin strtemp:='ORI'; fenshu:=get_fenshu(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('提单份数').asstring)); END else if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单方式').asstring)='电放' then begin strtemp:='TER'; fenshu:=get_fenshu(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('提单份数').asstring)); end else begin strtemp:='EXP'; fenshu:='0'; end; str.add('71:'+strtemp+':' +GetPortEdiID(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单地点').asstring) )+':' + GetDatetime(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单日期').asstring),0)+':' + fenshu+':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('预付地点').asstring) +':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('预付地点').asstring) +#39); end else begin if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='正本' then begin strtemp:='ORI'; fenshu:=get_fenshu(trim(frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring)); END else if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='电放' then begin strtemp:='TER'; fenshu:=get_fenshu(trim(frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring)); end else begin strtemp:='EXP'; fenshu:='0'; end; str.add('71:'+strtemp+':' +GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) )+':' + GetDatetime(trim(frm_op_seae.t_op_seae.fieldbyname('签单日期').asstring),0)+':' + fenshu+':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring) +#39); end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; function Tfrm_op_seae_edi_nbcd.CreateZHUEdiFile(bstype:integer):TStrings; var str,sl,sl1:Tstringlist; i,j,Count,l,M:integer; first:Boolean; strsql,strRmain,strtemp,strhead:string; rs,aQuery:Tadoquery; wide_str:widestring; k:integer; strType,s:string; strDatetime:string; SenderCode,ReciverCode:string; function GetRemarksString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(SoRemarks); GetLengthTString(TempStr,70); Result:='17:'; Result:=Result+FormatListString(TempStr,5,70)+''''; finally FreeAndNil(TempStr); end; end; function GetShipperString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(aQuery.fieldbyname('发货人代码').AsString); GetLengthTString(TempStr,35); Result:='20:'; 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(aQuery.fieldbyname('收货人代码').AsString); GetLengthTString(TempStr,35); Result:='21:'; 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(aQuery.fieldbyname('通知人代码').AsString); GetLengthTString(TempStr,35); Result:='22:'; 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(aQuery.fieldbyname('唛头').AsString); GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; aQuery:=CreateAdoQuery; try aQuery.Close;aQuery.sql.Clear; case bstype of 1:begin //拼箱主票 aQuery.SQL.Add('select * from t_op_seae where 编号=:编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end; 2:begin //拼箱分票 aQuery.SQL.Add('select * from t_op_seae where 编号=:编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae_fen.fieldbyname('编号').asstring; end; 3:begin //所有分票 aQuery.SQL.Add('select * from t_op_seae where 主编号=:编号 and 主编号<>编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end; end; aQuery.Open; if not aQuery.IsEmpty then begin if not isEditrue(aQuery) then exit; aQuery.first; first:=true; while not aQuery.eof do begin if first then begin str.Add ('02:'+ trim(aQuery.fieldbyname('委托编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +':' + trim(t_op_ams.fieldbyname('订舱人说明').asstring) +':' +':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); { str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +'::' + CarrName+':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); } end else begin str.Add ('02:'+ trim(aQuery.fieldbyname('委托编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +':' + trim(t_op_ams.fieldbyname('订舱人说明').asstring) +':' + ':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); { str.Add ('02:'+ trim(aQuery.fieldbyname('业务编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +'::' + ReciverCode +':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':::'+ #39); } end; if trim(aQuery.fieldbyname('签单方式').asstring)='正本' then strtemp:='ORI' else strtemp:='EXP'; str.add('03:'+strtemp+':' +GetPortEdiID(trim(aQuery.fieldbyname('签单地点').asstring) )+':' + trim(aQuery.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(aQuery.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(trim(aQuery.fieldbyname('提单份数').asstring))+':' + trim(aQuery.fieldbyname('预付地点').asstring) +':' + trim(aQuery.fieldbyname('预付地点').asstring) +#39); str.Add('11:' + trim(frm_op_seae.t_op_seae.fieldbyname('发货人编号').asstring)+':' + trim(aQuery.fieldbyname('船名').asstring) +':' + trim(aQuery.fieldbyname('航次').asstring)+':' +'::' + ReciverCode +':' + '::::::' +#39); //船舶经营人 str.Add ('12:'+trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('卸货代码').asstring) +':' +trim(aQuery.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(aQuery.fieldbyname('交货代码').asstring) +':' +trim(aQuery.fieldbyname('交货地点').asstring) +':' +trim(aQuery.fieldbyname('目的地代码').asstring) +':' +trim(aQuery.fieldbyname('目的地').asstring) +#39); if frm_data_share.t_code_free.locate('付费方式',aQuery.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; Str.Add(GetRemarksString); Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); str.Add ('41:1::'+trim(aQuery.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(aQuery.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(aQuery.fieldbyname('包装').asstring))+':' +trim(aQuery.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(aQuery.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(aQuery.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); IF trim(aQuery.fieldbyname('货物标识').asstring)='R'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(aQuery.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(aQuery.fieldbyname('设置温度').asstring) +':' +trim(aQuery.fieldbyname('最低温度').asstring) +':' +trim(aQuery.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(aQuery.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(aQuery.fieldbyname('危险品分类').asstring) +':' +':' +trim(aQuery.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; Str.Add(GetMARKSString); // Str.Add(GetCARGODESCRIPTIONString); sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString); GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+11; strRmain:=''; case bstype of 1: begin //拼箱主票 strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39 end; 2,3: begin strRmain:=strRmain+'L:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'+':'+':'+':'+'N'+#39 end; end; strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; { strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; while not rs.Eof do begin str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('尺寸').asstring,rs.fieldbyname('箱型').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+'''' ); rs.Next; end; end; end; } rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; aQuery.Next; first:=False; end; end; finally FreeAndNil(aQuery); end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; function Tfrm_op_seae_edi_nbcd.CreateSIEdiFile:TStrings; var str,sl,sl1:Tstringlist; i,j,Count,l,M:integer; strsql,strRmain,strtemp,S,fenshu:string; rs:Tadoquery; wide_str,str_shr,str_con,str_not:widestring; k:integer; strType:string; strDatetime:string; SenderCode,ReciverCode:string; firstcon:boolean; function GetRemarksString:String; var TempStr:TStringlist; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(SIRemarks); GetLengthTString(TempStr,70); Result:='17:'; Result:=Result+FormatListString(TempStr,5,70)+''''; finally FreeAndNil(TempStr); end; end; function GetAMSSHIPPERString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(t_op_ams.fieldbyname('AMS发货人').AsString); GetLengthTString(TempStr,35); Result:='23:'; Result:=Result+trim(t_op_ams.fieldbyname('真实签约人代码').AsString)+':'; Result:=Result+FormatListString(TempStr,6,35)+''''; finally FreeAndNil(TempStr); end; end; begin if not isEditrue(frm_op_seae.t_op_seae) then exit; SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; if bsSkinCheckRadioBox2.Checked then if not frm_op_seae_assistant.t_op_seae_assistant.active then frm_op_seae_assistant.t_op_seae_assistant.open; str.Clear; str.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin str.Add ('02:'+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('委托编号').asstring) //2 +':'+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring) //3 +':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('运输条款').asstring) //4 +':'+ trim(t_op_ams.fieldbyname('订舱人说明').asstring) //5 +':' //6 +':' //7 +':' //8 +':' //9 +':' // 10 +':' //11 +':' // 12 +':' // 13 +':'+QUOTATIONNO // 14 +':' //15 +':'+ trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) // 16 +':' // 17 +':' // 18 + #39); //内部航次号 end else begin str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring) //2 +':'+ trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) //3 +':' +trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) //4 +':'+ trim(t_op_ams.fieldbyname('订舱人说明').asstring) //5 +':' //6 +':' //7 +':' //8 +':' //9 +':' // 10 +':' //11 +':' // 12 +':' // 13 +':'+QUOTATIONNO // 14 +':' //15 +':'+ trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) // 16 +':' // 17 +':' // 18 + #39); //内部航次号 end; { str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring) +':'+ trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':'+ trim(t_op_ams.fieldbyname('订舱人说明').asstring)+':' +CarrName+':' +':::::::' +':'+QUOTATIONNO +'::'+ #39); } if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='正本' then begin strtemp:='ORI'; fenshu:=get_fenshu(trim(frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring)); end else begin strtemp:='EXP'; fenshu:='0'; end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin str.add('03:'+strtemp+':' +GetPortEdiID(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单地点').asstring) )+':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('签单日期').asstring),0)+':' + fenshu+':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('预付地点').asstring) +':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('预付地点').asstring) +#39); end else begin str.add('03:'+strtemp+':' +GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) )+':' + trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(frm_op_seae.t_op_seae.fieldbyname('签单日期').asstring),0)+':' + fenshu+':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring) +#39); end; str.Add('11:' + trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)+':' +'::' + ReciverCode +':' + '::::::' +#39); //船舶经营人 if UpperCase(trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring))='CY-CY' then begin str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +':'+':'+':'+':'+':'+#39); end else begin str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; end else begin if frm_data_share.t_code_free.locate('付费方式',frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; end; Str.Add(GetRemarksString); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').asstring) else sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); GetLengthTString(sl1,35); strtemp:='20:general:'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; s:=''; strtemp:=strtemp+':'+GetLengthword(s,34,sl1[4])+'?+'; Str_shr:='?+'+S; for j:=5 to sl1.Count-1 do begin Str_shr:=Str_shr+' '+sl1[j] end; { strtemp:=strtemp+':'+Copy(sl1[4],1,34)+'*'; Str_shr:='*'+Copy(sl1[4],34,1); for j:=5 to sl1.Count-1 do begin Str_shr:=Str_shr+' '+sl1[j] end; } end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').asstring) else sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); GetLengthTString(sl1,35); strtemp:='21:general:'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; s:=''; strtemp:=strtemp+':'+GetLengthword(s,33,sl1[4])+'?+?+'; Str_con:='?+?+'+S; for j:=5 to sl1.Count-1 do begin Str_con:=Str_con+' '+sl1[j] end; { strtemp:=strtemp+':'+Copy(sl1[4],1,33)+'**'; Str_con:='**'+Copy(sl1[4],33,2); for j:=5 to sl1.Count-1 do begin Str_con:=Str_con+' '+sl1[j] end; } end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('通知人代码').asstring) else sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); GetLengthTString(sl1,35); strtemp:='22:general:'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; s:=''; strtemp:=strtemp+':'+GetLengthword(s,32,sl1[4])+'?+?+?+'; Str_not:='?+?+?+'+S; for j:=5 to sl1.Count-1 do begin Str_not:=Str_not+' '+sl1[j] end; { strtemp:=strtemp+':'+Copy(sl1[4],1,32)+'***'; Str_not:='***'+Copy(sl1[4],32,3); for j:=5 to sl1.Count-1 do begin Str_not:=Str_not+' '+sl1[j] end; } end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; if (t_op_ams.fieldbyname('真实签约人代码').AsString<>'') or (t_op_ams.fieldbyname('AMS发货人').AsString<>'') then Str.Add(GetAMSSHIPPERString); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin str.Add ('41:1:'+trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('运输方式').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))+':' +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); end else begin str.Add ('41:1:'+trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); end; { str.Add ('41:1::'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); } IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asstring) else sl.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString); GetLengthTString(sl,22); M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+sl.Strings[L]+':'; end else begin if M=10 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring) else sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString); if str_shr<>'' then begin sl1.Add(str_shr) end; if str_con<>'' then begin sl1.Add(str_con) end; if str_not<>'' then begin sl1.Add(str_not) end; GetLengthTString(sl1,45); sl.text:=''; for L:=0 to sl1.Count-1 do begin sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+sl.Strings[L]+':'; end else begin if M=5 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); // Str.Add(GetCARGODESCRIPTIONString); Count:=Count+11; strRmain:=''; if trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'F:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'F:'+':'+':'+':'+':'+'N'+#39; end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin strsql:='select AS_ID,代码,sum(数量) as 数量 from t_op_ctn_fendan group by AS_ID,代码 having AS_ID=' +#39+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').asstring+#39; end else strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; if (bsSkinCheckRadioBox2.Checked) and (not frm_op_seae_assistant.t_op_seae_assistant.IsEmpty) then begin strsql:='select * from t_op_ctn_fendan where AS_ID=' +#39+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').asstring+#39; end else strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open; firstcon:=true; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; while not rs.Eof do begin if pos('FR',rs.fieldbyname('箱型').asstring)>0 then begin if firstcon then str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) +':NIL'+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+edit3.Text+'''') else str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) +':NIL'+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+''''); with ADOQueryTemp do begin Close;sql.Clear; SQL.Add('select * from t_op_ctn_detail where ctn_id=:ctn_id'); Parameters.ParamByName('ctn_id').Value:=rs.FieldByName('ctn_id').AsInteger; open;First; while not eof do begin if Trim(FieldByName('hts').AsString)<>'' then begin str.Add('53:'+Trim(FieldByName('hts').AsString)+':::::::'+''''); Count:=Count+1; end; Next; end; end; end else begin if firstcon then str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+edit3.Text+'''') else str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+''''); with ADOQueryTemp do begin Close;sql.Clear; SQL.Add('select * from t_op_ctn_detail where ctn_id=:ctn_id'); Parameters.ParamByName('ctn_id').Value:=rs.FieldByName('ctn_id').AsInteger; open;First; while not eof do begin if Trim(FieldByName('hts').AsString)<>'' then begin str.Add('53:'+Trim(FieldByName('hts').AsString)+':::::::'+''''); Count:=Count+1; end; Next; end; end; end; firstcon:=false; rs.Next; Count:=Count+1; end; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end else begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'L:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39; end; str.Add('48:'+':'+':'+strRmain); Count:=Count+1; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; function Tfrm_op_seae_edi_nbcd.CreateSIZHUEdiFile(bstype:integer):TStrings; var sl,sl1,str:Tstringlist; i,j,Count,l,M:integer; first:Boolean; strsql,strRmain,strtemp:string; rs,aQuery:Tadoquery; wide_str,str_shr,str_con,str_not:widestring; k:integer; strType,s:string; strDatetime:string; SenderCode,ReciverCode:string; function GetRemarksString:String; var TempStr:TStringlist; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(SIRemarks); GetLengthTString(TempStr,70); Result:='17:'; Result:=Result+FormatListString(TempStr,5,70)+''''; finally FreeAndNil(TempStr); end; end; begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; aQuery:=CreateAdoQuery; try aQuery.Close;aQuery.sql.Clear; case bstype of 1:begin //拼箱主票 aQuery.SQL.Add('select * from t_op_seae where 编号=:编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end; 2:begin //拼箱分票 aQuery.SQL.Add('select * from t_op_seae where 编号=:编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae_fen.fieldbyname('编号').asstring; end; 3:begin //所有分票 aQuery.SQL.Add('select * from t_op_seae where 主编号=:编号 and 主编号<>编号 order by 主提单号'); // aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end; end; if not aQuery.IsEmpty then begin if not isEditrue(aQuery) then exit; aQuery.first; first:=true; while not aQuery.eof do begin if bsSkinCheckRadioBox2.Checked then with t_op_seae_assistant do begin Close; SQL.Clear; SQL.Add('select * from t_op_seae_assistant where 编号='''+aQuery.fieldbyname('编号').AsString+''''); open; end; if first then begin str.Add ('02:'+ trim(aQuery.fieldbyname('委托编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +':' + trim(t_op_ams.fieldbyname('订舱人说明').asstring) +':' + ':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); { str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +'::' + CarrName+':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); } end else begin str.Add ('02:'+ trim(aQuery.fieldbyname('委托编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +':' + trim(t_op_ams.fieldbyname('订舱人说明').asstring) +':' + ':' + ':::::::' + '::' + QUOTATIONNO+':' +':'+ #39); { str.Add ('02:'+ trim(aQuery.fieldbyname('业务编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +'::' + ReciverCode +':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':::'+ #39); } end; if trim(aQuery.fieldbyname('签单方式').asstring)='正本' then strtemp:='ORI' else strtemp:='EXP'; str.add('03:'+strtemp+':' +GetPortEdiID(trim(aQuery.fieldbyname('签单地点').asstring) )+':' + trim(aQuery.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(aQuery.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(trim(aQuery.fieldbyname('提单份数').asstring))+':' + trim(aQuery.fieldbyname('预付地点').asstring) +':' + trim(aQuery.fieldbyname('预付地点').asstring) +#39); str.Add('11:' + trim(frm_op_seae.t_op_seae.fieldbyname('发货人编号').asstring)+':' + trim(aQuery.fieldbyname('船名').asstring) +':' + trim(aQuery.fieldbyname('航次').asstring)+':' +'::' + ReciverCode +':' + '::::::' +#39); //船舶经营人 str.Add ('12:'+trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('卸货代码').asstring) +':' +trim(aQuery.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(aQuery.fieldbyname('交货代码').asstring) +':' +trim(aQuery.fieldbyname('交货地点').asstring) +':' +trim(aQuery.fieldbyname('目的地代码').asstring) +':' +trim(aQuery.fieldbyname('目的地').asstring) +#39); if frm_data_share.t_code_free.locate('付费方式',aQuery.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; Str.Add(GetRemarksString); if (bsSkinCheckRadioBox2.Checked) and (not t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(t_op_seae_assistant.fieldbyname('收货人代码').asstring) else sl1.Text:=FormatEdiString(aQuery.fieldbyname('发货人代码').asstring); GetLengthTString(sl1,35); strtemp:='20::'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; strtemp:=strtemp+':'+Copy(sl1[4],1,34)+'*'; Str_shr:='*'+Copy(sl1[4],34,1); for j:=5 to sl1.Count-1 do begin Str_shr:=Str_shr+' '+sl1[j] end; end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; if (bsSkinCheckRadioBox2.Checked) and (not t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(t_op_seae_assistant.fieldbyname('收货人代码').asstring) else sl1.Text:=FormatEdiString(aQuery.fieldbyname('收货人代码').asstring); GetLengthTString(sl1,35); strtemp:='21::'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; strtemp:=strtemp+':'+Copy(sl1[4],1,33)+'**'; Str_con:='**'+Copy(sl1[4],33,2); for j:=5 to sl1.Count-1 do begin Str_con:=Str_con+' '+sl1[j] end; end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; if (bsSkinCheckRadioBox2.Checked) and (not t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(t_op_seae_assistant.fieldbyname('通知人代码').asstring) else sl1.Text:=FormatEdiString(aQuery.fieldbyname('通知人代码').asstring); GetLengthTString(sl1,35); strtemp:='22::'+sl1[0]+':'; if sl1.Count>=2 then strtemp:=strtemp+sl1[1]; if (sl1.Count>=3) and (sl1.Count<=5) then begin for j:=2 to sl1.Count-1 do begin strtemp:=strtemp+':'+sl1[j] end; end; if sl1.Count>5 then begin for j:=2 to 3 do begin strtemp:=strtemp+':'+sl1[j] end; strtemp:=strtemp+':'+Copy(sl1[4],1,32)+'***'; Str_not:='***'+Copy(sl1[4],32,3); for j:=5 to sl1.Count-1 do begin Str_not:=Str_not+' '+sl1[j] end; end; strtemp:=strtemp+#39; str.Add(strtemp); count:=count+1; str.Add ('41:1::'+trim(aQuery.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(aQuery.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(aQuery.fieldbyname('包装').asstring))+':' +trim(aQuery.fieldbyname('包装').asstring) +':' //第一层包装说明 +CARGOGROSSWT +':' //第一层包装说明 +trim(aQuery.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(aQuery.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); IF trim(aQuery.fieldbyname('货物标识').asstring)='R'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(aQuery.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(aQuery.fieldbyname('设置温度').asstring) +':' +trim(aQuery.fieldbyname('最低温度').asstring) +':' +trim(aQuery.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(aQuery.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(aQuery.fieldbyname('危险品分类').asstring) +':' +':' +trim(aQuery.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; if (bsSkinCheckRadioBox2.Checked) and (not t_op_seae_assistant.IsEmpty) then sl.Text:=FormatEdiString(t_op_seae_assistant.fieldbyname('唛头').asstring) else sl.Text:=FormatEdiString(aQuery.fieldbyname('唛头').AsString); GetLengthTString(sl,22); M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=10 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); if (bsSkinCheckRadioBox2.Checked) and (not t_op_seae_assistant.IsEmpty) then sl1.Text:=FormatEdiString(t_op_seae_assistant.fieldbyname('货物描述').asstring) else sl1.Text:=FormatEdiString(aQuery.fieldbyname('货物描述').AsString); GetLengthTString(sl1,45); sl.text:=''; for L:=0 to sl1.Count-1 do begin sl.Add(sl1.Strings[L]); end; if str_shr<>'' then begin sl.Add(str_shr) end; if str_con<>'' then begin sl.Add(str_con) end; if str_not<>'' then begin sl.Add(str_not) end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+11; strRmain:=''; case bstype of 1: begin //拼箱主票 strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39 end; 2,3: begin strRmain:=strRmain+'L:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'+':'+':'+':'+'N'+#39 end; end; strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; while not rs.Eof do begin if pos('FR',rs.fieldbyname('箱型').asstring)>0 then begin str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) +':NIL'+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+edit3.Text+'''' ); end else begin str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat))+':'+edit3.Text+'''' ); end; rs.Next; end; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; aQuery.Next; first:=False; end; end; finally FreeAndNil(aQuery); end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; function Tfrm_op_seae_edi_nbcd.GetCntrEdi(cntrsize: String):String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_ctn where 代码='''+cntrsize+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_nbcd.GetpkgsEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_package where 代码='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_nbcd.GetlineEdi(aline: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_trade where 航线='''+aline+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_nbcd.bsSkinButton3Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; inifile1:Tinifile; i:integer; begin if QUOTATIONNO='' then QUOTATIONNO:='0'; if CARGOGROSSWT='' then CARGOGROSSWT:='100'; if SoRemarks='' then SoRemarks:='ABC'; if SIRemarks='' then SIRemarks:='ABC'; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; 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); str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; strL:=Tstringlist.Create; try if bsSkinRadioGroup2.ItemIndex=1 then StrL:=CreateSIEdiFile else StrL:=CreateEdiFile; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!'+StrL[i],mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; end; strL.SaveToFile(str); finally FreeAndNil(StrL) end; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','NBCDSEND',edit1.text); inifile1.WriteString('EDI','NBCDRECIEVE',edit2.text); inifile1.WriteString('EDI','NBCDSENDNAME',edit3.text); inifile1.WriteString('EDI','NBCDFTPSERVER',edit4.text); inifile1.WriteString('EDI','NBCDFTPPATH',edit5.text); inifile1.WriteString('EDI','NBCDFTPNAME',edit6.text); inifile1.WriteString('EDI','NBCDFTPPASS',edit7.text); inifile1.free; showmessage('文件上传成功!'); except deletefile(str); showmessage('文件上传错误!'); end; idftp1.Free; end; procedure Tfrm_op_seae_edi_nbcd.bsSkinButton4Click(Sender: TObject); begin if frm_op_seae_edi_nbcd.Height=335 then frm_op_seae_edi_nbcd.Height:=199 else frm_op_seae_edi_nbcd.Height:=335; end; procedure Tfrm_op_seae_edi_nbcd.FormClose(Sender: TObject; var Action: TCloseAction); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','NBCDSEND',edit1.text); inifile1.WriteString('EDI','NBCDRECIEVE',edit2.text); inifile1.WriteString('EDI','NBCDSENDNAME',edit3.text); inifile1.WriteString('EDI','NBCDFTPSERVER',edit4.text); inifile1.WriteString('EDI','NBCDFTPPATH',edit5.text); inifile1.WriteString('EDI','NBCDFTPNAME',edit6.text); inifile1.WriteString('EDI','NBCDFTPPASS',edit7.text); inifile1.free; end; function Tfrm_op_seae_edi_nbcd.GetShipEdiNO(Ship:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 代码,EDI代码,客户简称,客户全称,揽货人,录入人,录入日期 from t_crm_client'); SQL.Add('where 客户性质<>''目标'' and 船公司=1 and 客户简称='''+Ship+''''); SQL.Add('order by 代码'); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_nbcd.CreateVgmEdiFile:TStrings; var str,sl,sl1:Tstringlist; i,j,Count,l,M:integer; strsql,strRmain,strtemp,S,fenshu:string; rs:Tadoquery; wide_str,str_shr,str_con,str_not:widestring; k:integer; strType,SM,CarrName:string; strDatetime,shipname,shipaddr:string; SenderCode,ReciverCode:string; firstcon:boolean; begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTVGM:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +#39); str.Add('11:' + trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) // +':'+CarrName //+':::::::::' //6---14 +#39); //船舶经营人 str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); Count:=Count+4; if 1=1 then begin strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; if not rs.IsEmpty then begin rs.First; while not rs.Eof do begin if (rs.fieldbyname('称重方式').asstring<>'') or (rs.fieldbyname('称重方式').asstring<>'无') then begin if Trim(rs.fieldbyname('称重方式').asstring)='累加' then SM:='SM2' else if Trim(rs.fieldbyname('称重方式').asstring)='总重' then SM:='SM1'; str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring) //2 +':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) //3 +':'+trim(rs.fieldbyname('封号').asstring) // 4 +':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger)) //5 +':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat)) //6 +'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat)) //78 +'::::::' //9-14 +':'+rs.fieldbyname('称重重量').asstring //15 +':'+GetDatetime(datetimetostr(now),1) //16 +':'+SM //17 +''''); sl.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); shipname:=''; if sl.Count>=1 then shipname:=Copy(sl[0],1,20); shipaddr:=''; if sl.Count>=2 then shipaddr:=sl[1]; str.Add ('58:'+shipname //2 +':'+shipaddr //3 +':' // 4 +':'+emailAddr //5 +':'+emptel //6 +':' //7 +':' //8 +':' //9 +''''); end; rs.Next; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; procedure Tfrm_op_seae_edi_nbcd.bsSkinButton6Click(Sender: TObject); var Str:TStrings; i:integer; begin // if not isEditrue(frm_op_seae.t_op_seae) then exit; try Str:=CreateVgmEdiFile; SaveDialog1.FileName:=frm_op_seae.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_nbcd.bsSkinButton7Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; inifile1:Tinifile; i:integer; begin ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; 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); str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; strL:=Tstringlist.Create; try StrL:=CreateVgmEdiFile; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!'+StrL[i],mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; end; strL.SaveToFile(str); finally FreeAndNil(StrL) end; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','NBCDSEND',edit1.text); inifile1.WriteString('EDI','NBCDRECIEVE',edit2.text); inifile1.WriteString('EDI','NBCDSENDNAME',edit3.text); inifile1.WriteString('EDI','NBCDFTPSERVER',edit4.text); inifile1.WriteString('EDI','NBCDFTPPATH',edit5.text); inifile1.WriteString('EDI','NBCDFTPNAME',edit6.text); inifile1.WriteString('EDI','NBCDFTPPASS',edit7.text); inifile1.free; showmessage('文件上传成功!'); except deletefile(str); showmessage('文件上传错误!'); end; idftp1.Free; end; end.