|
|
unit u_op_seae_edi_kam;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon,
|
|
|
Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB;
|
|
|
|
|
|
type
|
|
|
Tfrm_op_seae_edi_kam = class(TForm)
|
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
|
Label2: TLabel;
|
|
|
Edit2: TEdit;
|
|
|
Edit1: TEdit;
|
|
|
Label1: TLabel;
|
|
|
SaveDialog1: TSaveDialog;
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
bsSkinButton3: TbsSkinButton;
|
|
|
t_op_ctn: TADOQuery;
|
|
|
t_op_ctn1: TDataSource;
|
|
|
bsSkinRadioGroup1: TbsSkinRadioGroup;
|
|
|
Label3: TLabel;
|
|
|
Edit3: TEdit;
|
|
|
bsSkinRadioGroup2: TbsSkinRadioGroup;
|
|
|
bsSkinButton4: TbsSkinButton;
|
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
|
Label4: TLabel;
|
|
|
Label5: TLabel;
|
|
|
Label6: TLabel;
|
|
|
Label7: TLabel;
|
|
|
Edit4: TEdit;
|
|
|
Edit5: TEdit;
|
|
|
Edit6: TEdit;
|
|
|
Edit7: TEdit;
|
|
|
t_op_ams: TADOQuery;
|
|
|
t_op_ams1: TDataSource;
|
|
|
t_op_seae_assistant: TADOQuery;
|
|
|
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
|
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
procedure bsSkinButton3Click(Sender: TObject);
|
|
|
procedure bsSkinButton4Click(Sender: TObject);
|
|
|
private
|
|
|
function isEditrue(DataSet:TDataSet): boolean; //判断必填项
|
|
|
function GetStrNum(str:String):integer;//判断数字位数
|
|
|
function FormatListString(Old:TStrings;mCount,Strlength:integer):String;//根据长度要求格式化字符串
|
|
|
function FormatEdiString(str:String;Strlength:integer=0):String;//特殊字符加 :
|
|
|
function CreateEdiFile:TStrings;//订舱报文
|
|
|
function GetLengthword(var s: String; l: Integer;str:String): String;//根据长度要求截取字符串
|
|
|
procedure GetLengthTString(var sl:TStringList;l:integer);//根据长度格式化 tstringlist
|
|
|
function IsZhongwen(Str:String):Boolean;//是否包含中文或双字节字符
|
|
|
|
|
|
|
|
|
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
function ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String;
|
|
|
|
|
|
function GetShipEdiNO(Ship:String): String;
|
|
|
function GetDepotEdiNO(Ship:String): String;
|
|
|
function GetPortEdiID(Port:String): String;
|
|
|
function GetCntrEdi(cntrsize: String):String;
|
|
|
|
|
|
function GetCorpsString(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
|
|
|
function GetvesselEdi(avessel: String): String;
|
|
|
|
|
|
|
|
|
function GetpkgsEdi(pkgs:String):String;//包装EDI代码
|
|
|
|
|
|
function GetShipEName(Ship:String): String;
|
|
|
|
|
|
function Record00_SO_SI(strType,SenderCode,ReciverCode:string):String;
|
|
|
function Record02_SO(SenderCode,ReciverCode:string;aDataset:TDataset):String;
|
|
|
function Record03_SO(SenderCode,ReciverCode:string;aDataset:TDataset):String;
|
|
|
function Record10_SI(aDataset:TDataset):String;
|
|
|
function Record11_SO(aDataset:TDataset):String;
|
|
|
function Record11_SI(aDataset:TDataset):String;
|
|
|
function Record12_SO(aDataset:TDataset):String;
|
|
|
function Record12_SI(aDataset:TDataset):String;
|
|
|
function Record13_SI(aDataset:TDataset):String;
|
|
|
function Record15_SO(aDataset:TDataset):String;
|
|
|
function Record15_SI(aDataset:TDataset):String;
|
|
|
function Record20_21_22_SO(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
function Record16_17_18_SI(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
|
|
|
function Record17_SO(aDataset:TDataset):String;
|
|
|
|
|
|
function Record21_SI(SenderCode:string;aDataset:TDataset):String;
|
|
|
function Record23_SO(SenderCode:string;aDataset:TDataset):String;
|
|
|
function Record41_SO(aLineno:string;aDataset:TDataset):String;
|
|
|
function Record41_SI(aLineno:string;aDataset:TDataset):String;
|
|
|
function Record43_SO(aDataset:TDataset):String;
|
|
|
function Record43_SI(aDataset:TDataset):String;
|
|
|
function Record44_47_SO_SI(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
function Record48_SO(aDataset:TDataset):TStringlist;
|
|
|
function Record49(aDataset:TDataset):String;
|
|
|
function Record51_SO(aLineno:string;aDataset:TDataset):String;
|
|
|
function Record51_SI(alineno:string;aDataset:TDataset):String;
|
|
|
|
|
|
|
|
|
// function Record48(aDataset:TDataset):TStringlist;
|
|
|
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_op_seae_edi_kam: Tfrm_op_seae_edi_kam;
|
|
|
|
|
|
CheckError:Boolean=False;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_op_seae, u_main, my_sys_function, u_data_share;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.ControlLines(LinesCount,CorpTypeid,BsTypeid:Integer;SName:string):String;
|
|
|
begin
|
|
|
Result:='';
|
|
|
if LinesCount>5 then
|
|
|
begin
|
|
|
case CorpTypeid of
|
|
|
0:begin
|
|
|
case BsTypeid of
|
|
|
0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:*加多出部分';
|
|
|
1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:*加多出部分';
|
|
|
end;
|
|
|
end;
|
|
|
1:begin
|
|
|
case BsTypeid of
|
|
|
0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:**加多出部分';
|
|
|
1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:**加多出部分';
|
|
|
end;
|
|
|
end;
|
|
|
2:begin
|
|
|
case BsTypeid of
|
|
|
0: Result:=SName+'详细信息超过5行,超出部分请在基本信息货描中填写格式为:***加多出部分';
|
|
|
1: Result:=SName+'详细信息超过5行,超出部分请在装箱明细最后一个货描中填写格式为:***加多出部分';
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.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:=Trim(FieldByName('Edi代码').AsString);
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.GetShipEName(Ship:String): String;
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select 英文全称 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_kam.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 客户简称='''+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_kam.GetDepotEdiNO(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 客户简称='''+Ship+'''');
|
|
|
SQL.Add('order by 代码');
|
|
|
Open;
|
|
|
if not IsEmpty then
|
|
|
if Trim(FieldByName('EDI代码').asstring)<>'' then
|
|
|
Result:=Trim(FieldByName('EDI代码').asstring)
|
|
|
else Result:=Trim(FieldByName('代码').asstring)
|
|
|
else
|
|
|
Result:='';
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.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_kam.GetCntrEdi(cntrsize: String):String;
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select MSC代码 Edi代码 from t_code_ctn where 代码='''+cntrsize+'''');
|
|
|
Open;
|
|
|
if IsEmpty then
|
|
|
Result:=''
|
|
|
else
|
|
|
Result:=FieldByName('Edi代码').AsString;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.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_kam.GetCorpsString(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
var
|
|
|
TempStr:TStringList;
|
|
|
aAdoQuery:TAdoQuery;
|
|
|
shipNo,consigneeno,notifyno:string;
|
|
|
begin
|
|
|
aAdoQuery:=CreateAdoQuery;
|
|
|
with aAdoQuery do
|
|
|
try
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('select * from t_op_kam where 编号=:编号');
|
|
|
Parameters.ParamByName('编号').Value:=aDataset.fieldbyname('编号').asstring;
|
|
|
Open;
|
|
|
shipNo:=trim(fieldbyname('发货人代码').asstring);
|
|
|
consigneeno:=trim(fieldbyname('收货人代码').asstring);
|
|
|
notifyno:=trim(fieldbyname('通知人代码').asstring);
|
|
|
finally
|
|
|
// Free;
|
|
|
end;
|
|
|
CheckError:=False;
|
|
|
|
|
|
TempStr:=TStringList.Create;
|
|
|
try
|
|
|
TempStr.Text:=FormatEdiString(aDataset.fieldbyname(fldName).AsString);
|
|
|
GetLengthTString(TempStr,60);
|
|
|
if (recordno='16') or (recordno='20') then
|
|
|
Result:=recordno+':'+shipNo;
|
|
|
if (recordno='17') or (recordno='21') then
|
|
|
Result:=recordno+':'+consigneeno;
|
|
|
|
|
|
if (recordno='18') or (recordno='22') then
|
|
|
Result:=recordno+':'+notifyno;
|
|
|
|
|
|
if (recordno='16') or (recordno='17') or (recordno='18') then
|
|
|
begin
|
|
|
Result:=Result+':';
|
|
|
Result:=Result+FormatListString(TempStr,2,60)+':'; //取两个 3:发货人名称 4:发货人详细地址
|
|
|
|
|
|
end;
|
|
|
if (recordno='20') or (recordno='21') or (recordno='22') then
|
|
|
begin
|
|
|
Result:=Result+':';
|
|
|
Result:=Result+FormatListString(TempStr,6,60)+#39;
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
FreeAndNil(TempStr);
|
|
|
end;
|
|
|
|
|
|
with aAdoQuery do
|
|
|
try
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('select * from t_op_ams where 编号=:编号');
|
|
|
Parameters.ParamByName('编号').Value:=aDataset.fieldbyname('编号').asstring;
|
|
|
Open;
|
|
|
|
|
|
finally
|
|
|
// Free;
|
|
|
end;
|
|
|
|
|
|
if aAdoQuery.RecordCount=0 then
|
|
|
begin
|
|
|
CheckError:=True;
|
|
|
Exit;
|
|
|
end;
|
|
|
if ( (aAdoQuery.fieldbyname('发货人联系电话').IsNull) or (Trim(aAdoQuery.fieldbyname('发货人联系电话').AsString)='') )
|
|
|
and ( (aAdoQuery.fieldbyname('发货人邮箱').IsNull) or (Trim(aAdoQuery.fieldbyname('发货人邮箱').AsString)='') )
|
|
|
and ( (aAdoQuery.fieldbyname('发货人电传').IsNull) or (Trim(aAdoQuery.fieldbyname('发货人电传').AsString)='') )
|
|
|
and (bsSkinRadioGroup2.ItemIndex=1) then
|
|
|
begin
|
|
|
CheckError:=True;
|
|
|
Exit;
|
|
|
end;
|
|
|
|
|
|
|
|
|
if (recordno='16') then
|
|
|
begin
|
|
|
Result:=Result+aAdoQuery.fieldbyname('发货人联系电话').AsString+':'; //5 发货人电话号码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('发货人邮箱').AsString+':'; //6 发货人邮箱
|
|
|
Result:=Result+aAdoQuery.fieldbyname('发货人电传').AsString+':'; //7 发货人电传
|
|
|
Result:=Result+':'; //8 城市名称
|
|
|
Result:=Result+':'; //9 省份代码
|
|
|
Result:=Result+':'; //10 省份名称
|
|
|
Result:=Result+':'; //11 邮政编码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('发货人国家代码').AsString+':'; //12 发货人国家代码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('发货人企业代码').AsString+':'; //发货人企业代码
|
|
|
Result:=Result+#39;
|
|
|
end;
|
|
|
if (recordno='17') then
|
|
|
begin
|
|
|
Result:=Result+aAdoQuery.fieldbyname('收货人联系电话').AsString+':'; //5 收货人电话号码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('收货人邮箱').AsString+':'; //6 收货人邮箱
|
|
|
Result:=Result+aAdoQuery.fieldbyname('收货人电传').AsString+':'; //7 收货人电传
|
|
|
Result:=Result+':'; //8 城市名称
|
|
|
Result:=Result+':'; //9 省份代码
|
|
|
Result:=Result+':'; //10 省份名称
|
|
|
Result:=Result+':'; //11 邮政编码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('收货人国家代码').AsString+':'; //12 收货人国家代码
|
|
|
Result:=Result+':'; //13 具体联系人名称
|
|
|
Result:=Result+':'; // 14 具体联系人EMAIL地址(EM)
|
|
|
Result:=Result+':'; // 15 具体联系人电传号码(FX)
|
|
|
Result:=Result+':'; // 16 具体联系人电话号码(TE)
|
|
|
Result:=Result+aAdoQuery.fieldbyname('收货人企业代码').AsString+':'; // 17 收货人企业代码
|
|
|
Result:=Result+#39;
|
|
|
end;
|
|
|
if (recordno='18') then
|
|
|
begin
|
|
|
Result:=Result+aAdoQuery.fieldbyname('通知人联系电话').AsString+':'; //5 通知人电话号码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('通知人邮箱').AsString+':'; //6 通知人邮箱
|
|
|
Result:=Result+aAdoQuery.fieldbyname('通知人电传').AsString+':'; //7 通知人电传
|
|
|
Result:=Result+':'; //8 城市名称
|
|
|
Result:=Result+':'; //9 省份代码
|
|
|
Result:=Result+':'; //10 省份名称
|
|
|
Result:=Result+':'; //11 邮政编码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('通知人国家代码').AsString+':'; // 12 国家代码
|
|
|
Result:=Result+aAdoQuery.fieldbyname('通知人企业代码').AsString+':'; //13 通知人企业代码
|
|
|
Result:=Result+#39;
|
|
|
end;
|
|
|
FreeAndNil(aAdoQuery);
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record00_SO_SI(strType,SenderCode,ReciverCode:string):String;
|
|
|
begin
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
result:='00:IFTMBF:BOOKING'+':'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39
|
|
|
else result:='00:IFCSUM:MANIFEST'+':'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39;
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record02_SO(SenderCode,ReciverCode:string;aDataset:TDataset):String;
|
|
|
var billno,s:String;
|
|
|
strtype,billtype:string;
|
|
|
sl:Tstringlist;
|
|
|
begin
|
|
|
sl:=Tstringlist.Create;
|
|
|
sl.Text:=FormatEdiString(aDataset.fieldbyname('货物描述').AsString);
|
|
|
if sl.Text<>'' then
|
|
|
s:=sl[0];
|
|
|
|
|
|
billtype:='';
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
|
billtype:='Y';
|
|
|
|
|
|
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strtype:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
billno:=trim(aDataset.fieldbyname('主提单号').asstring);
|
|
|
result:='02'+':'+billno // 2
|
|
|
+':'+billno // 3
|
|
|
+':'+ trim(aDataset.fieldbyname('运输条款').asstring) //4
|
|
|
+':' //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':' //10
|
|
|
+':' //11
|
|
|
+':' // 12
|
|
|
+':' //13
|
|
|
+':' //14
|
|
|
+':'+strtype //15
|
|
|
+':' //16
|
|
|
+':' //17
|
|
|
+':' //18
|
|
|
+':'+billtype //19
|
|
|
+':'+aDataset.fieldbyname('运费协议号').asstring //20
|
|
|
+':'+'100001' //21
|
|
|
+':'+'GENERAL CARGO' //22
|
|
|
+':'+s //23
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record03_SO(SenderCode,ReciverCode:string;aDataset:TDataset):String;
|
|
|
var mbltype,Str1,Str2,ISSUECODE:string;
|
|
|
begin
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)<>'正本' then
|
|
|
mbltype:='W'
|
|
|
else mbltype:='O';
|
|
|
|
|
|
|
|
|
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
|
|
|
Str2:='1'
|
|
|
else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='TWO' then
|
|
|
Str2:='2'
|
|
|
else if frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring='THREE' then
|
|
|
Str2:='3';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ISSUECODE:=GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring));
|
|
|
result:='03'+':'+'KKC' // 2
|
|
|
+':'+ISSUECODE // 3
|
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) //4
|
|
|
+':'+GetDatetime(datetimetostr(frm_op_seae.t_op_seae.fieldbyname('签单日期').asDatetime),0) //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+#39;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record10_SI(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='10:'+GetvesselEdi(trim(aDataset.fieldbyname('船名').asstring))
|
|
|
+':'+trim(aDataset.fieldbyname('船名').asstring) // 3
|
|
|
+':' //4
|
|
|
+':'+ trim(aDataset.fieldbyname('航次').asstring)//5
|
|
|
+':::' //678
|
|
|
+':' //9
|
|
|
+':' //10
|
|
|
+'::::' //11 12 13 14
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record11_SO(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='11:'+GetvesselEdi(trim(aDataset.fieldbyname('船名').asstring))
|
|
|
+':'+trim(aDataset.fieldbyname('船名').asstring) // 3
|
|
|
+':'+ trim(aDataset.fieldbyname('航次').asstring)//4
|
|
|
+':::' //5 6 7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':' //10
|
|
|
+'::::' //11 12 13 14
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record11_SI(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='11:'+'KKC'
|
|
|
+':'
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record12_SO(aDataset:TDataset):String;
|
|
|
var czNo:string;
|
|
|
begin
|
|
|
if GetShipEdiNO(aDataset.fieldbyname('场站').asstring)='' then
|
|
|
czNo:='YZH-EMSKP'
|
|
|
else czNo:=GetShipEdiNO(aDataset.fieldbyname('场站').asstring);
|
|
|
|
|
|
result:='12'+':'+ trim(aDataset.fieldbyname('装港代码').asstring) // 2
|
|
|
+':'+ trim(aDataset.fieldbyname('装货港').asstring) //3
|
|
|
+':' + trim(aDataset.fieldbyname('装港代码').asstring) //4
|
|
|
+':' + trim(aDataset.fieldbyname('装货港').asstring) //5
|
|
|
+':'+trim(aDataset.fieldbyname('卸货代码').asstring)//6
|
|
|
+':'+trim(aDataset.fieldbyname('卸货港').asstring) //7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':'+trim(aDataset.fieldbyname('交货代码').asstring) //10
|
|
|
+':'+trim(aDataset.fieldbyname('交货地点').asstring) // 11
|
|
|
+':' //12
|
|
|
+':' //13
|
|
|
+':'+czNo //14
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record12_SI(aDataset:TDataset):String;
|
|
|
var strtype:string;
|
|
|
begin
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strtype:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
|
|
|
result:='12'
|
|
|
+':'+ trim(aDataset.fieldbyname('主提单号').asstring) // 2
|
|
|
+':' // 3
|
|
|
+':' //4
|
|
|
+':' //5
|
|
|
+':'+ trim(aDataset.fieldbyname('装港代码').asstring) //6
|
|
|
+':' + trim(aDataset.fieldbyname('装货港').asstring) //7
|
|
|
+':' + trim(aDataset.fieldbyname('卸货代码').asstring) //8
|
|
|
+':'+trim(aDataset.fieldbyname('卸货港').asstring)//9
|
|
|
+':'+trim(aDataset.fieldbyname('运输条款').asstring) //10
|
|
|
+':'+strtype //11
|
|
|
+':'+FormatDateTime('YYYYMMDD',Date) //12
|
|
|
+':' //13
|
|
|
+':' // 14
|
|
|
+':' //15
|
|
|
+':' //16
|
|
|
+':' //17
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record13_SI(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='13'
|
|
|
+':' + trim(aDataset.fieldbyname('卸货代码').asstring) //2
|
|
|
+':'+trim(aDataset.fieldbyname('卸货港').asstring)//3
|
|
|
+':'+ trim(aDataset.fieldbyname('交货代码').asstring) //4
|
|
|
+':' + trim(aDataset.fieldbyname('交货地点').asstring) //5
|
|
|
+':' //6
|
|
|
+':'//7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':' // 10
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record15_SO(aDataset:TDataset):String;
|
|
|
var strtype:string;
|
|
|
begin
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strtype:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
result:='15'
|
|
|
+':' //2
|
|
|
+':' //3
|
|
|
+':'+ strtype //4
|
|
|
+':::::::' //5-11
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record15_SI(aDataset:TDataset):String;
|
|
|
var strtype:string;
|
|
|
begin
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strtype:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
result:='15'
|
|
|
+':' //2
|
|
|
+':' //3
|
|
|
+':'+ strtype //4
|
|
|
+':::::' //5 6 7 8 9
|
|
|
+':' //10
|
|
|
+':'+strtype //5-11
|
|
|
+#39;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record20_21_22_SO(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:=GetCorpsString(recordno,fldName,aDataset);//+'''';
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record16_17_18_SI(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:=GetCorpsString(recordno,fldName,aDataset);//+'''';
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record17_SO(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='17'
|
|
|
+':'+GetDepotEdiNO(aDataset.fieldbyname('场站').asstring) //2
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record21_SI(SenderCode:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='21'
|
|
|
+':'+SenderCode //2
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record23_SO(SenderCode:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='23'
|
|
|
+':'+SenderCode //2
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record41_SO(alineno:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='41'
|
|
|
+':'+alineno //2
|
|
|
+':'+trim(aDataset.fieldbyname('运输方式').asstring) // 3
|
|
|
+':' //4
|
|
|
+':'+trim(aDataset.fieldbyname('件数').asstring) //5
|
|
|
+':'+ GetpkgsEdi(trim(aDataset.fieldbyname('包装').asstring)) //6
|
|
|
+':'+ trim(aDataset.fieldbyname('包装').asstring) //7
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) //8
|
|
|
+':'+ trim(aDataset.fieldbyname('尺码').asstring) //9
|
|
|
+':' //10
|
|
|
+':' //11
|
|
|
+':' //12
|
|
|
+':' //13
|
|
|
+':' //14
|
|
|
+':'+trim(aDataset.fieldbyname('重量').asstring) //15
|
|
|
+':' //16
|
|
|
+':' //17
|
|
|
+':' //18
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record41_SI(alineno:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='41'
|
|
|
+':'+alineno //2
|
|
|
+':'+trim(aDataset.fieldbyname('运输方式').asstring) // 3
|
|
|
+':'+trim(aDataset.fieldbyname('件数').asstring) //4
|
|
|
+':'+ trim(aDataset.fieldbyname('包装').asstring) //5
|
|
|
+':'+ GetpkgsEdi(trim(aDataset.fieldbyname('包装').asstring)) //6
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) //7
|
|
|
+':' //8
|
|
|
+':'+ trim(aDataset.fieldbyname('尺码').asstring) //9
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record43_SO(aDataset:TDataset):String;
|
|
|
begin
|
|
|
if (trim(aDataset.fieldbyname('货物标识').asstring)='D') or (trim(aDataset.fieldbyname('货物标识').asstring)='R') THEN
|
|
|
begin
|
|
|
result:='43'
|
|
|
+':'+trim(aDataset.fieldbyname('危险品分类').asstring) //2
|
|
|
+':' //3
|
|
|
+':'+trim(aDataset.fieldbyname('危险品编号').asstring) //4
|
|
|
+':' //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':' //10
|
|
|
+':' //11
|
|
|
+':C' //12
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) //13
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) //14
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) //15
|
|
|
+':' //16
|
|
|
+':' //17
|
|
|
+':' //18
|
|
|
+':' //19
|
|
|
+':' //20
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record43_SI(aDataset:TDataset):String;
|
|
|
begin
|
|
|
if (trim(aDataset.fieldbyname('货物标识').asstring)='D') OR (trim(aDataset.fieldbyname('货物标识').asstring)='R') THEN
|
|
|
begin
|
|
|
result:='43'
|
|
|
+':'+trim(aDataset.fieldbyname('危险品分类').asstring) //2
|
|
|
+':' //3
|
|
|
+':'+trim(aDataset.fieldbyname('危险品编号').asstring) //4
|
|
|
+':' //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':' //10
|
|
|
+':' //11
|
|
|
+':C' //12
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) //13
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) //14
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) //15
|
|
|
+':' //16
|
|
|
+':' //17
|
|
|
+':' //18
|
|
|
+':' //19
|
|
|
+':' //20
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record44_47_SO_SI(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
var sl,sl1:Tstringlist;
|
|
|
m,l:integer;
|
|
|
s:string;
|
|
|
begin
|
|
|
result:=Tstringlist.Create;
|
|
|
sl:=Tstringlist.Create;
|
|
|
sl1:=Tstringlist.Create;
|
|
|
try
|
|
|
sl1.Text:=FormatEdiString(aDataset.fieldbyname(FldName).AsString);
|
|
|
GetLengthTString(sl1,strLen);
|
|
|
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<=LoopCount then begin
|
|
|
if M=1 then begin
|
|
|
s:=RecordNo+':'+sl.Strings[L]+':';
|
|
|
end else begin
|
|
|
if M=LoopCount then
|
|
|
s:=s+sl.Strings[L]
|
|
|
else
|
|
|
s:=s+sl.Strings[L]+':';
|
|
|
end;
|
|
|
end else begin
|
|
|
S:=S+'''';
|
|
|
result.Add(S);
|
|
|
M:=1;
|
|
|
s:=RecordNo+':'+sl.Strings[L]+':';
|
|
|
end;
|
|
|
M:=M+1;
|
|
|
end;
|
|
|
S:=S+'''';
|
|
|
result.Add(S);
|
|
|
finally
|
|
|
sl.Free;
|
|
|
sl1.Free;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record48_SO(aDataset:TDataset):TStringlist;
|
|
|
var strsql,strtype:string;
|
|
|
rs:TADOQuery;
|
|
|
begin
|
|
|
if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then
|
|
|
strtype:='Y'
|
|
|
ELSE strtype:='N';
|
|
|
|
|
|
|
|
|
result:=TStringlist.Create;
|
|
|
strsql:='select 代码,编号,尺寸,箱型,sum(数量) as 数量 from t_op_ctn group by 代码,编号,尺寸,箱型 having 编号='
|
|
|
+#39+aDataset.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
|
|
|
result.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) //2
|
|
|
+':'+trim(rs.fieldbyname('数量').asstring) //3
|
|
|
+':'+'F' //4
|
|
|
+':' //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+':'+strtype //9
|
|
|
+#39);
|
|
|
rs.Next;
|
|
|
end;
|
|
|
finally
|
|
|
rs.Close;
|
|
|
rs.Destroy;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record49(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='49'
|
|
|
+':'+trim(aDataset.fieldbyname('箱号').asstring) // 2
|
|
|
+':'+trim(aDataset.fieldbyname('件数').asstring) //3
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) //4
|
|
|
+':'+ trim(aDataset.fieldbyname('尺码').asstring) //5
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record51_SO(alineno:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='51'
|
|
|
+':' // 2
|
|
|
+':'+ trim(GetCntrEdi(aDataset.fieldbyname('代码').asstring)) //3
|
|
|
+':' //4
|
|
|
+':' //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //9
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.Record51_SI(alineno:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='51'
|
|
|
+':'+alineno // 2
|
|
|
+':'+trim(aDataset.fieldbyname('箱号').asstring) //3
|
|
|
+':'+ trim(GetCntrEdi(aDataset.fieldbyname('代码').asstring)) //4
|
|
|
+':'+ trim(aDataset.fieldbyname('封号').asstring) //5
|
|
|
+':' //6
|
|
|
+':' //7
|
|
|
+':' //8
|
|
|
+':' //9
|
|
|
+':'+ trim(aDataset.fieldbyname('件数').asstring) //10
|
|
|
+':'+ trim(aDataset.fieldbyname('包装').asstring) //11
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) //12
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) //13
|
|
|
+':'+ trim(aDataset.fieldbyname('尺码').asstring) //14
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.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) then begin
|
|
|
Result:=True;
|
|
|
Exit;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.GetLengthword(var s: String; l: Integer;str:String): String;
|
|
|
var
|
|
|
i:Integer;
|
|
|
b:Boolean;
|
|
|
begin
|
|
|
s:='';
|
|
|
if Length(str)<=l then begin
|
|
|
result:=str;
|
|
|
end else begin
|
|
|
b:=true;
|
|
|
s:=Copy(str,l+1,Length(str)-l);
|
|
|
str:=Copy(str,1,l);
|
|
|
result:='';
|
|
|
for i:=Length(str) downto 1 do begin
|
|
|
if ( not (str[i] in [' ',';',',','.',':','/','(',')','?','+','-'])) and b then
|
|
|
s:=str[i]+s
|
|
|
else begin
|
|
|
b:=false;
|
|
|
result:=str[i]+Result;
|
|
|
end;
|
|
|
end;
|
|
|
s:=s+' ';
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.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_kam.FormatEdiString(str:String;Strlength:integer=0):String;
|
|
|
var
|
|
|
i:integer;
|
|
|
strC:widestring;
|
|
|
begin
|
|
|
strC:='';
|
|
|
for i:=1 to length(str) do
|
|
|
begin
|
|
|
if ((str[i]=#39) or (str[i]=':') or (str[i]='+') or (str[i]='?') or (str[i]=';')) then
|
|
|
begin
|
|
|
strC:=strC+'?'+str[i];
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
strC:=strC+str[i];
|
|
|
end;
|
|
|
end;
|
|
|
result:=strC;
|
|
|
{
|
|
|
Result:=Trim(str);
|
|
|
Result:=StringReplace(Result,'?','??',[rfReplaceAll]);
|
|
|
Result:=StringReplace(Result,':','?:',[rfReplaceAll]);
|
|
|
Result:=StringReplace(Result,'''','?''',[rfReplaceAll]);
|
|
|
Result:=StringReplace(Result,'+','?+',[rfReplaceAll]);
|
|
|
}
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.FormatListString(Old:TStrings;mCount,Strlength:integer):String;
|
|
|
var
|
|
|
i:integer;
|
|
|
NewStrs:TStrings;
|
|
|
mStr:String;
|
|
|
begin
|
|
|
Result:='';
|
|
|
NewStrs:=TStringList.Create;
|
|
|
for i:=0 to old.Count-1 do begin
|
|
|
if Length(old.Strings[i])<=Strlength then begin
|
|
|
NewStrs.Add(old.Strings[i]);
|
|
|
end else begin
|
|
|
mStr:=old.Strings[i];
|
|
|
while length(mStr)>Strlength do begin
|
|
|
newStrs.Add(copy(mStr,1,Strlength));
|
|
|
system.Delete(mStr,1,Strlength);
|
|
|
end;
|
|
|
newStrs.Add(mStr);
|
|
|
end;
|
|
|
end;
|
|
|
try
|
|
|
for i:=0 to mCount-1 do begin
|
|
|
if i<NewStrs.Count then begin
|
|
|
Result:=Result+NewStrs.Strings[i];
|
|
|
end;
|
|
|
if i<mCount-1 then
|
|
|
Result:=Result+':';
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(NewStrs);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.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;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.bsSkinButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.FormShow(Sender: TObject);
|
|
|
var
|
|
|
inifile1:Tinifile;
|
|
|
begin
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
edit1.text:=inifile1.ReadString('EDI','kamSEND','');
|
|
|
edit2.text:=inifile1.ReadString('EDI','kamRECIEVE','123456');
|
|
|
edit3.text:=inifile1.ReadString('EDI','kamSENDNAME','');
|
|
|
edit4.text:=inifile1.ReadString('EDI','kamFTPSERVER',get_parameters_value(77,''));
|
|
|
edit5.text:=inifile1.ReadString('EDI','kamFTPPATH',get_parameters_value(78,'/'));
|
|
|
edit6.text:=inifile1.ReadString('EDI','kamFTPNAME',get_parameters_value(79,''));
|
|
|
edit7.text:=inifile1.ReadString('EDI','kamFTPPASS',get_parameters_value(80,''));
|
|
|
inifile1.free;
|
|
|
CheckError:=False;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.bsSkinButton1Click(Sender: TObject);
|
|
|
var
|
|
|
Str:TStrings;
|
|
|
inifile1:Tinifile;
|
|
|
i:integer;
|
|
|
begin
|
|
|
str:=Tstringlist.Create;
|
|
|
try
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
Str:=CreateEdiFile
|
|
|
else
|
|
|
Str:=CreateEdiFile
|
|
|
else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then
|
|
|
else
|
|
|
begin
|
|
|
Exit;
|
|
|
end;
|
|
|
|
|
|
for i:=0 to Str.Count-1 do begin
|
|
|
if IsZhongwen(Str[i]) then begin
|
|
|
if MessageDlg('此票业务可能含有中文字符或其他不规范字符 ('+Str[i]+') ,确实要继续上传吗!',mtWarning,[mbYes,mbNo],0)=mrNo then
|
|
|
exit;
|
|
|
end;
|
|
|
end;
|
|
|
if CheckError and (bsSkinRadioGroup2.ItemIndex=1) then Exit;
|
|
|
|
|
|
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring;
|
|
|
if SaveDialog1.Execute then
|
|
|
begin
|
|
|
str.SaveToFile(SaveDialog1.FileName+'.txt');
|
|
|
showmessage('文件生成成功!');
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
showmessage('文件生成失败!');
|
|
|
exit;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(Str)
|
|
|
end;
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
inifile1.WriteString('EDI','kamSEND',edit1.text);
|
|
|
inifile1.WriteString('EDI','kamRECIEVE',edit2.text);
|
|
|
inifile1.WriteString('EDI','kamSENDNAME',edit3.text);
|
|
|
inifile1.WriteString('EDI','kamFTPSERVER',edit4.text);
|
|
|
inifile1.WriteString('EDI','kamFTPPATH',edit5.text);
|
|
|
inifile1.WriteString('EDI','kamFTPNAME',edit6.text);
|
|
|
inifile1.WriteString('EDI','kamFTPPASS',edit7.text);
|
|
|
inifile1.free;
|
|
|
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.isEditrue(DataSet:TDataSet): boolean;
|
|
|
var
|
|
|
cntrs,Lines:String;
|
|
|
sl:TStrings;
|
|
|
i:Integer;
|
|
|
aAdoQuery:TAdoQuery;
|
|
|
begin
|
|
|
result:=true;
|
|
|
sl:=TStringList.Create;
|
|
|
{
|
|
|
if trim(DataSet.fieldbyname('主提单号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('提单号不能为空',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aAdoQuery:=CreateAdoQuery;
|
|
|
with aAdoQuery do
|
|
|
try
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('select * from t_op_kam where 编号=:编号');
|
|
|
Parameters.ParamByName('编号').Value:=DataSet.fieldbyname('编号').asstring;
|
|
|
Open;
|
|
|
if IsEmpty then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('发货人,收货人,通知人代码不能为空,请双击发货人输入框维护',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
if (trim(fieldbyname('发货人代码').asstring)='')
|
|
|
or (trim(fieldbyname('收货人代码').asstring)='')
|
|
|
or (trim(fieldbyname('通知人代码').asstring)='') then
|
|
|
begin
|
|
|
// result:=false;
|
|
|
MessageDlg('发货人,收货人,通知人代码不能为空,请双击发货人输入框维护',mtWarning,[mbOk],0);
|
|
|
//exit;
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
Free;
|
|
|
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 GetShipEdiNO(DataSet.fieldbyname('场站').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('场站EDI代码不能为空,请在系统客户 维护 EDI代码',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
|
|
|
{
|
|
|
if GetShipEdiNO(DataSet.fieldbyname('发货人').AsString)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('发货人代码不能为空,请在系统客户 维护代码',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
|
|
|
if GetShipEdiNO(DataSet.fieldbyname('收货人').AsString)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('收货人代码不能为空,请在系统客户 维护代码',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
|
|
|
|
|
|
if GetShipEdiNO(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(DataSet.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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sl.Clear;
|
|
|
sl.Text:=Changestr(DataSet.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;
|
|
|
|
|
|
|
|
|
sl.Clear;
|
|
|
sl.Text:=Changestr(DataSet.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;
|
|
|
|
|
|
sl.Clear;
|
|
|
sl.Text:=Changestr(DataSet.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;
|
|
|
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then begin
|
|
|
t_op_ctn.close;
|
|
|
t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring;
|
|
|
t_op_ctn.open;
|
|
|
if t_op_ctn.IsEmpty then begin
|
|
|
result:=false;
|
|
|
MessageDlg('集装箱不能为空',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
t_op_ctn.First;
|
|
|
while not t_op_ctn.Eof do begin
|
|
|
if Trim(t_op_ctn.fieldbyname('箱号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('箱号不能为空!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
if Trim(t_op_ctn.fieldbyname('封号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('封号不能为空!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
t_op_ctn.Next;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_kam.CreateEdiFile:TStrings;
|
|
|
var str,aTempList:TStringlist;
|
|
|
strType,SenderCode,ReciverCode:string;
|
|
|
i,k,LineNo:integer;
|
|
|
at_op_ctn:TAdoQuery;
|
|
|
begin
|
|
|
try
|
|
|
aTempList:=TStringlist.create;
|
|
|
str:=TStringlist.create;
|
|
|
at_op_ctn:=CreateAdoQuery;
|
|
|
|
|
|
with at_op_ctn,sql do
|
|
|
begin
|
|
|
close;Clear;
|
|
|
add('select * from t_op_ctn');
|
|
|
add('where 编号=:编号');
|
|
|
parameters.ParamByName('编号').Value:='';
|
|
|
end;
|
|
|
|
|
|
SenderCode:=trim(edit1.Text) ;
|
|
|
ReciverCode:=trim(edit2.Text) ;
|
|
|
if bsSkinRadioGroup1.ItemIndex=0 then
|
|
|
strType:='9'
|
|
|
else if bsSkinRadioGroup1.ItemIndex=1 then
|
|
|
strType:='2'
|
|
|
else if bsSkinRadioGroup1.ItemIndex=2 then
|
|
|
strType:='3'
|
|
|
else if bsSkinRadioGroup1.ItemIndex=3 then
|
|
|
strType:='4'
|
|
|
else strType:='9';
|
|
|
I:=0;
|
|
|
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
|
|
|
begin
|
|
|
if not isEditrue(frm_op_seae.t_op_seae) then abort;
|
|
|
I:=0;
|
|
|
|
|
|
str.add(Record00_SO_SI(strType,SenderCode,ReciverCode));
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record02_SO(SenderCode,ReciverCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record03_SO(SenderCode,ReciverCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record10_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record11_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record11_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record12_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record12_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record13_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record15_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record15_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record17_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
begin
|
|
|
str.add(Record16_17_18_SI('16','发货人代码',frm_op_seae.t_op_seae));
|
|
|
if CheckError then
|
|
|
begin
|
|
|
ShowMessage('发货人联系电话、邮箱、传真不能都为空!');
|
|
|
Exit;
|
|
|
end;
|
|
|
str.add(Record16_17_18_SI('17','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record16_17_18_SI('18','通知人代码',frm_op_seae.t_op_seae));
|
|
|
end;
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
begin
|
|
|
str.add(Record20_21_22_SO('20','发货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22_SO('21','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22_SO('22','通知人代码',frm_op_seae.t_op_seae));
|
|
|
// str.add(Record20_21_22_SO('23','代理内容',frm_op_seae.t_op_seae));
|
|
|
end;
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record21_SI(SenderCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record23_SO(SenderCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record41_SO('1',frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record41_SI('1',frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)<>'S' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record43_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)<>'S' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record43_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
aTempList:=Record44_47_SO_SI(35,10,'44','唛头',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
|
|
|
aTempList:=Record44_47_SO_SI(70,5,'47','货物描述',frm_op_seae.t_op_seae);
|
|
|
|
|
|
str.addstrings(aTempList);
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
begin
|
|
|
aTempList:=Record48_SO(frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
end;
|
|
|
|
|
|
|
|
|
LineNo:=1;
|
|
|
with at_op_ctn do
|
|
|
begin
|
|
|
Close;
|
|
|
Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.FieldByName('编号').AsString;
|
|
|
Open;First;
|
|
|
while not eof do
|
|
|
begin
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
//str.add(Record51_SO(IntToStr(LineNo),at_op_ctn))
|
|
|
else
|
|
|
str.add(Record51_SI(IntToStr(LineNo),at_op_ctn));
|
|
|
LineNo:=LineNo+1;
|
|
|
Next;
|
|
|
end;
|
|
|
end;
|
|
|
I:=str.Count;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
I:=0;
|
|
|
str.add(Record00_SO_SI(strType,SenderCode,ReciverCode));
|
|
|
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 bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record02_SO(SenderCode,ReciverCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record03_SO(SenderCode,ReciverCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record10_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record11_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record11_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record12_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record12_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record13_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record15_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record15_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record17_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
begin
|
|
|
str.add(Record16_17_18_SI('16','发货人代码',frm_op_seae.t_op_seae));
|
|
|
if CheckError then
|
|
|
begin
|
|
|
ShowMessage('发货人联系电话、邮箱、传真不能都为空!');
|
|
|
Exit;
|
|
|
end;
|
|
|
str.add(Record16_17_18_SI('17','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record16_17_18_SI('18','通知人代码',frm_op_seae.t_op_seae));
|
|
|
end;
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
begin
|
|
|
str.add(Record20_21_22_SO('20','发货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22_SO('21','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22_SO('22','通知人代码',frm_op_seae.t_op_seae));
|
|
|
// str.add(Record20_21_22_SO('23','代理内容',frm_op_seae.t_op_seae));
|
|
|
end;
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record21_SI(SenderCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record23_SO(SenderCode,frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record41_SO('1',frm_op_seae.t_op_seae));
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record41_SI('1',frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)<>'S' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
str.add(Record43_SO(frm_op_seae.t_op_seae));
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)<>'S' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
str.add(Record43_SI(frm_op_seae.t_op_seae));
|
|
|
|
|
|
|
|
|
aTempList:=Record44_47_SO_SI(35,10,'44','唛头',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
|
|
|
aTempList:=Record44_47_SO_SI(70,5,'47','货物描述',frm_op_seae.t_op_seae);
|
|
|
|
|
|
str.addstrings(aTempList);
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
begin
|
|
|
aTempList:=Record48_SO(frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
end;
|
|
|
|
|
|
|
|
|
LineNo:=1;
|
|
|
with at_op_ctn do
|
|
|
begin
|
|
|
Close;
|
|
|
Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.FieldByName('编号').AsString;
|
|
|
Open;First;
|
|
|
while not eof do
|
|
|
begin
|
|
|
if bsSkinRadioGroup2.ItemIndex=0 then
|
|
|
//str.add(Record51_SO(IntToStr(LineNo),at_op_ctn))
|
|
|
else
|
|
|
str.add(Record51_SI(IntToStr(LineNo),at_op_ctn));
|
|
|
LineNo:=LineNo+1;
|
|
|
Next;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
I:=I+lineno;
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
str.Add('99:'+intToStr(i+1)+'''');
|
|
|
Result:=str;
|
|
|
freeandnil(aTempList);
|
|
|
//freeandnil(str);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.bsSkinButton3Click(Sender: TObject);
|
|
|
var
|
|
|
IdFTP1:TIdFTP;
|
|
|
str:widestring;
|
|
|
str_file:widestring;
|
|
|
ftpar,ftpname,ftppass,ftppath,ScriptPath:String;
|
|
|
StrL:TStrings;
|
|
|
inifile1:Tinifile;
|
|
|
i:integer;
|
|
|
begin
|
|
|
|
|
|
ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\';
|
|
|
if not DirectoryExists(ScriptPath) then
|
|
|
CreateDir(ScriptPath);
|
|
|
|
|
|
ftpar:=Trim(edit4.Text);
|
|
|
if ftpar='' then begin
|
|
|
MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
ftpname:=Trim(edit6.Text);
|
|
|
if ftpar='' then begin
|
|
|
MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
ftppass:=Trim(edit7.Text);
|
|
|
if ftpar='' then begin
|
|
|
MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
ftppath:=Trim(edit5.Text);
|
|
|
|
|
|
str:=ScriptPath
|
|
|
+frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring
|
|
|
+FormatDateTime('yyyy',now)
|
|
|
+FormatDateTime('mm',now)
|
|
|
+FormatDateTime('dd',now)
|
|
|
+FormatDateTime('hh',now)
|
|
|
+FormatDateTime('nn',now)+'.txt';
|
|
|
|
|
|
str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring
|
|
|
+FormatDateTime('yyyy',now)
|
|
|
+FormatDateTime('mm',now)
|
|
|
+FormatDateTime('dd',now)
|
|
|
+FormatDateTime('hh',now)
|
|
|
+FormatDateTime('nn',now)+'.txt';
|
|
|
|
|
|
strL:=Tstringlist.Create;
|
|
|
try
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
StrL:=CreateEdiFile
|
|
|
else
|
|
|
StrL:=CreateEdiFile
|
|
|
else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then
|
|
|
else begin
|
|
|
Exit;
|
|
|
end;
|
|
|
|
|
|
for i:=0 to StrL.Count-1 do begin
|
|
|
if IsZhongwen(StrL[i]) then begin
|
|
|
if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!',mtWarning,[mbYes,mbNo],0)=mrNo then
|
|
|
exit;
|
|
|
end;
|
|
|
end;
|
|
|
if CheckError and (bsSkinRadioGroup2.ItemIndex=1) then Exit;
|
|
|
|
|
|
strL.SaveToFile(str);
|
|
|
finally
|
|
|
FreeAndNil(StrL)
|
|
|
end;
|
|
|
|
|
|
try
|
|
|
|
|
|
IdFTP1:=TIdFTP.Create(application);
|
|
|
with idftp1 do
|
|
|
begin
|
|
|
Username:=ftpname;
|
|
|
Password:=ftppass;
|
|
|
Host:=ftpar;
|
|
|
Connect;
|
|
|
end;
|
|
|
idftp1.ChangeDir(ftppath);
|
|
|
idftp1.TransferType:=ftBinary;
|
|
|
idftp1.Put(str,str_file);
|
|
|
idftp1.Disconnect;
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
inifile1.WriteString('EDI','KAMSEND',edit1.text);
|
|
|
inifile1.WriteString('EDI','KAMRECIEVE',edit2.text);
|
|
|
inifile1.WriteString('EDI','KAMSENDNAME',edit3.text);
|
|
|
inifile1.WriteString('EDI','KAMFTPSERVER',edit4.text);
|
|
|
inifile1.WriteString('EDI','KAMFTPPATH',edit5.text);
|
|
|
inifile1.WriteString('EDI','KAMFTPNAME',edit6.text);
|
|
|
inifile1.WriteString('EDI','KAMFTPPASS',edit7.text);
|
|
|
inifile1.free;
|
|
|
|
|
|
showmessage('文件上传成功!');
|
|
|
except
|
|
|
deletefile(str);
|
|
|
showmessage('文件上传错误!');
|
|
|
end;
|
|
|
idftp1.Free;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_kam.bsSkinButton4Click(Sender: TObject);
|
|
|
begin
|
|
|
if frm_op_seae_edi_kam.Height=349 then
|
|
|
frm_op_seae_edi_kam.Height:=200
|
|
|
else
|
|
|
frm_op_seae_edi_kam.Height:=349;
|
|
|
end;
|
|
|
|
|
|
end.
|