unit u_op_seae_edi_zxd; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls,inifiles, DB, ADODB,IdFTP,IdFTPCommon, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, dxDBTLCl, dxGrClms; type TCarrier = Record //消息客户端消息结构 EdiNo :String; CarrierName :String; end; Tfrm_op_seae_edi_zxd = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; SaveDialog1: TSaveDialog; t_op_ctn: TADOQuery; Label5: TLabel; Label6: TLabel; Label7: TLabel; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; GroupBox1: TGroupBox; Label8: TLabel; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Label9: TLabel; Label10: TLabel; Edit11: TEdit; Label11: TLabel; t_op_edi: TADOQuery; Label12: TLabel; Edit12: TEdit; bsck: TbsSkinCheckRadioBox; t_op_edictn: TADOQuery; Panel1: TPanel; Label2: TLabel; Label1: TLabel; Label3: TLabel; Label4: TLabel; Edit2: TEdit; Edit1: TEdit; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; Edit3: TEdit; Edit4: TEdit; RadioGroup1: TRadioGroup; RadioGroup3: TRadioGroup; dxDBGrid1: TdxDBGrid; t_op_ctn1: TDataSource; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column1: TdxDBGridCheckColumn; procedure bsSkinButton1Click(Sender: TObject); procedure FormShow(Sender: TObject); function get_txtBooking(str:Tstringlist):integer; function get_goods(str:widestring):widestring; procedure bsSkinButton3Click(Sender: TObject); function isEditrue(DataSet:TDataSet):boolean; function Changestr(str:widestring):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; procedure bsSkinButton4Click(Sender: TObject); function GetvesselEdi(avessel: String): String; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } aCarrier:TCarrier; SelectCarrier:Boolean; function FormatEdiString(old:String;Strlength:integer):String; function GetpkgsEdi(pkgs:String):String; function GetShipEdiNO(Ship:String): String; end; var frm_op_seae_edi_zxd: Tfrm_op_seae_edi_zxd; implementation uses u_op_seae, my_sys_function, u_main, u_data_share, u_op_seae_assistant; {$R *.dfm} function Tfrm_op_seae_edi_zxd.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 客户简称='''+Ship+''''); SQL.Add('order by 代码'); Open; if not IsEmpty then Result:=Trim(FieldByName('代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_zxd.GetpkgsEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_package where 代码='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_zxd.FormatEdiString(old:String;Strlength:integer):String; var i:integer; begin Result:=Trim(Old); Result:=StringReplace(Result,'?','??',[rfReplaceAll]); Result:=StringReplace(Result,':','?:',[rfReplaceAll]); Result:=StringReplace(Result,'''','?''',[rfReplaceAll]); Result:=StringReplace(Result,'+','?+',[rfReplaceAll]); end; function Tfrm_op_seae_edi_zxd.GetvesselEdi(avessel: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 船舶呼号 from t_code_vessel where 英文船名='''+avessel+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_zxd.isEditrue(DataSet:TDataSet): boolean; var cntrs:String; begin result:=true; if trim(DataSet.fieldbyname('主提单号').asstring)='' then begin result:=false; MessageDlg('提单号不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('开船日期').asstring)='' then begin result:=false; MessageDlg('开船日期不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('船名').asstring)='' then begin result:=false; MessageDlg('船名不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('场站').asstring)='' then begin result:=false; MessageDlg('场站不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('包装').asstring)='' then begin result:=false; MessageDlg('包装不存在!',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('货物描述').asstring)='' then begin result:=false; MessageDlg('货物描述不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('唛头').asstring)='' then begin result:=false; MessageDlg('唛头不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('件数').asinteger=0 then begin result:=false; MessageDlg('件数不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('重量').asFloat=0 then begin result:=false; MessageDlg('总重量不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('尺码').asFloat=0 then begin result:=false; MessageDlg('总尺码不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' then begin result:=false; MessageDlg('货物标识不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='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 Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)='' then begin result:=false; MessageDlg('冷藏通风量不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring)='' then begin result:=false; MessageDlg('最低温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring)='' then begin result:=false; MessageDlg('最高温度不能为空',mtWarning,[mbOk],0); exit; end; end; end; function Tfrm_op_seae_edi_zxd.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_zxd.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_zxd.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_zxd.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_zxd.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_zxd.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_zxd.get_txtBooking(str:Tstringlist):integer; var str_all,sl,sl1:Tstringlist; l,count,m:integer; FILEFUNCTION,s:string; Qty:integer; pkg,cmb:double; begin if RadioGroup3.ItemIndex=0 then FILEFUNCTION:='9' //9原始 5 更新 else FILEFUNCTION:='4;'; Qty:=0; pkg:=0; cmb:=0; count:=0; str.Add ('00:'+'COSTCO' +':'+'CONTAINER LOAD PLAN' +':'+FILEFUNCTION +':'+trim(Edit1.Text) +':'+trim(Edit3.Text) +':'+FormatDateTime('YYYYMMDDhhmm',Now) +':'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring+#39); count:=count+1; str.Add ('10:'+trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring)) +':'+trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':'+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) +':' +':'+trim(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)+#39); count:=count+1; with t_op_ctn do begin First; while not eof do begin if t_op_ctn.FieldByName('A').AsBoolean then begin str.Add ('50:'+trim(fieldbyname('箱号').asstring) +':'+trim(fieldbyname('尺寸').asstring)+trim(fieldbyname('箱型').asstring) +':'+'F' +':'+'O' +':'+GetShipEdiNO(trim(frm_op_seae.t_op_seae.fieldbyname('场站').asstring)) //装箱地点代码 +':'+trim(frm_op_seae.t_op_seae.fieldbyname('场站').asstring) //装箱地点 +':'+FormatDateTime('YYYYMMDDhhmm',Now) +':'+trim(fieldbyname('封号').asstring) +':' // 箱经营人代码 +':' //箱经营人 +#39); count:=count+1; Qty:=Qty+fieldbyname('件数').asInteger; pkg:=pkg+fieldbyname('重量').AsFloat; cmb:=cmb+fieldbyname('尺码').AsFloat; end; next; end; end; str.Add ('51:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':'+frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring +':'+frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring +':'+frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring +':'+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)+#39); count:=count+1; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='R' then begin str.Add ('52:'+'1' +':'+trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring) // 货物代码 +':' +':'+IntToStr(Qty) +':'+GetpkgsEdi(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)) +':'+frm_op_seae.t_op_seae.fieldbyname('包装').asstring +':'+FormatFloat(';;',pkg) +':'+FormatFloat(';;',cmb) +':'+'C' +':'+frm_op_seae.t_op_seae.fieldbyname('温度').asstring +':'+frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring +':'+frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring+#39); count:=count+1; end else if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='D' then begin end else begin str.Add ('52:'+'1' +':'+trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring) // 货物代码 +':' +':'+IntToStr(Qty) +':'+GetpkgsEdi(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)) +':'+frm_op_seae.t_op_seae.fieldbyname('包装').asstring +':'+FormatFloat(';;',pkg) +':'+FormatFloat(';;',cmb)+#39); count:=count+1; end; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString; GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='53:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='53:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+M+1; sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('唛头').AsString; GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='54:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='54:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+M+1; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='D' then begin str.Add ('55:'+trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':'+frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring +':' +':' +':' +':' +':'+#39); count:=count+1; end; with t_op_ctn do begin First; while not eof do begin if t_op_ctn.FieldByName('A').AsBoolean then begin str.Add ('56:'+trim(fieldbyname('箱号').asstring) +':'+fieldbyname('件数').asString +':'+fieldbyname('重量').asString +':'+fieldbyname('重量').asString +':'+fieldbyname('尺码').asString +#39); count:=count+1; end; next; end; end; result:=count; end; procedure Tfrm_op_seae_edi_zxd.bsSkinButton1Click(Sender: TObject); var str:Tstringlist; i,Count,get_Count,bill_count:integer; inifile1:Tinifile; begin try 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(frm_op_seae.t_op_seae) then exit; if RadioGroup1.ItemIndex=1 then // get_Count:=frm_op_seae_edi_zxd.get_txtSI(str) else get_Count:=frm_op_seae_edi_zxd.get_txtBooking(str); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; str.Add('99:'+intToStr(count+1)+''''); end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; if RadioGroup1.ItemIndex=1 then // get_Count:=frm_op_seae_edi_zxd.get_txtSI(str) else get_Count:=frm_op_seae_edi_zxd.get_txtBooking(str); if get_Count=-1 then exit else count:=count+get_Count; str.Add('99:'+intToStr(count+1)+''''); 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; except on e:exception do begin ShowMessage(e.Message); end; end; end; {procedure Tfrm_op_seae_edi_zxd.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_zxd.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_zxd.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_zxd.FormShow(Sender: TObject); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); edit1.text:=inifile1.ReadString('EDI','SEND_CODE_ZXD',''); edit2.text:=inifile1.ReadString('EDI','SEND_NAME_ZXD',''); edit3.text:=inifile1.ReadString('EDI','RECEIVE_CODE_ZXD',''); edit4.text:=inifile1.ReadString('EDI','RECEIVE_NAME_ZXD',''); edit5.text:=inifile1.ReadString('EDI','SEND_TEL_ZXD',''); edit6.text:=inifile1.ReadString('EDI','SEND_MAIL_ZXD',''); edit7.text:=inifile1.ReadString('EDI','SEND_ATTN_ZXD',''); edit8.text:=inifile1.ReadString('EDI','FTPADD_ZXD',''); edit9.text:=inifile1.ReadString('EDI','FTPNAME_ZXD',''); edit10.text:=inifile1.ReadString('EDI','FTPPASS_ZXD',''); edit11.text:=inifile1.ReadString('EDI','FTPPATH_ZXD','/'); edit12.text:=inifile1.ReadString('EDI','ADDR_ZXD',''); inifile1.free; end; procedure Tfrm_op_seae_edi_zxd.bsSkinButton3Click(Sender: TObject); begin if frm_op_seae_edi_zxd.Width=650 then frm_op_seae_edi_zxd.Width:=305 else frm_op_seae_edi_zxd.Width:=650; end; procedure Tfrm_op_seae_edi_zxd.bsSkinButton4Click(Sender: TObject); var IdFTP1:TIdFTP; str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:Tstringlist; i,Count,get_Count,bill_count,i_soi:integer; 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);; 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(frm_op_seae.t_op_seae) then exit; if RadioGroup1.ItemIndex=1 then // get_Count:=frm_op_seae_edi_zxd.get_txtSI(StrL) else get_Count:=frm_op_seae_edi_zxd.get_txtBooking(StrL); if get_Count=-1 then exit else count:=count+get_Count; bill_count:=bill_count+1; end; StrL.Add('99:'+intToStr(count+1)+''''); end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; if RadioGroup1.ItemIndex=1 then // get_Count:=frm_op_seae_edi_zxd.get_txtSI(StrL) else get_Count:=frm_op_seae_edi_zxd.get_txtBooking(StrL); if get_Count=-1 then exit else count:=count+get_Count; StrL.Add('99:'+intToStr(count+1)+''''); end; StrL.SaveToFile(str); try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Connect; end; idftp1.ChangeDir(ftppath); idftp1.TransferType:=ftBinary; idftp1.Put(str,str_file); idftp1.Disconnect; showmessage('文件上传成功!'); except deletefile(str); i_soi:=1; showmessage('文件上传错误!'); 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_zxd.FormClose(Sender: TObject; var Action: TCloseAction); VAR inifile1:TIniFile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','SEND_CODE_ZXD',edit1.text); inifile1.WriteString('EDI','ZXDSEND_NAME_ZXD',edit2.text); inifile1.WriteString('EDI','RECEIVE_CODE_ZXD',edit3.text); inifile1.WriteString('EDI','RECEIVE_NAME_ZXD',edit4.text); inifile1.WriteString('EDI','SEND_TEL_ZXD',edit5.text); inifile1.WriteString('EDI','SEND_MAIL_ZXD',edit6.text); inifile1.WriteString('EDI','SEND_ATTN_ZXD',edit7.text); inifile1.WriteString('EDI','FTPADD_ZXD',edit8.text); inifile1.WriteString('EDI','FTPNAME_ZXD',edit9.text); inifile1.WriteString('EDI','FTPPASS_ZXD',Edit10.text); inifile1.WriteString('EDI','FTPPATH_ZXD',Edit11.text); inifile1.WriteString('EDI','ADDR_ZXD',edit12.text); inifile1.WriteInteger('EDI','CMASEND_TYPE_ZXD',RadioGroup1.ItemIndex); inifile1.free; action:=cafree; frm_op_seae_edi_zxd:=nil; end; procedure Tfrm_op_seae_edi_zxd.FormCreate(Sender: TObject); begin t_op_ctn.Close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.Open; end; end.