unit u_op_seae_edi_tsl; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls,inifiles, DB, ADODB,IdFTP,IdFTPCommon, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, Menus; type TCarrier = Record //消息客户端消息结构 EdiNo :String; CarrierName :String; end; Tfrm_op_seae_edi_tsl = class(TForm) Label2: TLabel; Label1: TLabel; Edit2: TEdit; Edit1: TEdit; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsBusinessSkinForm1: TbsBusinessSkinForm; SaveDialog1: TSaveDialog; Label3: TLabel; Label4: TLabel; Edit3: TEdit; Edit4: TEdit; t_op_ctn: TADOQuery; Label5: TLabel; Label6: TLabel; Label7: TLabel; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; RadioGroup1: TRadioGroup; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; GroupBox1: TGroupBox; Label8: TLabel; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Label9: TLabel; Label10: TLabel; Edit11: TEdit; Label11: TLabel; RadioGroup2: TRadioGroup; t_op_edi: TADOQuery; Label12: TLabel; Edit12: TEdit; RadioGroup3: TRadioGroup; bsck: TbsSkinCheckRadioBox; t_op_edictn: TADOQuery; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; Label13: TLabel; Edit13: TEdit; IdFTP1: TIdFTP; bsSkinButton7: TbsSkinButton; PopupMenu3: TPopupMenu; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N1: TMenuItem; CMA1: TMenuItem; INTTRA1: TMenuItem; N2: TMenuItem; CARGO1: TMenuItem; N3: TMenuItem; N4: TMenuItem; CMA2: TMenuItem; Label14: TLabel; Edit14: TEdit; GroupBox2: TGroupBox; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; Edit15: TEdit; Edit16: TEdit; Edit17: TEdit; Edit18: TEdit; CheckBox1: TCheckBox; Edit19: TEdit; Label19: TLabel; Edit20: TEdit; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; procedure bsSkinButton1Click(Sender: TObject); procedure FormShow(Sender: TObject); function get_txtBooking(str:Tstringlist):integer; function get_txtSI(str:Tstringlist):integer; function get_goods(str:widestring):widestring; procedure bsSkinButton3Click(Sender: TObject); function get_txtvgm_cargo(str:Tstringlist):integer; function get_txtvgm_intrra(str:Tstringlist):integer; function get_txtvgm_cma(str:Tstringlist):integer; function isEditrue:boolean; function GetCtnCode(ctnkind,ctnsize:String):String; function GetPkgCode(Pkg:String):String; function GetPort(PortID:String): String; function GetLoadPortEdiID(Port:String): String; function GetPortEdiID(Port:String): String; function GetShipEdiNO(Ship:String): String; function Changestr(str:widestring):string; function GetCtnGoods(bsno:String):String; function GetLengthword(var s: String; l: Integer;str:String): String; procedure GetLengthTString(var sl:TStringList;l:integer); function GetStrNum(str:String):integer; function GetCharNum(str:String):integer; function IsZhongwen(Str:String):Boolean; procedure bsSkinButton4Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure RadioGroup2Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N34Click(Sender: TObject); procedure CARGO1Click(Sender: TObject); procedure INTTRA1Click(Sender: TObject); procedure CMA1Click(Sender: TObject); procedure CMA2Click(Sender: TObject); private { Private declarations } public { Public declarations } aCarrier:TCarrier; SelectCarrier:Boolean; function ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String; function GetCarrier(i:integer):TCarrier; function GetcntCount:string; end; var frm_op_seae_edi_tsl: Tfrm_op_seae_edi_tsl; implementation uses u_op_seae, my_sys_function, u_main, u_data_share, u_op_seae_assistant; {$R *.dfm} function Tfrm_op_seae_edi_tsl.GetcntCount:string; var aAdoQuery:TAdoQuery; begin result:='0'; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try if not bsck.Checked then begin Close;t_op_ctn.SQL.Clear; SQL.Add('SELECT sum(t_op_ctn.数量) 数量'); SQL.Add('FROM t_op_ctn'); SQL.Add('WHERE t_op_ctn.编号=:编号'); Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin Close;SQL.Clear; SQL.Add('SELECT sum(t_op_ctn_fendan.数量) 数量'); SQL.Add('FROM t_op_ctn_fendan'); SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; Open; if IsEmpty then result:='0' else result:=fieldbyname('数量').AsString; finally Free; end; end; function Tfrm_op_seae_edi_tsl.GetCarrier(i:integer):TCarrier; begin case RadioGroup2.ItemIndex of 0:begin //msk Result.EdiNo:='MAEU'; Result.CarrierName:='MAERSK LINE'; end; 1:begin //mcc Result.EdiNo:='MCCQ'; Result.CarrierName:='MCC TRANSPORT SINGAPORE'; end; 2:begin //ANL Result.EdiNo:='ANNU'; Result.CarrierName:='ANL CONTAINER LINE'; end; 3:begin //CMA Result.EdiNo:='CMDU'; Result.CarrierName:='CMA CGM'; end; 4:begin //CNC Result.EdiNo:='CHNL'; Result.CarrierName:='CNC'; end; 5:begin //HL Result.EdiNo:='HLCU'; Result.CarrierName:='HAPAG-LLOYD'; end; 6:begin //MASK Result.EdiNo:='MAEU'; Result.CarrierName:='MAERSK LINE'; end; 7:begin // HAM Result.EdiNo:='SUDU'; Result.CarrierName:='HAMBURG'; end; 8:begin // HAM Result.EdiNo:='MSCU'; Result.CarrierName:='MSC'; end; 9:begin // HAM Result.EdiNo:='DAAE'; Result.CarrierName:='DELMAS'; end; 10:begin // UASC Result.EdiNo:='UASC'; Result.CarrierName:='UASC'; end; 11:begin // COSU Result.EdiNo:='COSU'; Result.CarrierName:='COSCO'; end; 12:begin // COSU Result.EdiNo:='OOLU'; Result.CarrierName:='OOCL'; end; end; end; function Tfrm_op_seae_edi_tsl.ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String; begin Result:=''; if LinesCount>5 then begin if RadioGroup2.ItemIndex=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; 3:begin case BsTypeid of 0: Result:=SName+'详细信息不能超过5行'; 1: Result:=SName+'详细信息不能超过5行'; end; end; end; end else 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; 3:begin case BsTypeid of 0: Result:=SName+'详细信息不能超过5行'; 1: Result:=SName+'详细信息不能超过5行'; end; end; end; end; end; end; function Tfrm_op_seae_edi_tsl.GetCtnGoods(bsno:String):String; var at_op_ctn,at_op_ctndetail :TADOQuery; ctnlist:TStringList; b_ctncount:Boolean; begin result:=''; at_op_ctn:=CreateAdoQuery; at_op_ctndetail:=CreateAdoQuery; ctnlist:=TStringList.Create; ctnlist.Clear; with at_op_ctn do begin Close;SQL.Clear; SQL.Add('select ctn_id from t_op_ctn'); SQL.Add('where 编号=:bsno'); Parameters.ParamByName('bsno').Value:=bsno; open;First; while not eof do begin ctnlist.Add(FieldByName('ctn_id').AsString); Next; end; end; if Trim(ctnlist.CommaText)<>'' then with at_op_ctndetail do begin Close;SQL.Clear; SQL.Add('select count(ctn_id) ctn_id from t_op_ctn_detail'); SQL.Add('where ctn_id in ('+ctnlist.CommaText+')'); Open; if FieldByName('ctn_id').AsInteger>0 then b_ctncount:=True; end; if b_ctncount then begin with at_op_ctndetail do begin Close;SQL.Clear; SQL.Add('select ctn_id,sum(件数)件数,sum(重量) 重量,sum(尺码) 尺码 from t_op_ctn_detail'); SQL.Add('where ctn_id=:ctn_id'); SQL.Add('Group by ctn_id'); end; with at_op_ctn do begin Close;SQL.Clear; SQL.Add('select ctn_id,件数,重量,尺码 from t_op_ctn'); SQL.Add('where 编号=:bsno'); Parameters.ParamByName('bsno').Value:=bsno; open;First; while not eof do begin at_op_ctndetail.Close; at_op_ctndetail.Parameters.ParamByName('ctn_id').Value:=FieldByName('ctn_id').AsInteger; at_op_ctndetail.Open; if at_op_ctndetail.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then begin if Trim(result)='' then result:='分箱件数合计:'+at_op_ctndetail.FieldByName('件数').AsString+'不等于箱总件数:'+FieldByName('件数').AsString else result:=result+#13#10+'分箱件数合计:'+at_op_ctndetail.FieldByName('件数').AsString+'不等于箱总件数:'+FieldByName('件数').AsString; end; if at_op_ctndetail.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then begin if Trim(result)='' then result:='分箱重量合计:'+at_op_ctndetail.FieldByName('重量').AsString+'不等于箱总重量:'+FieldByName('重量').AsString else result:=result+#13#10+'分箱重量合计:'+at_op_ctndetail.FieldByName('重量').AsString+'不等于箱总重量:'+FieldByName('重量').AsString; end; if at_op_ctndetail.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then begin if Trim(result)='' then result:='分箱尺码合计:'+at_op_ctndetail.FieldByName('尺码').AsString+'不等于箱总尺码:'+FieldByName('尺码').AsString else result:=result+#13#10+'分箱尺码合计:'+at_op_ctndetail.FieldByName('尺码').AsString+'不等于箱总尺码:'+FieldByName('尺码').AsString; end; Next; end; end; end; try finally at_op_ctn.Free; at_op_ctndetail.Free; end; end; function Tfrm_op_seae_edi_tsl.isEditrue: boolean; var cntrs,s,Edis,cntrGoods,Goods,Lines:String; sl:TStringList; i:integer; begin result:=true; SelectCarrier:=False; sl:=TStringList.Create; t_op_edi.Close; t_op_edi.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_edi.Open; if Edit1.Text='' then begin if trim(Edis)='' then Edis:='发送方代码' else Edis:=Edis+','+'发送方代码'; end; if Edit2.Text='' then begin if trim(Edis)='' then Edis:='发送方名称' else Edis:=Edis+','+'发送方名称'; end; if Edit3.Text='' then begin if trim(Edis)='' then Edis:='接受方代码' else Edis:=Edis+','+'接受方代码'; end; if Edit4.Text='' then begin if trim(Edis)='' then Edis:='接受方名称' else Edis:=Edis+','+'接受方名称'; end; if Edit5.Text='' then begin if trim(Edis)='' then Edis:='固定电话' else Edis:=Edis+','+'固定电话'; end; if Edit7.Text='' then begin if trim(Edis)='' then Edis:='联系人' else Edis:=Edis+','+'联系人'; end; if Edit6.Text='' then begin if trim(Edis)='' then Edis:='邮件地址' else Edis:=Edis+','+'邮件地址'; end; if Edit12.Text='' then begin if trim(Edis)='' then Edis:='邮件地址' else Edis:=Edis+','+'邮件地址'; end; if CheckBox1.Checked then begin if Edit19.Text='' then begin if trim(Edis)='' then Edis:='货代代码' else Edis:=Edis+','+'货代代码'; end; if Edit20.Text='' then begin if trim(Edis)='' then Edis:='货代名称' else Edis:=Edis+','+'货代名称'; end; end; if trim(Edis)<>'' then begin result:=false; MessageDlg(trim(Edis)+'不能为空',mtWarning,[mbOk],0); // exit; end; if RadioGroup2.ItemIndex=5 then begin if trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring)='' then begin result:=false; MessageDlg('HL 货类代码不能为空',mtWarning,[mbOk],0); end; end else begin if trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring)='' then begin MessageDlg('注意货类代码为空',mtWarning,[mbOk],0); end; end; if not bsck.Checked then begin if trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)='' then begin result:=false; MessageDlg('提单号不能为空',mtWarning,[mbOk],0); // exit; end; end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring)='' then begin result:=false; MessageDlg('分单提单号不能为空',mtWarning,[mbOk],0); // exit; end; end; if trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)='' then begin result:=false; MessageDlg('付费方式不能为空',mtWarning,[mbOk],0); // exit; end; if RadioGroup1.ItemIndex=1 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; end; if trim(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)='' then begin result:=false; MessageDlg('船公司不能为空',mtWarning,[mbOk],0); // exit; end else begin if GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)='' then begin result:=false; MessageDlg('船公司EDI代码不能为空',mtWarning,[mbOk],0); // exit; end; end; aCarrier:=GetCarrier(RadioGroup2.ItemIndex); if aCarrier.EdiNo<>GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring) then begin if MessageDlg('选择的船公司为:'+aCarrier.CarrierName+' 系统录入的船公司为:'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#13#10+',要以选择的船公司发送吗?',mtWarning,[mbyes,mbno],0)=mryes then begin SelectCarrier:=true; end; end; if not bsck.Checked then begin if trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString)='' then begin if MessageDlg('注意EDI备注为空,继续发送吗?',mtWarning,[mbyes,mbno],0)=mrNO then begin result:=false; end; end; if pos(':',frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString)>0 then begin result:=false; MessageDlg('EDI备注中不能有 : 字符',mtWarning,[mbOk],0); end; end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString)='' then begin if MessageDlg('注意EDI备注为空,继续发送吗?',mtWarning,[mbyes,mbno],0)=mrNO then begin result:=false; end; end; if pos(':',frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString)>0 then begin result:=false; MessageDlg('EDI备注中不能有 : 字符',mtWarning,[mbOk],0); // exit; end; end; if not bsck.Checked then begin if bsSkinCheckRadioBox1.Checked then begin if Pos('PLEASE BOOK OCEAN CARRIER',trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString))<=0 then begin ShowMessage('请在EDI备注中输入:PLEASE BOOK OCEAN CARRIER - 船公司名称'); begin result:=false; end; end; end; end else begin if bsSkinCheckRadioBox1.Checked then begin if Pos('PLEASE BOOK OCEAN CARRIER',trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString))<=0 then begin ShowMessage('请在EDI备注中输入:PLEASE BOOK OCEAN CARRIER - 船公司名称'); begin result:=false; end; end; end; end; { if trim(frm_op_seae.t_op_seae.fieldbyname('总价').asstring)='' then begin result:=false; MessageDlg('第一层包装皮重不能为空',mtWarning,[mbOk],0); exit; end; } //第二通知人 sl.Clear; sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('第二通知人').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中第二通知人中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('第二通知人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); end; end; if sl.Count>5 then begin result:=false; MessageDlg('第二通知人不能大于5行!',mtWarning,[mbOk],0); end; sl.Clear; if t_op_edi.fieldbyname('所在国家').AsString<>'' then begin sl.Text:=Changestr(t_op_edi.fieldbyname('AMS发货人').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin MessageDlg('EDI信息中发货人中有中文字符或TAB键!',mtWarning,[mbOk],0); result:=false; // Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('EDI信息中发货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,0,0,'AMS发货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end else begin sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中发货人中有中文字符或TAB键!',mtWarning,[mbOk],0); // Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('发货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,0,0,'发货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; if bsck.Checked then begin sl.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('分单EDI信息中发货人中有中文字符或TAB键!',mtWarning,[mbOk],0); // Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('分单发货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,0,1,'发货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('分单EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; sl.Clear; if t_op_edi.fieldbyname('所在国家').AsString<>'' then begin sl.Text:=Changestr(t_op_edi.fieldbyname('AMS收货人').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中收货人中有中文字符或TAB键!',mtWarning,[mbOk],0); // Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('EDI信息中收货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,1,0,'AMS收货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end else begin sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中收货人中有中文字符或TAB键!',mtWarning,[mbOk],0); // Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('收货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,1,0,'收货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; sl.Clear; sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('代理内容').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中代理中有中文字符或TAB键!',mtWarning,[mbOk],0); Exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('代理每行字符不能超过35个字符!',mtWarning,[mbOk],0); exit; end; end; Lines:=ControlLines(sl.Count,3,0,'代理内容'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-DOOR' then begin IF frm_op_seae.t_op_seae.fieldbyname('DOOR地址').asstring='' then begin result:=false; MessageDlg('运输条款为:CY-DOOR,SHIPPING TO地址不能为空 ',mtWarning,[mbOk],0); // exit; end; sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('DOOR地址').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中SHIPPING TO地址中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('SHIPPING TO地址中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; end; if bsck.Checked then begin sl.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('分单EDI信息中收货人中有中文字符或TAB键!',mtWarning,[mbOk],0); // exit; end; if Length(sl[i])>35 then begin result:=false; MessageDlg('分单收货人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,1,1,'收货人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('分单EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; sl.Clear; if t_op_edi.fieldbyname('所在国家').AsString<>'' then begin sl.Text:=Changestr(t_op_edi.fieldbyname('AMS通知人').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin MessageDlg('EDI信息中通知人中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('EDI信息中通知人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,2,0,'AMS通知人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end else begin sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中通知人中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('通知人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,2,0,'通知人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; if bsck.Checked then begin sl.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('通知人代码').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('分单EDI信息中通知人中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('分单通知人中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; Lines:=ControlLines(sl.Count,2,1,'通知人'); //LinesCount,CorpTypeid,BsTypeid:Integer;SName:string if Lines<>'' then begin result:=false; MessageDlg('分单EDI信息中'+Lines+'!',mtWarning,[mbOk],0); // Exit; end; end; sl.Clear; sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('唛头').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中唛头有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('唛头中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; sl.Clear; sl.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('货物描述').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('EDI信息中货物描述有中文字符或TAB键!',mtWarning,[mbOk],0); end; end; if bsck.Checked then begin sl.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('分单EDI信息中唛头中有中文字符或TAB键!',mtWarning,[mbOk],0); end; if Length(sl[i])>35 then begin result:=false; MessageDlg('分单唛头中每行字符不能超过35个字符!',mtWarning,[mbOk],0); // exit; end; end; end; if bsck.Checked then begin sl.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring); for i:=0 to sl.Count-1 do begin if IsZhongwen(sl[i]) then begin result:=false; MessageDlg('分单EDI信息中货物描述中有中文字符或TAB键!',mtWarning,[mbOk],0); end; end; end; FreeAndNil(sl); if trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)='' then begin result:=false; MessageDlg('装港代码不能为空',mtWarning,[mbOk],0); end; if Length(trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring))<>5 then begin result:=false; MessageDlg('装港代码必须为5个字符',mtWarning,[mbOk],0); end; { if trim(GetLoadPortEdiID(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring))='' then begin result:=false; MessageDlg('装港代码不能为空,请在起运维护 EDI代码',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 frm_op_seae.t_op_seae.fieldbyname('开船日期').asDateTime<(now-120) then begin result:=false; MessageDlg('开船日期必须在今日的120天内!',mtWarning,[mbOk],0); // exit; end; if RadioGroup1.ItemIndex=1 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; end; { if trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring)='' then begin result:=false; MessageDlg('目的地代码不能为空',mtWarning,[mbOk],0); end; if Length(trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring))<>5 then begin result:=false; MessageDlg('目的地代码必须为5个字符',mtWarning,[mbOk],0); end; if trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)='' then begin result:=false; MessageDlg('目的地不能为空',mtWarning,[mbOk],0); //xit; 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); end; if Length(trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring))<>5 then begin result:=false; MessageDlg('卸货代码必须为五个字符',mtWarning,[mbOk],0); // exit; end; { if trim(GetPortEdiID(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 not bsck.Checked then begin if GetPkgCode(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))='' then begin result:=false; MessageDlg('包装代码不能为空',mtWarning,[mbOk],0); // exit; end; end else begin if GetPkgCode(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))='' then begin result:=false; MessageDlg('包装代码不能为空',mtWarning,[mbOk],0); // exit; end; end; if not bsck.Checked then begin if trim(frm_op_seae.t_op_seae.fieldbyname('货物描述').asstring)='' then begin result:=false; MessageDlg('货物描述不能为空',mtWarning,[mbOk],0); // exit; end; end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring)='' then begin result:=false; MessageDlg('货物描述不能为空',mtWarning,[mbOk],0); // exit; end; end; if not bsck.Checked then begin if trim(frm_op_seae.t_op_seae.fieldbyname('唛头').asstring)='' then begin result:=false; MessageDlg('唛头不能为空',mtWarning,[mbOk],0); // exit; end; end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asstring)='' then begin result:=false; MessageDlg('唛头不能为空',mtWarning,[mbOk],0); // exit; end; end; if not bsck.Checked then begin if frm_op_seae.t_op_seae.fieldbyname('件数').asinteger=0 then begin result:=false; MessageDlg('件数不能为空',mtWarning,[mbOk],0); // exit; end; if frm_op_seae.t_op_seae.fieldbyname('重量').asfloat=0 then begin result:=false; MessageDlg('重量不能为空',mtWarning,[mbOk],0); // exit; end; if frm_op_seae.t_op_seae.fieldbyname('尺码').asfloat=0 then begin result:=false; MessageDlg('尺码不能为空',mtWarning,[mbOk],0); // exit; end; end else begin if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asinteger=0 then begin result:=false; MessageDlg('件数不能为空',mtWarning,[mbOk],0); // exit; end; if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asfloat=0 then begin result:=false; MessageDlg('重量不能为空',mtWarning,[mbOk],0); // exit; end; if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asfloat=0 then begin result:=false; MessageDlg('尺码不能为空',mtWarning,[mbOk],0); // exit; end; end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='D' 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 GetStrNum(Trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring))<>4 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 GetStrNum(trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring))<>3 then begin result:=false; MessageDlg('设置温度必须是3位数字',mtWarning,[mbOk],0); // exit; end; end; if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then if (trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)='') or (GetPortEdiID(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)='') then begin //付款地点代码 result:=false; MessageDlg('预付地点(或edi代码)不能为空',mtWarning,[mbOk],0); // exit; end; if Pos('COLLECT',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then if (trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring)='') or (frm_op_seae.t_op_seae.fieldbyname('到付地点代码').asstring='') then begin //付款地点代码 result:=false; MessageDlg('到付地点(或edi代码)不能为空',mtWarning,[mbOk],0); // exit; end; if RadioGroup1.ItemIndex=1 then begin if (trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring)='') or (GetPortEdiID(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring)='') then begin //签单地点代码 result:=false; MessageDlg('签单地点(或edi代码)不能为空',mtWarning,[mbOk],0); // exit; end; 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 not bsck.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn.编号,t_op_ctn.数量, t_code_ctn.EDI代码,t_op_ctn.尺寸,t_op_ctn.包装'); t_op_ctn.SQL.Add(',t_op_ctn.箱型,t_op_ctn.箱号,t_op_ctn.重量,t_op_ctn.封号,t_op_ctn.尺码,t_op_ctn.件数,t_op_ctn.品名'); t_op_ctn.SQL.Add('FROM t_op_ctn INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn.编号=:编号'); t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn_fendan.编号,t_op_ctn_fendan.数量, t_code_ctn.EDI代码,t_op_ctn_fendan.尺寸,t_op_ctn_fendan.包装'); t_op_ctn.SQL.Add(',t_op_ctn_fendan.箱型,t_op_ctn_fendan.箱号,t_op_ctn_fendan.重量,t_op_ctn_fendan.封号,t_op_ctn_fendan.尺码,t_op_ctn_fendan.件数,t_op_ctn_fendan.品名'); t_op_ctn.SQL.Add('FROM t_op_ctn_fendan INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn_fendan.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); t_op_ctn.Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; 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 cntrs:=GetCtnCode(t_op_ctn.fieldByName('箱型').asString,t_op_ctn.fieldByName('尺寸').asString); if cntrs='' then begin result:=false; MessageDlg('集装箱类型EDI代码不存在!',mtWarning,[mbOk],0); // exit; end; if t_op_ctn.fieldByName('品名').asString='' then begin if Goods='' then Goods:=t_op_ctn.fieldByName('箱型').asString+t_op_ctn.fieldByName('尺寸').asString else Goods:=Goods+#13#10+t_op_ctn.fieldByName('箱型').asString+t_op_ctn.fieldByName('尺寸').asString; end; t_op_ctn.next; end; { if trim(Goods)<>'' then MessageDlg('注意'+#13#10+Goods+#13#10+'集装箱货物名称为空!',mtWarning,[mbOk],0); } if RadioGroup1.ItemIndex=1 then begin if t_op_edi.FieldByName('所在国家').asstring='USA' then begin if t_op_edi.FieldByName('舱单申报者').asstring='' then begin result:=false; MessageDlg('舱单申报者不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.FieldByName('舱单申报者').asstring='自己' then begin if t_op_edi.FieldByName('SCAC编号').asstring='' then begin result:=false; MessageDlg('SCAC编号不能为空',mtWarning,[mbOk],0); // exit; end; end; if t_op_edi.FieldByName('收货人邮编').asstring='' then begin result:=false; MessageDlg('收货人邮编不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.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 t_op_edi.FieldByName('所在国家').asstring='CANADA' then begin if t_op_edi.FieldByName('舱单申报者').asstring='' then begin result:=false; MessageDlg('舱单申报者不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.FieldByName('舱单申报者').asstring='自己' then begin if t_op_edi.FieldByName('SCAC编号').asstring='' then begin result:=false; MessageDlg('SCAC编号不能为空',mtWarning,[mbOk],0); // exit; end; end; if t_op_edi.FieldByName('收货人邮编').asstring='' then begin result:=false; MessageDlg('收货人邮编不能为空',mtWarning,[mbOk],0); // exit; end; end; if t_op_edi.FieldByName('所在国家').asstring='BRAZIL' then begin if t_op_edi.FieldByName('收货人国家代码').asstring='' then begin result:=false; MessageDlg('收货人国家代码不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.FieldByName('收货人税号').asstring='' then begin result:=false; MessageDlg('收货人税号不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.FieldByName('收货人国家代码').asstring<>'BR' then begin if t_op_edi.FieldByName('通知人国家代码').asstring='' then begin result:=false; MessageDlg('通知人国家代码不能为空',mtWarning,[mbOk],0); // exit; end; if t_op_edi.FieldByName('通知人税号').asstring='' then begin result:=false; MessageDlg('通知人税号不能为空',mtWarning,[mbOk],0); // exit; end; end; if t_op_edi.FieldByName('货物NCM编号').asstring='' then begin result:=false; MessageDlg('货物NCM编号不能为空',mtWarning,[mbOk],0); // exit; end; end; cntrGoods:=GetCtnGoods(frm_op_seae.t_op_seae.fieldByName('编号').asString); if trim(cntrGoods)<>'' then begin result:=false; MessageDlg(cntrGoods,mtWarning,[mbOk],0); // exit; end; if not bsck.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn.编号,t_op_ctn.数量, t_code_ctn.EDI代码,t_op_ctn.尺寸,t_op_ctn.包装'); t_op_ctn.SQL.Add(',t_op_ctn.箱型,t_op_ctn.箱号,t_op_ctn.重量,t_op_ctn.封号,t_op_ctn.尺码,t_op_ctn.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn.编号=:编号'); t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn_fendan.编号,t_op_ctn_fendan.数量, t_code_ctn.EDI代码,t_op_ctn_fendan.尺寸,t_op_ctn_fendan.包装'); t_op_ctn.SQL.Add(',t_op_ctn_fendan.箱型,t_op_ctn_fendan.箱号,t_op_ctn_fendan.重量,t_op_ctn_fendan.封号,t_op_ctn_fendan.尺码,t_op_ctn_fendan.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn_fendan INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn_fendan.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); t_op_ctn.Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; 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 cntrs:=t_op_ctn.fieldByName('箱号').asString; if GetCtnCode(t_op_ctn.fieldByName('箱型').asstring,t_op_ctn.fieldByName('尺寸').asstring)='' then begin result:=false; MessageDlg('集装箱类型EDI代码不存在!',mtWarning,[mbOk],0); // exit; end; if ((GetStrNum(cntrs))<>7) or ((GetcharNum(cntrs))<>4) then begin result:=false; MessageDlg('集装箱箱号不正确!',mtWarning,[mbOk],0); // exit; end; t_op_ctn.next; end; if t_op_edi.FieldByName('所在国家').asstring='巴西' then begin if frm_op_seae.t_op_seae.fieldByName('总价').asfloat=0 then begin result:=false; MessageDlg('箱皮重不能为空!',mtWarning,[mbOk],0); // exit; end; end; end; end; function Tfrm_op_seae_edi_tsl.get_goods(str:widestring):widestring; var str_all:Tstringlist; r_str:widestring; i:integer; begin str:=Changestr(trim(str)); str_all:=Tstringlist.Create; str_all.Text:=str; for i:=0 to str_all.Count-1 do begin r_str:=r_str+' '+str_all[i]; end; result:=trim(r_str); end; function Tfrm_op_seae_edi_tsl.GetCtnCode(ctnkind,ctnsize:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; ctnsize:=StringReplace(ctnsize,'''','''''',[rfReplaceAll]); try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码 from t_code_ctn where 箱型='''+ctnkind+''' and 尺寸='''+ctnsize+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_tsl.GetPkgCode(Pkg: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 代码='''+pkg+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_tsl.GetPort(PortID:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 港口名称 英文名 from t_code_edi_port where EDI代码='''+PortID+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('英文名').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_tsl.GetLoadPortEdiID(Port:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码 from t_code_loaport 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_tsl.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_tsl.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_tsl.Changestr(str:widestring):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_tsl.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 (str[i]<>' ') 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_tsl.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_tsl.GetStrNum(str:String):integer; var i:integer; begin result:=0; if str='' then exit; for i:=1 to length(Str) do begin if str[i] in ['0','1','2','3','4','5','6','7','8','9'] then result:=result+1; end; end; function Tfrm_op_seae_edi_tsl.GetCharNum(str:String):integer; var i:integer; begin result:=0; if str='' then exit; for i:=1 to length(Str) do begin if str[i] in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] then result:=result+1; end; end; function Tfrm_op_seae_edi_tsl.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(9)) then begin // if (Str[i]>Chr(127)) or (Str[i]=Chr(9)) or (Str[i]='<') or (Str[i]='>') then begin Result:=True; Exit; end; end; end; function Tfrm_op_seae_edi_tsl.get_txtBooking(str:Tstringlist):integer; var str_all,sl:Tstringlist; j,Count,i,k:integer; str_guodu,str_shr,str_con,str_not:widestring; str_pay,Str_head:string; function CutVoyNo(VoyNo:String):String; begin if length(VoyNO)<3 then exit; if Pos('.',VoyNO)>0 then begin Result:=Copy(VoyNO,3,length(VoyNO)-2); end else Result:=VoyNO; end; begin str_all:=Tstringlist.Create; count:=0; str.Add('UNB+UNOC:2+'+Edit1.TEXT+'SO'+':ZZZ+'+Edit3.TEXT +':ZZZ+'+GetDatetime(datetimetostr(now),2)+'+' +frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); count:=count+1; str.Add('UNH+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+'+IFTMIN:D:99B:UN'+#39); count:=count+1; if not bsck.Checked then begin if RadioGroup2.ItemIndex=5 then // HL begin if RadioGroup3.ItemIndex=0 then str.Add('BGM+335+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+'SO+9'+#39) //9原始 5 更新 else str.Add('BGM+335+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+'SO+5'+#39); //9原始 5 更新 end else begin if RadioGroup3.ItemIndex=0 then str.Add('BGM+335+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'SO+9'+#39) //9原始 5 更新 else str.Add('BGM+335+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'SO+5'+#39); //9原始 5 更新 end; end else begin if RadioGroup3.ItemIndex=0 then str.Add('BGM+335+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'SO+9'+#39) //9原始 5 更新 else str.Add('BGM+335+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'SO+5'+#39); //9原始 5 更新 end; count:=count+1; str.Add('DTM+137:'+GetDatetime(datetimetostr(now),1)+':203'+#39); count:=count+1; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='' then begin showmessage('业务编号为:'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring +'的业务运输条款没有输入!!'); result:=-1; exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-DOOR' then begin str.Add('TSR+27+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-CY' then begin str.Add('TSR+28+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-DOOR' then begin str.Add('TSR+29+2'+#39); end; if (trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-CY') or (trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-RAMP') then begin str.Add('TSR+30+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='OTHER' then begin str.Add('TSR+30+2'+#39); end; count:=count+1; if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring); if Pos('COLLECT',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring); if not bsck.Checked then begin case RadioGroup2.ItemIndex of 5 : begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring +' Payable at '+str_pay+' '+ frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+' '+frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring+ ' '+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+ trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString)+#39); end; 12:begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring // +' Payable at '+str_pay+' '+ +frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+ trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString)+#39); end; else begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring +' Payable at '+str_pay+' '+ frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+ trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString)+#39); end; end; end else begin case RadioGroup2.ItemIndex of 12:begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring // +' Payable at '+str_pay+' '+ +frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString)+#39); end; else str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring +' Payable at '+str_pay+' '+ frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString)+#39); end; end; count:=count+1; if not bsck.Checked then str.Add('CNT+7:'+frm_op_seae.t_op_seae.fieldbyname('重量').asstring+':KGM''') else str.Add('CNT+7:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring+':KGM'''); count:=count+1; if not bsck.Checked then str.Add('CNT+11:'+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+'''') else str.Add('CNT+11:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+''''); count:=count+1; if not bsck.Checked then str.Add('CNT+15:'+frm_op_seae.t_op_seae.fieldbyname('尺码').asstring+':MTQ''') else str.Add('CNT+15:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring+':MTQ'''); count:=count+1; if RadioGroup2.ItemIndex=10 then begin str.Add('CNT+16:'+GetcntCount+#39); // count:=count+1; end; if frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring='FREIGHT PREPAID' then begin str.Add('LOC+57+'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+#39); end else if frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring='FREIGHT COLLECT' then begin str.Add('LOC+57+'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点代码').asstring) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring)+#39); end else str.Add('LOC+57+'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+#39); count:=count+1; if (CheckBox1.Checked) then begin str.Add('RFF+FF:'+frm_op_seae.t_op_seae.fieldbyname('订舱单号').asstring+#39); count:=count+1; end; case RadioGroup2.ItemIndex of 5 : begin str.Add('RFF+BM:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39) // str.Add('RFF+ON:'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39) end; else begin if not bsck.Checked then str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39) else str.Add('RFF+BN:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+#39); count:=count+1; if not bsck.Checked then str.Add('RFF+BM:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39) else str.Add('RFF+BM:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+#39); count:=count+1; end; end; str.Add('RFF+CT:'+frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring+#39); // count:=count+1; if RadioGroup2.ItemIndex=10 then begin str.Add('RFF+SI:'+frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring+#39); // count:=count+1; end; if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str.Add('CPI+4++P''') else if Pos('COLLECT',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str.Add('CPI+4++C''') else str.Add('CPI+4++B'''); count:=count+1; if SelectCarrier then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring)<>'' then begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1++'+aCarrier.EdiNo+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1++'+aCarrier.EdiNo+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end; end else begin if Trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring)<>'' then begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1++'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1++'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end; end; str.Add('LOC+9+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('DTM+133:'+GetDatetime(datetimetostr(frm_op_seae.t_op_seae.fieldbyname('开船日期').asDatetime),0)+':102'+#39); count:=count+1; str.Add('LOC+88+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('LOC+11+'+frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+#39); count:=count+1; if trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)<>'' then begin str.Add('LOC+7+'+frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring //? +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)+#39); count:=count+1; end; str_all.Clear; str_head:=''; if not bsck.Checked then begin if t_op_edi.FieldByName('所在国家').asstring<>'' then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS发货人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+CZ+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,34)+'-'; Str_shr:='-'+Copy(str_all[4],34,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,34)+'*'; Str_shr:='*'+Copy(str_all[4],34,1); end; for j:=5 to str_all.Count-1 do begin Str_shr:=Str_shr+' '+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str_head:=''; str_all.Clear; if not bsck.Checked then begin if t_op_edi.FieldByName('所在国家').asstring<>'' then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS收货人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+CN+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,33)+'--'; Str_con:='--'+Copy(str_all[4],33,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,33)+'**'; Str_con:='**'+Copy(str_all[4],33,1); end; for j:=5 to str_all.Count-1 do begin Str_con:=Str_con+' '+str_all[j] end; end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('收货人邮编').asstring+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='加拿大') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('收货人邮编').asstring+'+CA'+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='巴西') then begin str_guodu:=str_guodu+'++++'+t_op_edi.FieldByName('收货人国家代码').asstring+#39; str.Add(str_guodu); str.Add('RFF+GN:'+t_op_edi.FieldByName('收货人税号').asstring+#39); // count:=count+1; end else begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end; count:=count+1; str_head:=''; str_all.Clear; if not bsck.Checked then begin if t_op_edi.FieldByName('所在国家').asstring<>'' then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS通知人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('通知人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+NI+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,32)+'---'; Str_not:='---'+Copy(str_all[4],32,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,32)+'***'; Str_not:='***'+Copy(str_all[4],32,1); end; for j:=5 to str_all.Count-1 do begin Str_not:=Str_not+' '+str_all[j] end; end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('通知人邮编').asstring+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='加拿大') then begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='巴西') then begin if t_op_edi.FieldByName('通知人国家代码').asstring<>'' then str_guodu:=str_guodu+'++++'+t_op_edi.FieldByName('通知人国家代码').asstring+#39 else str_guodu:=str_guodu+#39; str.Add(str_guodu); if t_op_edi.FieldByName('通知人税号').asstring<>'' then begin str.Add('RFF+GN:'+t_op_edi.FieldByName('通知人税号').asstring+#39); // count:=count+1; end; end else begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end; count:=count+1; if SelectCarrier then begin if bsSkinCheckRadioBox1.Checked then str.Add('NAD+CA+'+'STND'+':160:86++'+'SINOTRANS'+#39) else str.Add('NAD+CA+'+aCarrier.EdiNo+':160:86++'+aCarrier.CarrierName+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('NAD+CA+'+'STND'+':160:86++'+'SINOTRANS'+#39) else str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+':160:86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); count:=count+1; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-DOOR' then begin if not bsck.Checked then str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring) else str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').asstring); GetLengthTString(str_all,35); str_guodu:='NAD+SF+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 4 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; str_head:=''; str_all.Clear; if not bsck.Checked then begin if t_op_edi.fieldbyname('所在国家').AsString<>'' then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS收货人').asstring); //t_op_edi end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); end; if (pos('TO ORDER',UpperCase(str_all.Text))>0) or (pos('SAME AS',UpperCase(str_all.Text))>0) then if t_op_edi.fieldbyname('所在国家').AsString<>'' then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('通知人代码').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+ST+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 4 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-CY' then begin { str.Add('NAD+SF+++SEAWORTHYQD+.'+#39); count:=count+1; } str_all.Text:=Changestr(edit12.text); GetLengthTString(str_all,35); str_guodu:='NAD+SF+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 4 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-DOOR' then begin str_head:=''; str_all.Clear; str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('DOOR地址').asstring); GetLengthTString(str_all,35); str_guodu:='NAD+ST+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 4 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; end; if (CheckBox1.Checked) then begin str.Add('NAD+FW+'+Edit19.TEXT+':160:86++'+Edit20.text+#39) end else begin if Length(Edit2.text)<=35 then str.Add('NAD+FW+'+Edit1.TEXT+':160:86++'+Edit2.text+#39) else str.Add('NAD+FW+'+Edit1.TEXT+':160:86++'+Copy(Edit2.text,1,35)+'+'+Copy(Edit2.text,35,35)+#39); end; count:=count+1; if Length(Edit2.text)<=35 then str.Add('NAD+HI+'+Edit1.TEXT+':160:86++'+Edit2.text+#39) else str.Add('NAD+HI+'+Edit1.TEXT+':160:86++'+Copy(Edit2.text,1,35)+'+'+Copy(Edit2.text,35,35)+#39); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; str.Add('NAD+MR+++'+edit2.text+''''); count:=count+1; str.Add('CTA+NT+:'+Edit7.text+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; if not bsck.Checked then begin str.Add('GID+1+'+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+'::6:'+frm_op_seae.t_op_seae.fieldbyname('包装').asstring+#39); //? end else begin str.Add('GID+1+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))+'::6:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring+#39); //? end; count:=count+1; if Trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring)<>'' then begin str.Add('PIA+5+'+frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring+':HS'+#39); //? count:=count+1; end; sl:=TStringList.Create; try if not bsck.Checked then begin sl.text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').asstring; end else begin sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring; end; for i:=0 to sl.Count-1 do begin str.Add('FTX+AAA+++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; if Trim(str_shr)<>'' then begin str.Add('FTX+AAA+++'+ Str_shr+#39); count:=count+2; end; if Trim(str_con)<>'' then begin str.Add('FTX+AAA+++'+ Str_con+#39); count:=count+2; end; if Trim(str_not)<>'' then begin str.Add('FTX+AAA+++'+ Str_not+#39); count:=count+2; end; if not bsck.Checked then begin str.Add('MEA+AAE+WT+KGM:'+frm_op_seae.t_op_seae.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+frm_op_seae.t_op_seae.fieldbyname('尺码').asstring+#39); count:=count+1; end else begin str.Add('MEA+AAE+WT+KGM:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring+#39); count:=count+1; end; sl:=TStringList.Create; try if not bsck.Checked then begin sl.text:=frm_op_seae.t_op_seae.fieldbyname('唛头').asString; end else begin sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asString; end; GetLengthTString(sl,35); for i:=0 to sl.Count-1 do begin str.Add('PCI++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='D' then begin str.Add('DGS+IMD+'+frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring +'+'+frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring+#39); count:=count+1; str.Add('CTA+HG+:'+edit7.text+#39); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; end; if not bsck.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn.编号,t_op_ctn.数量, t_code_ctn.EDI代码,t_op_ctn.尺寸,t_op_ctn.包装'); t_op_ctn.SQL.Add(',t_op_ctn.箱型,t_op_ctn.箱号,t_op_ctn.重量,t_op_ctn.封号,t_op_ctn.尺码,t_op_ctn.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn.编号=:编号'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn_fendan.编号,t_op_ctn_fendan.数量, t_code_ctn.EDI代码,t_op_ctn_fendan.尺寸,t_op_ctn_fendan.包装'); t_op_ctn.SQL.Add(',t_op_ctn_fendan.箱型,t_op_ctn_fendan.箱号,t_op_ctn_fendan.重量,t_op_ctn_fendan.封号,t_op_ctn_fendan.尺码,t_op_ctn_fendan.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn_fendan INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn_fendan.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then str.Add('EQD+CN++'+GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)+'+1'+#39) else str.Add('EQD+CN++'+GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)+'+2'+#39); //箱型 多箱型 count:=count+1; str.Add('EQN+'+t_op_ctn.fieldbyname('数量').asstring+#39); //数量 count:=count+1; if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)<>'' then begin str.Add('MEA+AAE+AAS+CBM:'+frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring+#39); count:=count+1; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('湿度').asstring)<>'' then begin str.Add('MEA+AAE+AAO+HMD:'+frm_op_seae.t_op_seae.fieldbyname('湿度').asstring+#39); count:=count+1; end; end; if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R' then begin str.Add('TMP+2+'+frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring+':CEL'+#39); count:=count+1; end; t_op_ctn.next; end; count:=count+1; result:=count; end; function Tfrm_op_seae_edi_tsl.get_txtSI(str: Tstringlist): integer; //提单确认 var str_all,sl:Tstringlist; ctnlist:TStringList; j,Count,i,k,Lineno:integer; str_guodu,str_shr,str_con,str_not:widestring; str_pay,Str_head,str1,str2,CopyBillCount:string; aAdoQuery:TAdoQuery; function CutVoyNo(VoyNo:String):String; begin if length(VoyNO)<3 then exit; if Pos('.',VoyNO)>0 then begin Result:=Copy(VoyNO,3,length(VoyNO)-2); end else Result:=VoyNO; end; begin str_all:=Tstringlist.Create; count:=0; str.Add('UNB+UNOC:2+'+Edit1.TEXT+':ZZZ+'+Edit3.TEXT +':ZZZ+'+GetDatetime(datetimetostr(now),2)+'+' +frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); count:=count+1; str.Add('UNH+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+'+IFTMIN:D:99B:UN'+#39); count:=count+1; if not bsck.checked then begin if RadioGroup3.ItemIndex=0 then str.Add('BGM+340+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+9'+#39) else str.Add('BGM+340+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+5'+#39); count:=count+1; end else begin if RadioGroup3.ItemIndex=0 then str.Add('BGM+340+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'+9'+#39) else str.Add('BGM+340+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'+5'+#39); count:=count+1; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='' then begin showmessage('业务编号为:'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring +'的业务运输条款没有输入!!'); result:=-1; exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-DOOR' then begin str.Add('TSR+27+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-CY' then begin str.Add('TSR+28+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-DOOR' then begin str.Add('TSR+29+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='CY-CY' then begin str.Add('TSR+30+2'+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring)='OTHER' then begin str.Add('TSR+30+2'+#39); end; count:=count+1; if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring); if Pos('COLLECT',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring); if not bsck.checked then begin case RadioGroup2.ItemIndex of 12:begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring // +' Payable at '+str_pay+' '+ +frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+ trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)+#39); count:=count+1; end; else str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring +' Payable at '+str_pay+' '+ frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+ trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)+#39); count:=count+1; end; end else begin case RadioGroup2.ItemIndex of 12:begin str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring // +' Payable at '+str_pay+' '+ +frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring)+' '+Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString)+#39); count:=count+1; end; else str.Add('FTX+AAI+++'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring +' Payable at '+str_pay+' '+ frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring+ ' '+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring)+#39); count:=count+1; end; end; sl:=TStringList.Create; try if not bsck.checked then sl.text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asString) else sl.text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asString); for i:=0 to sl.Count-1 do begin str.Add('FTX+AAI+++'+sl.Strings[i]+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; if (t_op_edi.FieldByName('所在国家').asstring='加拿大') then begin if (t_op_edi.FieldByName('SCAC编号').asstring<>'') then str.Add('FTX+CCI++MFS+1:CA:'+t_op_edi.FieldByName('SCAC编号').asstring+#39) else str.Add('FTX+CCI++MFS+5:CA'+#39); end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin if (t_op_edi.FieldByName('SCAC编号').asstring<>'') then str.Add('FTX+CCI++MFS+1:US:'+t_op_edi.FieldByName('SCAC编号').asstring+#39) else str.Add('FTX+CCI++MFS+5:US'+#39); end; count:=count+1; if not bsck.checked then begin str.Add('CNT+7:'+frm_op_seae.t_op_seae.fieldbyname('重量').asstring+':KGM'''); count:=count+1; str.Add('CNT+11:'+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+''''); count:=count+1; str.Add('CNT+15:'+frm_op_seae.t_op_seae.fieldbyname('尺码').asstring+':MTQ'''); count:=count+1; end else begin str.Add('CNT+7:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring+':KGM'''); count:=count+1; str.Add('CNT+11:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+''''); count:=count+1; str.Add('CNT+15:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring+':MTQ'''); count:=count+1; end; if RadioGroup2.ItemIndex=10 then begin str.Add('CNT+16:'+GetcntCount+#39); // count:=count+1; end; if frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring='FREIGHT PREPAID' then begin str.Add('LOC+57+'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+#39); end else if frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring='FREIGHT COLLECT' then begin str.Add('LOC+57+'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点代码').asstring) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring)+#39); end else str.Add('LOC+57+'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+#39); count:=count+1; str.Add('LOC+73+'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring)) +'::6:'+trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring)+#39); count:=count+1; { if not (frm_op_seae.t_op_seae.fieldbyname('放单日期').asDatetime<(now-120)) then begin str.Add('DTM+95:'+GetDatetime(datetimetostr(frm_op_seae.t_op_seae.fieldbyname('放单日期').asDatetime),0)+':102'+#39); count:=count+1; end; } if not bsck.checked then begin if (RadioGroup2.ItemIndex=6) or (RadioGroup2.ItemIndex=1) then begin sl:=TStringList.Create; try sl.text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('拆单并单编号').asString); if sl.Count>0 then begin for i:=0 to sl.Count-1 do begin str.Add('RFF+BN:'+sl.Strings[i]+#39); count:=count+1; end; end else begin if t_op_edi.IsEmpty or (t_op_edi.FieldByName('定舱号').AsString='') then str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39) else str.Add('RFF+BN:'+t_op_edi.FieldByName('定舱号').AsString+#39); count:=count+1; end; finally FreeAndNil(sl); end; end else begin if t_op_edi.IsEmpty or (t_op_edi.FieldByName('定舱号').AsString='') then str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39) else str.Add('RFF+BN:'+t_op_edi.FieldByName('定舱号').AsString+#39); count:=count+1; end; end else begin if RadioGroup2.ItemIndex=6 then begin str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; end else begin str.Add('RFF+BN:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+#39); count:=count+1; end; end; if not bsck.checked then begin str.Add('RFF+BM:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; end else begin str.Add('RFF+BM:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+#39); count:=count+1; end; { str.Add('RFF+ON:###NAD-CZ-ZZZ-['+frm_op_seae.t_op_seae.fieldbyname('发货人编码').asstring+']'+#39); count:=count+1; } str.Add('RFF+CT:'+frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring+#39); // count:=count+1; if RadioGroup2.ItemIndex=10 then begin str.Add('RFF+SI:'+frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring+#39); // count:=count+1; end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin str.Add('REF+TN:'+t_op_edi.FieldByName('ITN编号').asstring+#39); count:=count+1; end; if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then str.Add('CPI+4++P''') else str.Add('CPI+4++C'''); count:=count+1; if SelectCarrier then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring)<>'' then begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1++'+aCarrier.EdiNo+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1++'+aCarrier.EdiNo+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end; end else begin if Trim(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring)<>'' then begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1++'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('内部航次号').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1++'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'+++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39) else str.Add('TDT+20+'+CutVoyNo(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +'+1+++++:::'+frm_op_seae.t_op_seae.fieldbyname('船名').asstring+#39); count:=count+1; end; end; str.Add('LOC+9+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('LOC+88+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('LOC+11+'+frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+#39); count:=count+1; if trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)<>'' then begin str.Add('LOC+7+'+frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring //? +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)+#39); count:=count+1; end; str_all.Clear; str_head:=''; if not bsck.checked then begin if (t_op_edi.FieldByName('所在国家').asstring<>'') and (aCarrier.CarrierName<>'OOCL') then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS发货人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('发货人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+CZ+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,34)+'-'; Str_shr:='-'+Copy(str_all[4],34,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,34)+'*'; Str_shr:='*'+Copy(str_all[4],34,1); end; for j:=5 to str_all.Count-1 do begin Str_shr:=Str_shr+' '+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; str_head:=''; str_all.Clear; if not bsck.Checked then begin if (t_op_edi.FieldByName('所在国家').asstring<>'') and (aCarrier.CarrierName<>'OOCL') then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS收货人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('收货人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+CN+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,33)+'--'; Str_con:='--'+Copy(str_all[4],33,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,33)+'**'; Str_con:='**'+Copy(str_all[4],33,1); end; for j:=5 to str_all.Count-1 do begin Str_con:=Str_con+' '+str_all[j] end; end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('收货人邮编').asstring+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='加拿大') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('收货人邮编').asstring+'+CA'+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='巴西') then begin str_guodu:=str_guodu+'++++'+t_op_edi.FieldByName('收货人国家代码').asstring+#39; str.Add(str_guodu); str.Add('RFF+GN:'+t_op_edi.FieldByName('收货人税号').asstring+#39); // count:=count+1; end else begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end; count:=count+1; //代理 str_head:=''; str_all.Clear; str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('代理内容').asstring); IF str_all.Count>0 then begin GetLengthTString(str_all,35); str_guodu:='NAD+FW+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; end; str_head:=''; str_all.Clear; if not bsck.checked then begin if (t_op_edi.FieldByName('所在国家').asstring<>'') and (aCarrier.CarrierName<>'OOCL') then begin str_all.Text:=Changestr(t_op_edi.fieldbyname('AMS通知人').asstring); end else begin str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring); end; end else begin str_all.Text:=Changestr(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('通知人代码').asstring); end; GetLengthTString(str_all,35); str_guodu:='NAD+NI+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; if str_all.Count>5 then begin for j:=2 to 3 do begin str_guodu:=str_guodu+':'+str_all[j] end; if RadioGroup2.ItemIndex=5 then begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,32)+'---'; Str_not:='---'+Copy(str_all[4],32,1); end else begin str_guodu:=str_guodu+':'+Copy(str_all[4],1,32)+'***'; Str_not:='***'+Copy(str_all[4],32,1); end; for j:=5 to str_all.Count-1 do begin Str_not:=Str_not+' '+str_all[j] end; end; if (t_op_edi.FieldByName('所在国家').asstring='美国') then begin str_guodu:=str_guodu+'+++'+t_op_edi.FieldByName('通知人邮编').asstring+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='加拿大') then begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end else if (t_op_edi.FieldByName('所在国家').asstring='巴西') then begin if t_op_edi.FieldByName('通知人国家代码').asstring<>'' then str_guodu:=str_guodu+'++++'+t_op_edi.FieldByName('通知人国家代码').asstring+#39 else str_guodu:=str_guodu+#39; str.Add(str_guodu); if t_op_edi.FieldByName('通知人税号').asstring<>'' then begin str.Add('RFF+GN:'+t_op_edi.FieldByName('通知人税号').asstring+#39); // count:=count+1; end; end else begin str_guodu:=str_guodu+#39; str.Add(str_guodu); end; count:=count+1; if trim(frm_op_seae.t_op_seae.fieldbyname('第二通知人').asstring)<>'' then begin str_head:=''; str_all.Clear; str_all.Text:=Changestr(frm_op_seae.t_op_seae.fieldbyname('第二通知人').asstring); GetLengthTString(str_all,35); str_guodu:='NAD+N1+++'+str_all[0]+'+'; if str_all.Count>=2 then str_guodu:=str_guodu+str_all[1]; if (str_all.Count>=3) and (str_all.Count<=5) then begin for j:=2 to str_all.Count-1 do begin str_guodu:=str_guodu+':'+str_all[j] end; end; str_guodu:=str_guodu+#39; str.Add(str_guodu); count:=count+1; end; { if RadioGroup2.ItemIndex=0 then str.Add('NAD+CA+MAEU:160:86++MAERSK'+#39) else if RadioGroup2.ItemIndex=1 then str.Add('NAD+CA+MCCQ:160:86++MCC TRANSPORT'+#39) else if RadioGroup2.ItemIndex=2 then str.Add('NAD+CA+ANNU:160:86++ANL CONTAINER LINE'+#39); } if SelectCarrier then begin if bsSkinCheckRadioBox1.Checked then str.Add('NAD+CA+'+'STND'+':160:86++'+'SINOTRANS'+#39) else str.Add('NAD+CA+'+aCarrier.EdiNo+':160:86++'+aCarrier.CarrierName+#39); count:=count+1; end else begin if bsSkinCheckRadioBox1.Checked then str.Add('NAD+CA+'+'STND'+':160:86++'+'SINOTRANS'+#39) else str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+':160:86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); count:=count+1; end; { if SelectCarrier then begin str.Add('NAD+CA+'+aCarrier.EdiNo+':160:86++'+aCarrier.CarrierName+#39); count:=count+1; end else begin str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+':160:86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); count:=count+1; end; } // str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+':160:86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); // count:=count+1; if Length(Edit2.text)<=35 then str.Add('NAD+HI+'+Edit1.TEXT+':160:86++'+Edit2.text+#39) else str.Add('NAD+HI+'+Edit1.TEXT+':160:86++'+Copy(Edit2.text,1,35)+'+'+Copy(Edit2.text,35,35)+#39); count:=count+1; str.Add('CTA+IC+:'+edit7.text+''''); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='ONE' then Str1:='1' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='TWO' then Str1:='2' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='THREE' then Str1:='3' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='FOUR' then Str1:='4' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='FIVE' then Str1:='5' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='SIX' then Str1:='6' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='SERVEN' then Str1:='7' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='EIGHT' then Str1:='8' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='NIGHT' then Str1:='9' else if frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring='TEN' then Str1:='10'; if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='ONE' then CopyBillCount:='1' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='TWO' then CopyBillCount:='2' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='THREE' then CopyBillCount:='3' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='FOUR' then CopyBillCount:='4' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='FIVE' then CopyBillCount:='5' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='SIX' then CopyBillCount:='6' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='SERVEN' then CopyBillCount:='7' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='EIGHT' then CopyBillCount:='8' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='NIGHT' then CopyBillCount:='9' else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='TEN' then CopyBillCount:='10'; IF trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='正本' then begin //提单类型 if aCarrier.CarrierName='OOCL' then Str2:='705' else Str2:='706'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; if trim(CopyBillCount)<>'' then begin Str2:='707'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+CopyBillCount+#39) else str.Add('DOC+'+Str2+'+++'+CopyBillCount+#39); count:=count+1; end; end else if (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='海运单') or (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='Seaway') or (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='SWB正本') or (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='SWB无正本') then begin //SWB正本 //SWB无正本 Str2:='710'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; end else if (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='BILL COPY') or (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='电放') then begin if aCarrier.CarrierName='OOCL' then Str2:='705' else Str2:='706'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; if Trim(CopyBillCount)<>'' then begin Str2:='707'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+CopyBillCount+#39) else str.Add('DOC+'+Str2+'+++'+CopyBillCount+#39); count:=count+1; end; end else if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='HOUSE BILL' then begin Str2:='714'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; end else if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='正副本' then begin if aCarrier.CarrierName='OOCL' then Str2:='705' else Str2:='706'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; if Trim(CopyBillCount)<>'' then begin Str2:='707'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+CopyBillCount+#39) else str.Add('DOC+'+Str2+'+++'+CopyBillCount+#39); count:=count+1; end; end; { else begin Str2:='706'; if frm_op_seae.t_op_seae.fieldbyname('运费').AsBoolean then str.Add('DOC+'+Str2+'+:27++'+Str1+#39) else str.Add('DOC+'+Str2+'+++'+Str1+#39); // str.Add('DOC+'+Str2+'+++'+Str1+#39); count:=count+1; end; } { str.Add('NAD+ZZZ+'+Edit1.TEXT+':160:86++'+Edit2.TEXT+#39); count:=count+1; str.Add('CTA+NT+'+employee+#39); count:=count+1; str.Add('COM+'+Edit6.text+':EM'+#39); count:=count+1; } { k:=1; t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin str.Add('GID+'+IntToStr(k)+'+'+t_op_ctn.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(t_op_ctn.fieldbyname('包装').asstring))+'::6:'+t_op_ctn.fieldbyname('包装').asstring+#39); //? k:=k+1; count:=count+1; t_op_ctn.Next; end; } /// ctnlist:=TStringList.Create; ctnlist.Clear; with t_op_edictn do begin Close;SQL.Clear; SQL.Add('select ctn_id from t_op_ctn'); SQL.Add('where 编号=:bsno'); Parameters.ParamByName('bsno').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; open;First; while not eof do begin ctnlist.Add(FieldByName('ctn_id').AsString); Next; end; end; t_op_edictn.Close;t_op_edictn.SQL.Clear; t_op_edictn.SQL.Add('select * from t_op_ctn_detail'); t_op_edictn.SQL.Add('where ctn_id in ('+ctnlist.CommaText+')'); t_op_edictn.Open; if t_op_edictn.RecordCount<=0 then begin if not bsck.checked then begin str.Add('GID+1+'+frm_op_seae.t_op_seae.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+'::6:'+frm_op_seae.t_op_seae.fieldbyname('包装').asstring+#39); //? count:=count+1; end else begin str.Add('GID+1+'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))+'::6:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring+#39); //? count:=count+1; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring)<>'' then begin // 商品编码 str.Add('PIA+5+'+frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring+':HS'+#39); //? count:=count+1; end; if RadioGroup1.ItemIndex=0 then begin sl:=TStringList.Create; try if not bsck.checked then sl.text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').asstring else sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring; for i:=0 to sl.Count-1 do begin str.Add('FTX+AAA+++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; end else begin sl:=TStringList.Create; try if not bsck.checked then sl.text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').asstring else sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring; for i:=0 to sl.Count-1 do begin str.Add('FTX+AAA+++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; if Trim(str_shr)<>'' then begin str.Add('FTX+AAA+++'+ Str_shr+#39); count:=count+2; end; if Trim(str_con)<>'' then begin str.Add('FTX+AAA+++'+ Str_con+#39); count:=count+2; end; if Trim(str_not)<>'' then begin str.Add('FTX+AAA+++'+ Str_not+#39); count:=count+2; end; end; if not bsck.checked then begin str.Add('MEA+AAE+WT+KGM:'+frm_op_seae.t_op_seae.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+frm_op_seae.t_op_seae.fieldbyname('尺码').asstring+#39); count:=count+1; end else begin str.Add('MEA+AAE+WT+KGM:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring+#39); count:=count+1; end; if Trim(t_op_edi.fieldbyname('货物NCM编号').asstring)<>'' then begin str.Add('RFF+ABT:'+t_op_edi.fieldbyname('货物NCM编号').asstring+#39); //? count:=count+1; end; sl:=TStringList.Create; try if not bsck.checked then sl.text:=frm_op_seae.t_op_seae.fieldbyname('唛头').asString else sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asString; GetLengthTString(sl,35); for i:=0 to sl.Count-1 do begin str.Add('PCI++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; if not bsck.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn.编号,t_op_ctn.数量, t_code_ctn.EDI代码,t_op_ctn.尺寸,t_op_ctn.包装'); t_op_ctn.SQL.Add(',t_op_ctn.箱型,t_op_ctn.箱号,t_op_ctn.重量,t_op_ctn.封号,t_op_ctn.尺码,t_op_ctn.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn.编号=:编号'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn_fendan.编号,t_op_ctn_fendan.数量, t_code_ctn.EDI代码,t_op_ctn_fendan.尺寸,t_op_ctn_fendan.包装'); t_op_ctn.SQL.Add(',t_op_ctn_fendan.箱型,t_op_ctn_fendan.箱号,t_op_ctn_fendan.重量,t_op_ctn_fendan.封号,t_op_ctn_fendan.尺码,t_op_ctn_fendan.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn_fendan INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn_fendan.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin str.Add('SGP+'+t_op_ctn.fieldbyname('箱号').asstring+'+'+t_op_ctn.fieldbyname('件数').asstring+#39); //数量 count:=count+1; str.Add('MEA+AAE+WT+KGM:'+t_op_ctn.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+t_op_ctn.fieldbyname('尺码').asstring+#39); count:=count+1; t_op_ctn.next; end; end else //分箱明细 begin t_op_edictn.Close;t_op_edictn.SQL.Clear; t_op_edictn.SQL.Add('select hts,货物描述,包装,sum(件数)件数,sum(重量) 重量,sum(尺码) 尺码'); t_op_edictn.SQL.Add('from t_op_ctn_detail'); t_op_edictn.SQL.Add('where ctn_id in ('+ctnlist.CommaText+')'); t_op_edictn.SQL.Add('Group by hts,货物描述,包装'); t_op_edictn.SQL.Add('Order by min(id)'); t_op_edictn.Open; Lineno:=1; while not t_op_edictn.eof do begin str.Add('GID+'+Inttostr(Lineno)+'+'+t_op_edictn.fieldbyname('件数').asstring+':'+ GetPkgCode(trim(t_op_edictn.fieldbyname('包装').asstring))+'::6:'+t_op_edictn.fieldbyname('包装').asstring+#39); //? count:=count+1; str.Add('PIA+5+'+t_op_edictn.fieldbyname('hts').asstring+':HS'+#39); //? count:=count+1; sl:=TStringList.Create; try sl.text:=t_op_edictn.fieldbyname('货物描述').asstring; for i:=0 to sl.Count-1 do begin str.Add('FTX+AAA+++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; str.Add('MEA+AAE+WT+KGM:'+t_op_edictn.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+t_op_edictn.fieldbyname('尺码').asstring+#39); count:=count+1; if Trim(t_op_edi.fieldbyname('货物NCM编号').asstring)<>'' then begin str.Add('RFF+ABT:'+t_op_edi.fieldbyname('货物NCM编号').asstring+#39); //? count:=count+1; end; if Lineno=1 then begin sl:=TStringList.Create; try if not bsck.Checked then sl.text:=frm_op_seae.t_op_seae.fieldbyname('唛头').asString else sl.text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asString; GetLengthTString(sl,35); for i:=0 to sl.Count-1 do begin str.Add('PCI++'+Changestr(sl.Strings[i])+''+#39); count:=count+1; end; finally FreeAndNil(sl); end; end; if (aCarrier.CarrierName='OOCL') THEN begin aAdoQuery:=CreateAdoQuery; try aAdoQuery.Close;aAdoQuery.SQL.Clear; aAdoQuery.SQL.Add('select t_op_ctn.箱号,t_op_ctn_detail.件数,t_op_ctn_detail.重量,t_op_ctn_detail.尺码'); aAdoQuery.SQL.Add('from t_op_ctn_detail'); aAdoQuery.SQL.Add('left Join t_op_ctn on t_op_ctn.ctn_id=t_op_ctn_detail.ctn_id'); aAdoQuery.SQL.Add('where t_op_ctn.编号=:编号 and t_op_ctn_detail.货物描述=:goods and t_op_ctn_detail.包装=:pkg and t_op_ctn_detail.hts=:hts'); aAdoQuery.Parameters.ParamByName('goods').Value:=t_op_edictn.fieldbyname('货物描述').asstring; aAdoQuery.Parameters.ParamByName('pkg').Value:=t_op_edictn.fieldbyname('包装').asstring; aAdoQuery.Parameters.ParamByName('hts').Value:=t_op_edictn.fieldbyname('hts').asstring; aAdoQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; aAdoQuery.Open; while not aAdoQuery.eof do begin str.Add('SGP+'+aAdoQuery.fieldbyname('箱号').asstring+'+'+aAdoQuery.fieldbyname('件数').asstring+#39); //数量 count:=count+1; str.Add('MEA+AAE+WT+KGM:'+aAdoQuery.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+aAdoQuery.fieldbyname('尺码').asstring+#39); count:=count+1; aAdoQuery.Next; end; finally aAdoQuery.Free; end; end else begin aAdoQuery:=CreateAdoQuery; try aAdoQuery.Close;aAdoQuery.SQL.Clear; aAdoQuery.SQL.Add('select t_op_ctn.箱号,sum(t_op_ctn_detail.件数)件数,sum(t_op_ctn_detail.重量) 重量,sum(t_op_ctn_detail.尺码) 尺码'); aAdoQuery.SQL.Add('from t_op_ctn_detail'); aAdoQuery.SQL.Add('left Join t_op_ctn on t_op_ctn.ctn_id=t_op_ctn_detail.ctn_id'); aAdoQuery.SQL.Add('where t_op_ctn.编号=:编号 and t_op_ctn_detail.货物描述=:goods and t_op_ctn_detail.包装=:pkg and t_op_ctn_detail.hts=:hts'); aAdoQuery.SQL.Add('Group by t_op_ctn.箱号'); aAdoQuery.Parameters.ParamByName('goods').Value:=t_op_edictn.fieldbyname('货物描述').asstring; aAdoQuery.Parameters.ParamByName('pkg').Value:=t_op_edictn.fieldbyname('包装').asstring; aAdoQuery.Parameters.ParamByName('hts').Value:=t_op_edictn.fieldbyname('hts').asstring; aAdoQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; aAdoQuery.Open; while not aAdoQuery.eof do begin str.Add('SGP+'+aAdoQuery.fieldbyname('箱号').asstring+'+'+aAdoQuery.fieldbyname('件数').asstring+#39); //数量 count:=count+1; str.Add('MEA+AAE+WT+KGM:'+aAdoQuery.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+aAdoQuery.fieldbyname('尺码').asstring+#39); count:=count+1; aAdoQuery.Next; end; finally aAdoQuery.Free; end; end; Lineno:=Lineno+1; t_op_edictn.Next; end; end; //// if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='D' then begin str.Add('DGS+IMD+'+frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring +'+'+frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring+#39); count:=count+1; str.Add('CTA+HG+:'+edit7.text+#39); count:=count+1; str.Add('COM+'+Edit5.text+':TE'+#39); count:=count+1; end; if not bsck.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn.编号,t_op_ctn.数量, t_code_ctn.EDI代码,t_op_ctn.尺寸,t_op_ctn.包装'); t_op_ctn.SQL.Add(',t_op_ctn.箱型,t_op_ctn.箱号,t_op_ctn.重量,t_op_ctn.封号,t_op_ctn.尺码,t_op_ctn.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn.编号=:编号'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('SELECT t_op_ctn_fendan.编号,t_op_ctn_fendan.数量, t_code_ctn.EDI代码,t_op_ctn_fendan.尺寸,t_op_ctn_fendan.包装'); t_op_ctn.SQL.Add(',t_op_ctn_fendan.箱型,t_op_ctn_fendan.箱号,t_op_ctn_fendan.重量,t_op_ctn_fendan.封号,t_op_ctn_fendan.尺码,t_op_ctn_fendan.件数'); t_op_ctn.SQL.Add('FROM t_op_ctn_fendan INNER JOIN'); t_op_ctn.SQL.Add('t_code_ctn ON t_op_ctn_fendan.代码 = t_code_ctn.代码'); t_op_ctn.SQL.Add('WHERE t_op_ctn_fendan.as_id=:as_id'); t_op_ctn.close; t_op_ctn.Parameters.ParamByName('as_id').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asinteger; end; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then str.Add('EQD+CN+'+t_op_ctn.fieldbyname('箱号').asstring+'+'+GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)+'+1'+#39) //数量 else str.Add('EQD+CN+'+t_op_ctn.fieldbyname('箱号').asstring+'+'+GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)+'+2'+#39); //数量 count:=count+1; str.Add('MEA+AAE+WT+KGM:'+t_op_ctn.fieldbyname('重量').asstring+#39); count:=count+1; str.Add('MEA+AAE+AAW+MTQ:'+t_op_ctn.fieldbyname('尺码').asstring+#39); count:=count+1; if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)<>'' then begin str.Add('MEA+AAE+AAS+CBM:'+frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring+#39); count:=count+1; end; end; { if frm_op_seae.t_op_seae.fieldbyname('总价').asfloat<>0 then begin str.Add('MEA+AAE+T+KGM:'+frm_op_seae.t_op_seae.fieldbyname('总价').asstring+#39); count:=count+1; end; } str.Add('SEL+'+t_op_ctn.fieldbyname('封号').asstring+'+CA'+#39); count:=count+1; if frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R' then begin str.Add('TMP+2+'+frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring+':CEL'+#39); count:=count+1; end; t_op_ctn.next; end; count:=count+1; result:=count; end; procedure Tfrm_op_seae_edi_tsl.bsSkinButton1Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin if bsck.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面选择分单发送分单Edi'); exit; end end; str:=Tstringlist.Create; str.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if not isEditrue then exit; if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtSI(str) else get_Count:=frm_op_seae_edi_cma.get_txtBooking(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin if not isEditrue then exit; if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtSI(str) else get_Count:=frm_op_seae_edi_cma.get_txtBooking(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB键,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+GetDatetime(datetimetostr(now),1); if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; end; {procedure Tfrm_op_seae_edi_cma.bsSkinButton1Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; begin str:=Tstringlist.Create; str.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); get_Count:=frm_op_seae_edi_cma.get_txt(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+'+inttostr(bill_count)+'+100'+#39); end else begin get_Count:=frm_op_seae_edi_cma.get_txt(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+1+100'+#39); end; 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; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('INTRA','SEND_CODE',edit1.text); inifile1.WriteString('INTRA','SEND_NAME',edit2.text); inifile1.WriteString('INTRA','RECEIVE_CODE',edit3.text); inifile1.WriteString('INTRA','RECEIVE_NAME',edit4.text); inifile1.free; close; end;} procedure Tfrm_op_seae_edi_tsl.FormShow(Sender: TObject); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); edit1.text:=inifile1.ReadString('EDI','SEND_CODE',''); edit2.text:=inifile1.ReadString('EDI','SEND_NAME',''); edit3.text:=inifile1.ReadString('EDI','RECEIVE_CODE',''); edit4.text:=inifile1.ReadString('EDI','RECEIVE_NAME',''); edit5.text:=inifile1.ReadString('EDI','SEND_TEL',''); edit6.text:=inifile1.ReadString('EDI','SEND_MAIL',''); edit7.text:=inifile1.ReadString('EDI','SEND_ATTN',''); edit8.text:=inifile1.ReadString('EDI','FTPADD',''); edit9.text:=inifile1.ReadString('EDI','FTPNAME',''); edit10.text:=inifile1.ReadString('EDI','FTPPASS',''); edit11.text:=inifile1.ReadString('EDI','FTPPATH','/'); edit13.text:=inifile1.ReadString('EDI','FTPPATHSI',''); edit14.text:=inifile1.ReadString('EDI','FTPSIGN',''); edit12.text:=inifile1.ReadString('EDI','ADDR',''); RadioGroup1.ItemIndex:=inifile1.ReadInteger('EDI','CMASEND_TYPE',0); RadioGroup2.ItemIndex:=inifile1.ReadInteger('EDI','CMASEND_CA',0); edit15.text:=inifile1.ReadString('EDI','FTPADDCMA',''); edit16.text:=inifile1.ReadString('EDI','FTPNAMECMA',''); Edit17.text:=inifile1.ReadString('EDI','FTPPASSCMA',''); Edit18.text:=inifile1.ReadString('EDI','FTPPATHCMA',''); Edit19.text:=inifile1.ReadString('EDI','FWID',''); Edit20.text:=inifile1.ReadString('EDI','FWNAME',''); IF RadioGroup2.ItemIndex=8 THEN bsSkinCheckRadioBox1.Checked:=True; inifile1.free; end; procedure Tfrm_op_seae_edi_tsl.bsSkinButton3Click(Sender: TObject); begin if frm_op_seae_edi_cma.Width=650 then frm_op_seae_edi_cma.Width:=305 else frm_op_seae_edi_cma.Width:=650; end; procedure Tfrm_op_seae_edi_tsl.bsSkinButton4Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ftppathSI,ScriptPath:String; StrL:Tstringlist; i,Count,get_Count,bill_count,i_soi:integer; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin i_soi:=0; if bsck.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(Edit8.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(Edit9.Text);; if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(Edit10.Text);; if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(Edit11.Text); ftppathSI:=Trim(Edit13.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; StrL.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if not isEditrue then exit; if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtSI(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtBooking(StrL); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); StrL.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin if not isEditrue then exit; if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtSI(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtBooking(StrL); if get_Count=-1 then exit else count:=count+get_Count; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); StrL.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); { str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+1+100'+#39); } end; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin MessageDlg('此票业务有中文字符或TAB键或<>字符,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; StrL.SaveToFile(str); edi:=StrL.Text; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; case RadioGroup1.ItemIndex of 0:begin idftp1.ChangeDir(ftppath); end; 1:begin if (Trim(ftppathSI)<>'') then idftp1.ChangeDir(ftppathSI) else idftp1.ChangeDir(ftppath); end; end; // idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; showmessage('文件上传成功!'); // if RadioGroup1.ItemIndex=0 then SIO:='SO' else SIO:='SI'; if RadioGroup3.ItemIndex=0 then ORG:='ORG' else ORG:='AMEND'; IF bsck.Checked then begin MBL:='分单'; MBLNO:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring; end else begin MBL:='主单'; MBLNO:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; end; CARR:=frm_op_seae.t_op_seae.fieldbyname('船公司').asstring; CORP:=frm_op_seae.t_op_seae.fieldbyname('委托单位').asstring; EMP:=employee; EMPDAE:=FormatDateTime('YYYY-MM-DD hh:mm:ss',now); ETD:=FormatDateTime('YYYY-MM-DD',frm_op_seae.t_op_seae.fieldbyname('开船日期').value); Insertt_op_Edi_Log(SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE,str,edi); except on e : exception do begin MessageDlg('文件上传错误!'+e.message,mtError,[mbOk],0); deletefile(str); i_soi:=1; // showmessage('文件上传错误!'); end; end; idftp1.Free; if i_soi=0 then UpdateSOIStatus(RadioGroup1.ItemIndex,frm_op_seae.t_op_seae.fieldbyname('编号').asstring); end; procedure Tfrm_op_seae_edi_tsl.FormClose(Sender: TObject; var Action: TCloseAction); VAR inifile1:TIniFile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','SEND_CODE',edit1.text); inifile1.WriteString('EDI','SEND_NAME',edit2.text); inifile1.WriteString('EDI','RECEIVE_CODE',edit3.text); inifile1.WriteString('EDI','RECEIVE_NAME',edit4.text); inifile1.WriteString('EDI','SEND_TEL',edit5.text); inifile1.WriteString('EDI','SEND_MAIL',edit6.text); inifile1.WriteString('EDI','SEND_ATTN',edit7.text); inifile1.WriteString('EDI','FTPADD',edit8.text); inifile1.WriteString('EDI','FTPNAME',edit9.text); inifile1.WriteString('EDI','FTPPASS',Edit10.text); inifile1.WriteString('EDI','FTPPATH',Edit11.text); inifile1.WriteString('EDI','FTPADDCMA',edit15.text); inifile1.WriteString('EDI','FTPNAMECMA',edit16.text); inifile1.WriteString('EDI','FTPPASSCMA',Edit17.text); inifile1.WriteString('EDI','FTPPATHCMA',Edit18.text); inifile1.WriteString('EDI','FTPPATHSI',Edit13.text); inifile1.WriteString('EDI','FTPSIGN',Edit14.text); inifile1.WriteString('EDI','ADDR',edit12.text); inifile1.WriteString('EDI','FWID',edit19.text); inifile1.WriteString('EDI','FWNAME',edit20.text); inifile1.WriteInteger('EDI','CMASEND_TYPE',RadioGroup1.ItemIndex); inifile1.WriteInteger('EDI','CMASEND_CA',RadioGroup2.ItemIndex); inifile1.free; action:=cafree; frm_op_seae_edi_cma:=nil; end; procedure Tfrm_op_seae_edi_tsl.RadioGroup2Click(Sender: TObject); begin IF RadioGroup2.ItemIndex=8 THEN bsSkinCheckRadioBox1.Checked:=True ELSE bsSkinCheckRadioBox1.Checked:=False; end; procedure Tfrm_op_seae_edi_tsl.bsSkinButton7Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton7.ClientToScreen(Point(0,bsSkinButton7.Height)); PopupMenu3.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi_tsl.N17Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin str:=Tstringlist.Create; str.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB键,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+GetDatetime(datetimetostr(now),1); if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; end; function Tfrm_op_seae_edi_tsl.get_txtvgm_cargo(str:Tstringlist):integer; var str_all,sl:Tstringlist; i,count:integer; SM,Carrer,shipname,shipaddr:string; begin i:=0; case RadioGroup2.ItemIndex of 0:Carrer:='MAEU'; 1:Carrer:='SAFM'; 2:Carrer:='MCPU'; end; str_all:=Tstringlist.Create; count:=0; sl:=Tstringlist.Create; sl.Text:=Changestr(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('UNB+UNOA:2+'+Edit1.TEXT+':ZZ+'+'CARGOSMART' +':01+'+GetDatetime(datetimetostr(now),2)+'+' +frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNH+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+VERMAS:D:16A:UN'+#39); count:=count+1; if RadioGroup3.ItemIndex=0 then str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+9'+#39) //9原始 5 更新 else str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+5'+#39); //9原始 5 更新 count:=count+1; str.Add('DTM+137:'+GetDatetime(datetimetostr(now),1)+':203'+#39); count:=count+1; str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+#39); count:=count+1; t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin if (t_op_ctn.fieldbyname('称重方式').asstring<>'') or (t_op_ctn.fieldbyname('称重方式').asstring<>'无') then begin i:=i+1; str.Add('EQD+CN+'+t_op_ctn.fieldbyname('箱号').asstring+#39); //数量 count:=count+1; str.Add('RFF+BM:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; str.Add('MEA+AAE+VGM+KGM:'+t_op_ctn.fieldbyname('称重重量').asstring+#39); ////累加 无 count:=count+1; if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='累加' then SM:='SM2' else if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='总重' then SM:='SM1'; str.Add('DOC+'+SM+':VGM:306'+#39); ////累加 无 count:=count+1; str.Add('NAD+SPC+++'+shipname+#39); ////累加 无 count:=count+1; str.Add('CTA+RP+:'+Changestr(Edit14.Text)+#39); ////累加 无 count:=count+1; str.Add('NAD+AM+++'+Changestr(Edit2.Text)+#39); ////累加 无 count:=count+1; str.Add('CTA+RP+:'+Changestr(Edit14.Text)+#39); ////累加 无 count:=count+1; // str.Add('UNT+7+'+IntToStr(i)+#39); count:=count+1; end; t_op_ctn.next; end; result:=count; end; function Tfrm_op_seae_edi_tsl.get_txtvgm_intrra(str:Tstringlist):integer; var str_all,sl:Tstringlist; i,count:integer; SM,Carrer:string; begin i:=0; case RadioGroup2.ItemIndex of 0:Carrer:='MAEU'; 1:Carrer:='SAFM'; 2:Carrer:='MCPU'; end; str_all:=Tstringlist.Create; count:=0; str.Add('UNB+UNOC:3+'+Edit1.TEXT+':ZZZ+'+'INTTRA' +':ZZZ+'+GetDatetime(datetimetostr(now),2)+'+' +frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNH+001+VERMAS:D:16A:UN:0.8'+#39); count:=count+1; if RadioGroup3.ItemIndex=0 then str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+9'+#39) //9原始 5 更新 else str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+5'+#39); //9原始 5 更新 count:=count+1; count:=count+1; t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin if (t_op_ctn.fieldbyname('称重方式').asstring<>'') or (t_op_ctn.fieldbyname('称重方式').asstring<>'无') then begin i:=i+1; str.Add('DTM+137:'+GetDatetime(datetimetostr(now),1)+':203'+#39); count:=count+1; str.Add('EQD+CN+'+t_op_ctn.fieldbyname('箱号').asstring+':6346:5'+#39); //数量 count:=count+1; str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; str.Add('RFF+AOW:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; str.Add('MEA+AAE+VGM+KGM:'+t_op_ctn.fieldbyname('称重重量').asstring+#39); ////累加 无 count:=count+1; if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='累加' then SM:='SM2' else if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='总重' then SM:='SM1'; str.Add('DOC+'+SM+':VGM:306'+#39); ////累加 无 count:=count+1; str.Add('NAD+SPC+++'+Changestr(Edit2.Text)+#39); ////累加 无 count:=count+1; str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'::86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); count:=count+1; str.Add('UNT+9+'+IntToStr(i)+#39); count:=count+1; end; t_op_ctn.next; end; result:=count; end; function Tfrm_op_seae_edi_tsl.get_txtvgm_cma(str:Tstringlist):integer; var str_all,sl:Tstringlist; i,count:integer; SM,Carrer:string; begin i:=0; str_all:=Tstringlist.Create; count:=0; str.Add('UNB+UNOC:3+'+Edit1.TEXT+':ZZZ+'+'CMA-CGM' +':ZZZ+'+GetDatetime(datetimetostr(now),2)+'+' +frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); str.Add('UNH+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'+VERMAS:D:16A:UN:0.4'+#39); count:=count+1; if RadioGroup3.ItemIndex=0 then str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'++9'+#39) //9原始 5 更新 else str.Add('BGM+XXX+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+'++5'+#39); //9原始 5 更新 count:=count+1; str.Add('DTM+137:'+GetDatetime(datetimetostr(now),1)+':203'+#39); count:=count+1; t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; t_op_ctn.first; while not t_op_ctn.eof do begin if (t_op_ctn.fieldbyname('称重方式').asstring<>'') or (t_op_ctn.fieldbyname('称重方式').asstring<>'无') then begin i:=i+1; str.Add('EQD+CN+'+t_op_ctn.fieldbyname('箱号').asstring+':6346:5'+GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)+':6346:5'+#39); //数量 // count:=count+1; str.Add('RFF+BN:'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); count:=count+1; str.Add('LOC+88+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('LOC+65+'+frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+#39); count:=count+1; str.Add('LOC+11+'+frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+#39); count:=count+1; str.Add('LOC+9+'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':139:6:'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+#39); count:=count+1; str.Add('DTM+WAT:'+GetDatetime(datetimetostr(now),1)+':203'+#39); ////累加 无 count:=count+1; str.Add('MEA+AAE+VGM+KGM:'+t_op_ctn.fieldbyname('称重重量').asstring+#39); ////累加 无 count:=count+1; if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='累加' then SM:='SM2' else if Trim(t_op_ctn.fieldbyname('称重方式').asstring)='总重' then SM:='SM1'; str.Add('DOC+'+SM+':VGM:306'+#39); ////累加 无 count:=count+1; str.Add('NAD+SPC+++'+Changestr(Edit2.Text)+#39); ////累加 无 count:=count+1; str.Add('CTA+RP+:'+Changestr(Edit14.Text)+#39); ////累加 无 count:=count+1; str.Add('COM+'+Changestr(Edit6.Text)+':EM'+#39); //str.Add('NAD+CA+'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+'::86++'+frm_op_seae.t_op_seae.fieldbyname('船公司').asstring+#39); //count:=count+1; // str.Add('UNT+13+'+IntToStr(i)+#39); // count:=count+1; end; t_op_ctn.next; end; result:=count; end; procedure Tfrm_op_seae_edi_tsl.N34Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin str:=Tstringlist.Create; str.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); str.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); str.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB键,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+GetDatetime(datetimetostr(now),1); if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; end; procedure Tfrm_op_seae_edi_tsl.CARGO1Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ftppathSI,ScriptPath:String; StrL:Tstringlist; i,Count,get_Count,bill_count,i_soi:integer; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin i_soi:=0; if bsck.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(Edit8.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(Edit9.Text);; if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(Edit10.Text);; if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:='/prod/in/vgm'; ftppathSI:=Trim(Edit13.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; StrL.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(StrL); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_cargo(StrL); if get_Count=-1 then exit else count:=count+get_Count; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); { str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+1+100'+#39); } end; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin MessageDlg('此票业务有中文字符或TAB键或<>字符,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; StrL.SaveToFile(str); edi:=StrL.Text; // showmessage(ftppath); //exit; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; idftp1.ChangeDir(ftppath); // idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; showmessage('文件上传成功!'); // if RadioGroup1.ItemIndex=0 then SIO:='SO' else SIO:='SI'; if RadioGroup3.ItemIndex=0 then ORG:='ORG' else ORG:='AMEND'; IF bsck.Checked then begin MBL:='分单'; MBLNO:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring; end else begin MBL:='主单'; MBLNO:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; end; CARR:=frm_op_seae.t_op_seae.fieldbyname('船公司').asstring; CORP:=frm_op_seae.t_op_seae.fieldbyname('委托单位').asstring; EMP:=employee; EMPDAE:=FormatDateTime('YYYY-MM-DD hh:mm:ss',now); ETD:=FormatDateTime('YYYY-MM-DD',frm_op_seae.t_op_seae.fieldbyname('开船日期').value); Insertt_op_Edi_Log(SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE,str,edi); except on e : exception do begin MessageDlg('文件上传错误!'+e.message,mtError,[mbOk],0); deletefile(str); i_soi:=1; // showmessage('文件上传错误!'); end; end; idftp1.Free; end; procedure Tfrm_op_seae_edi_tsl.INTTRA1Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ftppathSI,ScriptPath:String; StrL:Tstringlist; i,Count,get_Count,bill_count,i_soi:integer; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin i_soi:=0; if bsck.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(Edit8.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(Edit9.Text);; if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(Edit10.Text);; if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(Edit11.Text); ftppathSI:=Trim(Edit13.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; StrL.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(StrL); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+'+inttostr(bill_count)+'+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_intrra(StrL); if get_Count=-1 then exit else count:=count+get_Count; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); { str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+1+100'+#39); } end; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin MessageDlg('此票业务有中文字符或TAB键或<>字符,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; StrL.SaveToFile(str); edi:=StrL.Text; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; case RadioGroup1.ItemIndex of 0:begin idftp1.ChangeDir(ftppath); end; 1:begin if (Trim(ftppathSI)<>'') then idftp1.ChangeDir(ftppathSI) else idftp1.ChangeDir(ftppath); end; end; // idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; showmessage('文件上传成功!'); // if RadioGroup1.ItemIndex=0 then SIO:='SO' else SIO:='SI'; if RadioGroup3.ItemIndex=0 then ORG:='ORG' else ORG:='AMEND'; IF bsck.Checked then begin MBL:='分单'; MBLNO:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring; end else begin MBL:='主单'; MBLNO:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; end; CARR:=frm_op_seae.t_op_seae.fieldbyname('船公司').asstring; CORP:=frm_op_seae.t_op_seae.fieldbyname('委托单位').asstring; EMP:=employee; EMPDAE:=FormatDateTime('YYYY-MM-DD hh:mm:ss',now); ETD:=FormatDateTime('YYYY-MM-DD',frm_op_seae.t_op_seae.fieldbyname('开船日期').value); Insertt_op_Edi_Log(SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE,str,edi); except on e : exception do begin MessageDlg('文件上传错误!'+e.message,mtError,[mbOk],0); deletefile(str); i_soi:=1; // showmessage('文件上传错误!'); end; end; idftp1.Free; end; procedure Tfrm_op_seae_edi_tsl.CMA1Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin str:=Tstringlist.Create; str.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); str.Add('UNZ+1'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('UNT+'+INTTOSTR(str.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); str.Add('UNZ+1'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB键,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+GetDatetime(datetimetostr(now),1); if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; end; procedure Tfrm_op_seae_edi_tsl.CMA2Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ftppathSI,ScriptPath:String; StrL:Tstringlist; i,Count,get_Count,bill_count,i_soi:integer; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin i_soi:=0; if bsck.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(Edit15.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(Edit16.Text);; if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(Edit17.Text);; if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(Edit18.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; StrL.Clear; count:=0; bill_count:=0; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(StrL); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+1'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); end else begin if RadioGroup1.ItemIndex=1 then get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(StrL) else get_Count:=frm_op_seae_edi_cma.get_txtvgm_cma(StrL); if get_Count=-1 then exit else count:=count+get_Count; StrL.Add('UNT+'+INTTOSTR(StrL.count)+'+'+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring+#39); StrL.Add('UNZ+1+'+frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring+#39); { str.Add('UNT+'+INTTOSTR(count)+'+1'+#39); str.Add('UNZ+1+100'+#39); } end; for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i]) then begin MessageDlg('此票业务有中文字符或TAB键或<>字符,不能上传!'+#13#10+Str[i],mtWarning,[mbYes],0); exit; end; end; StrL.SaveToFile(str); edi:=StrL.Text; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; case RadioGroup1.ItemIndex of 0:begin idftp1.ChangeDir(ftppath); end; 1:begin if (Trim(ftppathSI)<>'') then idftp1.ChangeDir(ftppathSI) else idftp1.ChangeDir(ftppath); end; end; // idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; showmessage('文件上传成功!'); // if RadioGroup1.ItemIndex=0 then SIO:='SO' else SIO:='SI'; if RadioGroup3.ItemIndex=0 then ORG:='ORG' else ORG:='AMEND'; IF bsck.Checked then begin MBL:='分单'; MBLNO:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring; end else begin MBL:='主单'; MBLNO:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; end; CARR:=frm_op_seae.t_op_seae.fieldbyname('船公司').asstring; CORP:=frm_op_seae.t_op_seae.fieldbyname('委托单位').asstring; EMP:=employee; EMPDAE:=FormatDateTime('YYYY-MM-DD hh:mm:ss',now); ETD:=FormatDateTime('YYYY-MM-DD',frm_op_seae.t_op_seae.fieldbyname('开船日期').value); Insertt_op_Edi_Log(SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE,str,edi); except on e : exception do begin MessageDlg('文件上传错误!'+e.message,mtError,[mbOk],0); deletefile(str); i_soi:=1; // showmessage('文件上传错误!'); end; end; idftp1.Free; end; end.