unit u_op_seae_edi_yh; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB; type Tfrm_op_seae_edi_yh = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; Label2: TLabel; Edit2: TEdit; Edit1: TEdit; Label1: TLabel; SaveDialog1: TSaveDialog; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; CheckBoxwt: TCheckBox; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); private function isEditrue(DataSet:TDataSet): boolean; function FormatListString(Old:TStrings;mCount,Strlength:integer):String; function FormatEdiString(old:String):String; procedure GetLengthTString(var sl: TStringList; l: integer); function GetLengthword(var s: String; l: Integer;str:String): String; function GetCntrEdi(cntrsize: String):String; function GetpkgsEdi(pkgs:String):String; { Private declarations } public { Public declarations } end; var frm_op_seae_edi_yh: Tfrm_op_seae_edi_yh; implementation uses u_op_seae, u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_op_seae_edi_yh.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_edi_yh.FormShow(Sender: TObject); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); edit1.text:=inifile1.ReadString('EDI','YHSEND',''); edit2.text:=inifile1.ReadString('EDI','YHRECIEVE',''); CheckBoxwt.Checked:=inifile1.ReadBool('EDI','YHWT',true); inifile1.free; end; procedure Tfrm_op_seae_edi_yh.bsSkinButton1Click(Sender: TObject); var str,sl1,sl:Tstringlist; i,j,Count,M,L:integer; strsql,strRmain:string; rs:Tadoquery; wide_str:widestring; k:integer; inifile1:Tinifile; strType,s:string; strDatetime:string; SenderCode,ReciverCode:string; function GetRemarksString:String; var TempStr:TStrings; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('EDI备注').AsString; Result:='17:'; Result:=Result+FormatListString(TempStr,5,35)+''''; finally FreeAndNil(TempStr); end; end; function GetShipperString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString); GetLengthTString(TempStr,35); Result:='20:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString); GetLengthTString(TempStr,35); Result:='21:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString); GetLengthTString(TempStr,35); Result:='22:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetMARKSString:String; var TempStr:TStringList; begin TempStr:=TStringList.Create; try TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString); GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,70)+''''; finally FreeAndNil(TempStr); end; end; begin 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; end; end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; end; SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; strType:='9'; if frm_op_seae.dxdbgrid1.SelectedCount<=1 then begin str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; if CheckBoxwt.Checked then str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':'+ SenderCode+':' +'::::::'+FormatDateTime('YYYYMMDDHHMM',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':'+':::::'+ #39) else str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':'+ SenderCode+':' +'::::::'+FormatDateTime('YYYYMMDDHHMM',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':'+':::::'+ #39); str.add('03:'+ '::' ///////////// + trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(frm_op_seae.t_op_seae.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(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); str.Add('11::' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + 'V.'+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)+':::::' +FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':::::' +#39); //船舶经营人 str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); end else begin str.Add ('14:'+'P'+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asstring)<>'' then Str.Add(GetRemarksString); Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); str.Add ('41:::'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) +'::' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('温度单位').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; Str.Add(GetMARKSString); sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString); GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+sl.Strings[L]+':'; end else begin if M=5 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+11; strRmain:=''; if trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'F:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'F:'+':'+':'+':'+':'+'N'+#39; end; strsql:='select 编号,尺寸,箱型,sum(数量) as 数量 from t_op_ctn group by 编号,尺寸,箱型 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+trim(rs.fieldbyname('尺寸').asstring)+ trim(rs.fieldbyname('箱型').asstring)+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end else begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'L:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39; end; str.Add('48:'+':'+':'+strRmain); Count:=Count+1; end; str.Add ('99:'+ inttostr(Count+2)+#39); end else begin str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ ReciverCode +':'+ GetDatetime(datetimetostr(now),1) +#39); Count:=0; for k:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[k])); if CheckBoxwt.Checked then str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':'+ SenderCode+':' +'::::::'+FormatDateTime('YYYYMMDDHHMM',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':'+':::::'+ #39) else str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':'+ SenderCode+':' +'::::::'+FormatDateTime('YYYYMMDDHHMM',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':'+':::::'+ #39); str.add('03:'+ '::' ///////////// + trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(frm_op_seae.t_op_seae.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(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); str.Add('11::' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + 'V.'+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)+':::::' +FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.FieldByName('开船日期').AsDateTime)+':::::' +#39); //船舶经营人 str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); end else begin str.Add ('14:'+'P'+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); end; if trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asstring)<>'' then Str.Add(GetRemarksString); Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); str.Add ('41:::'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) +'::' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('温度单位').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; Str.Add(GetMARKSString); sl1.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString); GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+sl.Strings[L]+':'; end else begin if M=5 then s:=s+sl.Strings[L] else s:=s+sl.Strings[L]+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+sl.Strings[L]+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+11; strRmain:=''; if trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'F:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'F:'+':'+':'+':'+':'+'N'+#39; end; strsql:='select 编号,尺寸,箱型,sum(数量) as 数量 from t_op_ctn group by 编号,尺寸,箱型 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+trim(rs.fieldbyname('尺寸').asstring)+ trim(rs.fieldbyname('箱型').asstring)+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end else begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'L:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39; end; str.Add('48:'+':'+':'+strRmain); Count:=Count+1; end; end; count:=str.count; str.Add ('99:'+ inttostr(Count+1)+#39); end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('船名').asstring+formatdatetime('YYYYMMDDHHMM',now); if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; freeandnil(str); freeandnil(sl1); freeandnil(sl); inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('EDI','YHSEND',edit1.text); inifile1.WriteString('EDI','YHRECIEVE',edit2.text); inifile1.WriteBool('EDI','YHWT',CheckBoxwt.Checked); inifile1.free; close; end; function Tfrm_op_seae_edi_yh.FormatEdiString(old: String): 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_yh.FormatListString(Old: TStrings; mCount, Strlength: integer): String; var i:integer; NewStrs:TStrings; mStr:String; begin Result:=''; NewStrs:=TStringList.Create; for i:=0 to old.Count-1 do begin if Length(old.Strings[i])<=Strlength then begin if (Trim(old.Strings[i])<>'') and (Trim(old.Strings[i])<>#10) then NewStrs.Add(old.Strings[i]); end else begin mStr:=old.Strings[i]; while length(mStr)>Strlength do begin newStrs.Add(copy(mStr,1,Strlength)); system.Delete(mStr,1,Strlength); end; newStrs.Add(mStr); end; end; try for i:=0 to mCount-1 do begin if i4 then begin result:=false; MessageDlg('危险品编号必须是4位数字',mtWarning,[mbOk],0); exit; end; } end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='R' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring)='' then begin result:=false; MessageDlg('设置温度不能为空',mtWarning,[mbOk],0); exit; end; { if Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)='' then begin result:=false; MessageDlg('冷藏通风量不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring)='' then begin result:=false; MessageDlg('最低温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring)='' then begin result:=false; MessageDlg('最高温度不能为空',mtWarning,[mbOk],0); exit; end; } end; { t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; t_op_ctn.open; if t_op_ctn.IsEmpty then begin result:=false; MessageDlg('集装箱不能为空',mtWarning,[mbOk],0); exit; end; t_op_ctn.First; while not t_op_ctn.Eof do begin if Trim(GetCntrEdi(t_op_ctn.fieldbyname('代码').asstring))='' then begin result:=false; MessageDlg('集装箱EDI代码不存在!',mtWarning,[mbOk],0); exit; end; t_op_ctn.Next; end; } end; procedure Tfrm_op_seae_edi_yh.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_yh.GetLengthword(var s: String; l: Integer; str: String): String; var i:Integer; b:Boolean; begin s:=''; if Length(str)