You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1165 lines
36 KiB
Plaintext

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

unit u_op_seae_edi_CSSA;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinCtrls, StdCtrls, ExtCtrls, DB, ADODB,XMLDoc, XMLIntf,
xmldom, msxmldom, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, IdCoder, IdCoder3to4, IdCoderMIME,DateUtils,EncdDecd,Httpapp,
IdHashMessageDigest,IdGlobal, IdHash,U_md5, IdMessage, IdURI,
IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP,IdAttachmentFile;
type
TBytes = array of Byte;
TFrm_op_seae_edi_CSSA = class(TForm)
RadioGroup1: TRadioGroup;
bsSkinButton2: TbsSkinButton;
bsSkinButton1: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
t_op_ctn: TADOQuery;
t_sys_company: TADOQuery;
XMLDocument1: TXMLDocument;
SaveDialog1: TSaveDialog;
IdHTTP1: TIdHTTP;
IdEncoderMIME1: TIdEncoderMIME;
CheckBox1: TCheckBox;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
procedure FormShow(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
private
{ Private declarations }
function GetCompany:String;
function CheckParaExist(para:string):Boolean;
function GetCntrVGM(cntrsize: String):String;
function GetPackVGM(cntrsize: String):String;
function GetECodeVGM(cntrsize: String):String;
function GetTelVGM(cntrsize: String):String;
function GetDepartmentVGM(cntrsize: String):String;
function CheckSendorCode:Boolean;
function IsZhongwen(Str: String): Boolean;
function SeparateEC(Str: String): string;
procedure MakeVGM;
function GetShipVGM(Ship:String): String;
function GetShipFTP(Ship:String): String;
function Changestr(str:widestring):string;
procedure SendFile;
procedure sendmail;
public
{ Public declarations }
end;
var
Frm_op_seae_edi_CSSA: TFrm_op_seae_edi_CSSA;
HasM:Boolean; //ÊÇ·ñÓдí
RequestFile:string;
implementation
uses u_op_seae, my_sys_function, u_main, u_data_share, u_op_seae_assistant;
{$R *.dfm}
function TFrm_op_seae_edi_CSSA.CheckParaExist(para:string):Boolean;
begin
Result:=False;
if Trim(para)<>'' then Result:=True;
end;
//»ñȡʱ¼ä´Á javaÀïµÄʱ¼äÊÇ´Ó1970Äê1ÔÂ1ÈÕ0µãµ½µ±Ç°µÄ¼ä¸ô
function GetJavaTime( d: TDateTime ): Int64;
var
dJavaStart: TDateTime;
begin
dJavaStart := EncodeDateTime( 1970, 1, 1, 0, 0, 0, 0 );
Result := MilliSecondsBetween( d, dJavaStart );
end;
//¶ÁÈ¡XMLÎļþ½ÚµãÐÅÏ¢ ²»¼ÓÈκλسµ»»ÐÐ
function ReadXml(node: IXMLNode): string;
var
nodeList,attrList: IXMLNodeList;
str,strName,strValue: string;
i: Integer;
begin
Result := '';
if not node.HasChildNodes then Exit;
attrList := node.AttributeNodes; {¸ù½ÚµãµÄÊôÐÔÇåµ¥}
nodeList := node.ChildNodes; {¸ù½ÚµãϵÄ×Ó½ÚµãÁбí}
str := '<' + node.NodeName;
//ÏȶÁÈ¡ÊôÐÔ
for i := 0 to attrList.Count - 1 do
begin
strName := attrList[i].NodeName;
strValue := attrList[i].NodeValue;
str := str + ' ' + strName + '=' + AnsiQuotedStr(strValue, '"');
end;
str := str + '>';// + sLineBreak; {sLineBreak Êdz£Á¿, Ï൱ÓÚ #13#10 ´Ë´¦²»¼Ó£¬ÍøÕ¾×Ô¶¯½âÎö}
//¶ÁÈ¡×Ó½Úµã
for i := 0 to nodeList.Count - 1 do
begin
strName := nodeList[i].NodeName;
if nodeList[i].IsTextElement then
begin
strValue := nodeList[i].NodeValue;
str := str + '<' + strName + '>' + strValue + '</' + strName + '>' ;//+ sLineBreak; //´Ë´¦²»¼Ó£¬ÍøÕ¾×Ô¶¯½âÎö
end else if nodeList[i].HasChildNodes then
begin
str := str + ReadXml(nodeList[i]); {µÝ¹é}
str := str + '</' + strName + '>' ;//+ sLineBreak; {·â¿Ú} //´Ë´¦²»¼Ó£¬ÍøÕ¾×Ô¶¯½âÎö
end;
end;
str := str + '</' + node.NodeName + '>'; {·â¿Ú}
Result := str;
end;
function TFrm_op_seae_edi_CSSA.CheckSendorCode:Boolean;
begin
{ Result:=False;
with t_sys_company do
begin
Close;
SQL.Clear;
SQL.Add('select top 1 * from t_sys_company ');
Open;
end;
if Trim(Edit1.Text)=Trim(t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString) then Result:=True;
}
end;
function TFrm_op_seae_edi_CSSA.IsZhongwen(Str: String): Boolean;
var
i:Integer;
begin
Result:=false;
if Str='' then Exit;
for i:=1 to Length(Str) do begin
if (Str[i]>Chr(127)) or (Str[i]=Chr(9)) then begin
Result:=True;
Exit;
end;
end;
end;
function TFrm_op_seae_edi_CSSA.SeparateEC(Str: String): string;
var
i:Integer;
begin
if Str='' then Exit;
for i:=1 to Length(Str) do
begin
if (Str[i]<=Chr(127)) then Result:=Result+Str[i] else Break;
end;
end;
function TFrm_op_seae_edi_CSSA.GetShipVGM(Ship:String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ´úÂë,VGM´úÂë,FTP½ÓÊÕ´úÂë,¿Í»§¼ò³Æ,¿Í»§È«³Æ,À¿»õÈË,¼ÈëÈË,¼ÈëÈÕÆÚ from t_crm_client');
SQL.Add('where ¿Í»§ÐÔÖÊ<>''Ä¿±ê'' and ´¬¹«Ë¾=1 and ¿Í»§¼ò³Æ='''+Ship+'''');
SQL.Add('order by ´úÂë');
Open;
if not IsEmpty then
Result:=Trim(FieldByName('VGM´úÂë').asstring)
else
Result:='';
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetShipFTP(Ship:String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ´úÂë,VGM´úÂë,FTP½ÓÊÕ´úÂë,¿Í»§¼ò³Æ,¿Í»§È«³Æ,À¿»õÈË,¼ÈëÈË,¼ÈëÈÕÆÚ from t_crm_client');
SQL.Add('where ¿Í»§ÐÔÖÊ<>''Ä¿±ê'' and ´¬¹«Ë¾=1 and ¿Í»§¼ò³Æ='''+Ship+'''');
SQL.Add('order by ´úÂë');
Open;
if not IsEmpty then
Result:=Trim(FieldByName('FTP½ÓÊÕ´úÂë').asstring)
else
Result:='';
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure TFrm_op_seae_edi_CSSA.FormShow(Sender: TObject);
begin
with t_sys_company do
begin
Close;
SQL.Clear;
SQL.Add('select top 1 * from t_sys_company ');
Open;
end;
// Edit1.Text:= t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString;
//Edit2.Text:=GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString);
end;
function TFrm_op_seae_edi_CSSA.Changestr(str:widestring):string;
var
i:integer;
strC:widestring;
begin
strC:=str;
strC:=StringReplace(strC,'''''','&quot;',[rfReplaceAll]);
strC:=StringReplace(strC,'''','&apos;',[rfReplaceAll]);
strC:=StringReplace(strC,'&','&amp;',[rfReplaceAll]);
strC:=StringReplace(strC,'>','&gt;',[rfReplaceAll]);
strC:=StringReplace(strC,'<','&lt;',[rfReplaceAll]);
result:=strC;
end;
function TFrm_op_seae_edi_CSSA.GetCntrVGM(cntrsize: String):String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select VGM´úÂë from t_code_ctn where ´úÂë='''+cntrsize+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('VGM´úÂë').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetPackVGM(cntrsize: String):String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select VGM´úÂë from t_code_package where ´úÂë='''+cntrsize+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('VGM´úÂë').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetDepartmentVGM(cntrsize: String):String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select VGM´úÂë from t_code_subcomp where ·Ö²¿Ãû³Æ=(select ·Ö²¿Ãû³Æ from t_sys_employee where ÐÕÃû='''+cntrsize+''')');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('VGM´úÂë').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetECodeVGM(cntrsize: String):String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ´úÂë from t_sys_employee where ÐÕÃû='''+cntrsize+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('´úÂë').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetTelVGM(cntrsize: String):String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ¹Ì¶¨µç»° from t_sys_employee where ÐÕÃû='''+cntrsize+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('¹Ì¶¨µç»°').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function TFrm_op_seae_edi_CSSA.GetCompany:String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select top 1 ¼ò³Æ from t_sys_company ');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('¼ò³Æ').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure TFrm_op_seae_edi_CSSA.MakeVGM;
var
fNode,pNode,mNode,cNode,dNode,eNode,gNode: IXMLNode; {¶¨Òå7²ã½Úµã}
sl:TStringList;
i,Elength,Wlength,Clength:Integer;
begin
XMLDocument1.XML.Clear;
XMLDocument1.Active := True;
XMLDocument1.Version := '1.0';
XMLDocument1.Encoding := 'GB2312';
//Ìí¼Ó¸ù½Úµã edi
fNode := XMLDocument1.AddChild('edi');
// Ϊ¸ù½ÚµãÌí¼Ó×Ó½Úµã:HEAD
pNode := fNode.AddChild('head');
cNode := pNode.AddChild('sndcom'); //*
if (IsZhongwen(t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString)) or (not CheckParaExist(t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString)) then
begin
HasM:=True;
ShowMessage('·¢ËÍ·½´úÂëδÅäÖûò²»ÄÜ°üº¬ÖÐÎÄ£¡Çë¼ì²é£¡');
Exit;
end;
cNode.Text := t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString;
cNode := pNode.AddChild('sender');
cNode := pNode.AddChild('fromop'); //*
employeecode:=GetECodeVGM(employee);
if (IsZhongwen(employeecode)) or (not CheckParaExist(employeecode)) then
begin
HasM:=True;
ShowMessage('·¢ËÍ·½²Ù×÷Ô±²»ÄÜΪ¿Õ»ò°üº¬ÖÐÎÄ£¡Çë¼ì²é£¡');
Exit;
end;
cNode.Text := employeecode;
cNode := pNode.AddChild('fromtele'); //*
emptel:=GetTelVGM(employee);
if not CheckParaExist(emptel) then
begin
HasM:=True;
ShowMessage('²Ù×÷Ô±ÁªÏµµç»°Î´ÅäÖã¡Çë¼ì²é£¡');
Exit;
end;
cNode.Text := emptel;
cNode := pNode.AddChild('fromfax');
cNode := pNode.AddChild('frommail'); //*
cNode.Text := 'dongshengsoft@dongshengsoft.com';
cNode := pNode.AddChild('fromopc');
cNode.Text := empmobil;
cNode := pNode.AddChild('fromope');
cNode.Text := employeecode;
cNode := pNode.AddChild('accom'); //*
if Trim(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString)='' then
begin
HasM:=True;
ShowMessage('½ÓÊÕ·½¹«Ë¾Îª¿Õ£¡´¬¹«Ë¾²»ÄÜΪ¿Õ£¡');
Exit;
end;
cNode.Text :=frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString;
cNode := pNode.AddChild('accepter');
cNode := pNode.AddChild('toop');
cNode := pNode.AddChild('sendtime'); //*
cNode.Text:=FormatDateTime('yyyy-mm-dd hh:mm:ss',Now);
cNode := pNode.AddChild('editype'); //*
cNode.Text:='VERMAS';
cNode := pNode.AddChild('EdiID'); //*
cNode := pNode.AddChild('EdiName');
cNode := pNode.AddChild('EdiMode'); //*
cNode.Text:='HYXML';
cNode := pNode.AddChild('EdiReceiver'); //*
if Trim(GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString))='' then
begin
HasM:=True;
ShowMessage('Ôݲ»Ö§³Ö´Ë´¬¹«Ë¾£¬¾´ÇëÆÚ´ý£¡');
Exit;
end;
cNode.Text := GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString);
cNode := pNode.AddChild('EdiSender'); //*
cNode.Text := t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString;
// Ϊ¸ù½ÚµãÌí¼Ó×Ó½Úµã:Forward
pNode := fNode.AddChild('Forward');
cNode := pNode.AddChild('EdiForwardFMT');
cNode := pNode.AddChild('EdiForwardType');
cNode := pNode.AddChild('EdiForwardURL');
cNode := pNode.AddChild('EdiForwardId');
cNode := pNode.AddChild('EdiForwardPass');
cNode := pNode.AddChild('EdiForwardREFE1');
cNode := pNode.AddChild('EdiForwardREFE2');
cNode := pNode.AddChild('EdiForwardREFE3');
cNode := pNode.AddChild('EdiForwardREFE4');
cNode := pNode.AddChild('EdiForwardREFE5');
// Ϊ¸ù½ÚµãÌí¼Ó×Ó½Úµã:reference
pNode := fNode.AddChild('reference');
cNode := pNode.AddChild('blfreight'); //*
if RadioGroup1.ItemIndex=0 then cNode.Text:='9';
if RadioGroup1.ItemIndex=1 then cNode.Text:='5';
if RadioGroup1.ItemIndex=2 then cNode.Text:='1';
cNode := pNode.AddChild('refid');
cNode := pNode.AddChild('freid');
cNode := pNode.AddChild('referenceno');
cNode := pNode.AddChild('bookingno'); //*
cNode.Text:= frm_op_seae.t_op_seae.fieldbyname('¶©²Õµ¥ºÅ').AsString;
cNode := pNode.AddChild('workno'); //*
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('ÒµÎñ±àºÅ').AsString;
cNode := pNode.AddChild('sale');
cNode.Text:='gu';//frm_op_seae.t_op_seae.fieldbyname('À¿»õÈË').AsString;
cNode := pNode.AddChild('billofladingno'); //*
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').AsString) then
begin
HasM:=True;
ShowMessage('Ö÷Ìáµ¥ºÅ²»´æÔÚ£¡²»ÄÜÉú³ÉXML£¡Çë¼ì²é£¡');
Exit;
end;
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').AsString;
// Ϊ¸ù½ÚµãÌí¼Ó×Ó½Úµã:detail
pNode := fNode.AddChild('detail');
//Ôö¼Ó¶þ¼¶×Ó½Úµã baseinfo
mNode:= pNode.AddChild('baseinfo');
cNode := mNode.AddChild('orderman'); //* ¶©²Õµ¥Î» Èç¹û¼ÁË£¬¾ÍÈ¡¶©²Õ´úÀí£¬Èç¹ûû¼¾ÍÈ¡companyÀïµÄshortname
cNode.Text := frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString;
cNode := mNode.AddChild('source');
cNode := mNode.AddChild('usdaccountshipper');
cNode := mNode.AddChild('customshipper');
cNode := mNode.AddChild('rmbaccountshipper');
cNode := mNode.AddChild('paymenttermcode'); //* ¸¶¿î·½Ê½´úÂë(P/C/E)
cNode := mNode.AddChild('paymentterm'); //*
cNode := mNode.AddChild('payableat');
cNode := mNode.AddChild('shippingitem'); //*
cNode.Text := frm_op_seae.t_op_seae.fieldbyname('ÔËÊäÌõ¿î').AsString;
cNode := mNode.AddChild('billofladingtype'); //*
cNode := mNode.AddChild('shipper'); //*
{if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('·¢»õÈË´úÂë').AsString) then
begin
ShowMessage('·¢»õÈ˲»ÄÜΪ¿Õ£¡');
Exit;
end; }
sl:=TStringList.Create;
sl.Text:=frm_op_seae.t_op_seae.fieldbyname('·¢»õÈË´úÂë').AsString;
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
cNode := mNode.AddChild('consignee'); //*
sl:=TStringList.Create;
sl.Text:=frm_op_seae.t_op_seae.fieldbyname('ÊÕ»õÈË´úÂë').AsString;
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
cNode := mNode.AddChild('notifyparty'); //*
sl:=TStringList.Create;
sl.Text:=frm_op_seae.t_op_seae.fieldbyname('֪ͨÈË´úÂë').AsString;
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
cNode := mNode.AddChild('notifyparty2');
if Trim(frm_op_seae.t_op_seae.fieldbyname('µÚ¶þ֪ͨÈË').AsString)<>'' then
begin
sl:=TStringList.Create;
sl.Text:=frm_op_seae.t_op_seae.fieldbyname('µÚ¶þ֪ͨÈË').AsString;
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
end
else
begin
dNode := cNode.AddChild('text');
end;
cNode := mNode.AddChild('ordermemo');
cNode := mNode.AddChild('numberoforiginals'); //*
cNode := mNode.AddChild('numberofcopys');
cNode := mNode.AddChild('placeofissuecode'); //*
cNode := mNode.AddChild('placeofissue'); //*
cNode := mNode.AddChild('timeofissue'); //*
//Ôö¼Ó¶þ¼¶×Ó½Úµã cargo
mNode:= pNode.AddChild('cargo');
cNode := mNode.AddChild('APPLICANT');
cNode := mNode.AddChild('BOKKINGPARTY');
cNode := mNode.AddChild('FOBPARTY');
cNode := mNode.AddChild('SCNO');
cNode := mNode.AddChild('QUARANTINECODING');
cNode := mNode.AddChild('SCACCODE');
cNode := mNode.AddChild('QUOTATIONNO');
cNode := mNode.AddChild('CHARGETYPE');
cNode := mNode.AddChild('NVOCCHBLNO');
cNode := mNode.AddChild('realshipper');
dNode := cNode.AddChild('text');
cNode := mNode.AddChild('realconsignee');
dNode := cNode.AddChild('text');
cNode := mNode.AddChild('realnotifyparty');
dNode := cNode.AddChild('text');
cNode := mNode.AddChild('realnotifyparty2');
dNode := cNode.AddChild('text');
//Ôö¼Ó¶þ¼¶×Ó½Úµã booking
mNode:= pNode.AddChild('booking');
cNode := mNode.AddChild('shipmentdate');
cNode := mNode.AddChild('expirydate');
cNode := mNode.AddChild('tranship');
cNode := mNode.AddChild('batch');
cNode := mNode.AddChild('quotationno');
//Ôö¼Ó¶þ¼¶×Ó½Úµã freight
mNode:= pNode.AddChild('freight');
cNode := mNode.AddChild('fl');
cNode := mNode.AddChild('masterlclno');
cNode := mNode.AddChild('requestdate');
cNode := mNode.AddChild('lastdate');
cNode := mNode.AddChild('arrivedate');
//Ôö¼ÓÈý¼¶×Ó½Úµã port
cNode := mNode.AddChild('port');
dNode := cNode.AddChild('placeofreceipt');
dNode := cNode.AddChild('portofloading'); //* ×°»õ¸Û
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('×°»õ¸Û').AsString) then
begin
HasM:=True;
ShowMessage('×°»õ¸Û²»ÄÜΪ¿Õ£¡');
Exit;
end;
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('×°»õ¸Û').AsString;
dNode := cNode.AddChild('portoftranship');
dNode := cNode.AddChild('portofdischarge'); //* ж»õ¸Û
{if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('ж»õ¸Û').AsString) then
begin
ShowMessage('ж»õ¸Û²»ÄÜΪ¿Õ£¡');
Exit;
end; }
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('ж»õ¸Û').AsString;
dNode := cNode.AddChild('placeofdelivery'); //* Ä¿µÄ¸Û
{if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('Ä¿µÄµØ').AsString) then
begin
ShowMessage('Ä¿µÄµØ²»ÄÜΪ¿Õ£¡');
Exit;
end; }
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('Ä¿µÄµØ').AsString;
dNode := cNode.AddChild('finaldestination');
dNode := cNode.AddChild('co_placeofreceipt');
dNode := cNode.AddChild('co_portofloading'); //* ×°»õ¸Û´úÂë
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('×°¸Û´úÂë').AsString) then
begin
HasM:=True;
ShowMessage('×°¸Û´úÂë²»ÄÜΪ¿Õ£¡');
Exit;
end;
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('×°¸Û´úÂë').AsString;
dNode := cNode.AddChild('co_portoftranship');
dNode := cNode.AddChild('co_portofdischarge'); //* ж»õ¸Û´úÂë
{if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('ж»õ´úÂë').AsString) then
begin
ShowMessage('ж»õ¸Û´úÂë²»ÄÜΪ¿Õ£¡');
Exit;
end; }
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('ж»õ´úÂë').AsString;
dNode := cNode.AddChild('co_placeofdelivery'); //* Ä¿µÄ¸Û´úÂë
{if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('Ä¿µÄµØ´úÂë').AsString) then
begin
ShowMessage('Ä¿µÄµØ´úÂë²»ÄÜΪ¿Õ£¡');
Exit;
end; }
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('Ä¿µÄµØ´úÂë').AsString;
dNode := cNode.AddChild('co_finaldestination');
//Ôö¼ÓÈý¼¶×Ó½Úµãvessel
cNode := mNode.AddChild('vessel');
dNode := cNode.AddChild('carrier'); //* ´¬¹«Ë¾
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString;
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('´¬Ãû').AsString) then
begin
HasM:=True;
ShowMessage('´¬Ãû²»ÄÜΪ¿Õ£¡');
Exit;
end;
dNode := cNode.AddChild('oceanvessel'); //* ´¬Ãû
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('´¬Ãû').AsString;
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('º½´Î').AsString) then
begin
HasM:=True;
ShowMessage('º½´Î²»ÄÜΪ¿Õ£¡');
Exit;
end;
dNode := cNode.AddChild('voyno'); //* º½´Î
dNode.Text:=frm_op_seae.t_op_seae.fieldbyname('º½´Î').AsString;
dNode := cNode.AddChild('etd'); //* ¿ªº½ÈÕÆÚ
if not CheckParaExist(frm_op_seae.t_op_seae.fieldbyname('¿ª´¬ÈÕÆÚ').AsString) then
begin
HasM:=True;
ShowMessage('¿ª´¬ÈÕÆÚ²»ÄÜΪ¿Õ£¡');
Exit;
end;
dNode.Text:= FormatDateTime('yyyy-mm-dd',frm_op_seae.t_op_seae.fieldbyname('¿ª´¬ÈÕÆÚ').AsDateTime);
dNode := cNode.AddChild('deliverymode');
//Ôö¼ÓÈý¼¶×Ó½Úµãinfo2nd
cNode := mNode.AddChild('info2nd');
dNode := cNode.AddChild('carrier');
dNode := cNode.AddChild('oceanvessel');
dNode := cNode.AddChild('voyno');
dNode := cNode.AddChild('etd');
dNode := cNode.AddChild('eta');
dNode := cNode.AddChild('remarks');
eNode := dNode.AddChild('text');
//Ôö¼ÓÈý¼¶×Ó½Úµãcontainer
cNode := mNode.AddChild('container'); //Èô¼¯×°Ïäû¼£¬Ìáʾ£º¼¯×°ÏäÐÅÏ¢²»ÄÜΪ¿Õ
with t_op_ctn do
begin
Close;
SQL.Clear;
sql.Add('select * from t_op_ctn where ±àºÅ='+quotedstr(frm_op_seae.t_op_seae.fieldbyname('±àºÅ').AsString)+' order by ´úÂë' );
Open;
end;
if t_op_ctn.RecordCount=0 then
begin
HasM:=True;
ShowMessage('¼¯×°ÏäÐÅÏ¢²»´æÔÚ£¡²»ÄÜÉú³ÉVGMÎļþ£¡Çë¼ì²é£¡');
Exit;
end
else
begin
t_op_ctn.First;
while not t_op_ctn.Eof do
begin
dNode := cNode.AddChild('containers'); //¿ÉÎÞÏÞÑ­»·
eNode := dNode.AddChild('containertype'); //* ÏäÐÍ ÏäÐͲ»ÄÜΪ¿Õ
eNode.Text:=GetCntrVGM(t_op_ctn.fieldbyname('´úÂë').AsString);
if not CheckParaExist(GetCntrVGM(t_op_ctn.fieldbyname('´úÂë').AsString)) then
begin
HasM:=True;
ShowMessage('ÏäÐÍVGM´úÂëδÉèÖã¡');
Exit;
end;
eNode := dNode.AddChild('containerno'); //* ÏäºÅ ÏäÐͲ»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('ÏäºÅ').AsString) then
begin
HasM:=True;
ShowMessage('ÏäºÅ²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('ÏäºÅ').AsString;
eNode := dNode.AddChild('sealno'); //* ·âºÅ ²»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('·âºÅ').AsString) then
begin
HasM:=True;
ShowMessage('·âºÅ²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('·âºÅ').AsString;
eNode := dNode.AddChild('containernoofpkgs'); //* ¼þÊý ²»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('¼þÊý').AsString) then
begin
HasM:=True;
ShowMessage('¼þÊý²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('¼þÊý').AsString;
eNode := dNode.AddChild('containergrossweight'); //* ëÖØ ²»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('ÖØÁ¿').AsString) then
begin
HasM:=True;
ShowMessage('ëÖز»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('ÖØÁ¿').AsString;
eNode := dNode.AddChild('containercbm'); //* Ìå»ý ²»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('³ßÂë').AsString) then
begin
HasM:=True;
ShowMessage('Ìå»ý²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('³ßÂë').AsString;
eNode := dNode.AddChild('containerpackagingcode'); //* Ïä»õÎï°ü×°ÀàÐÍ´úÂë °ü×°ÀàÐÍ´úÂëδÅäÖÃ
if not CheckParaExist(GetPackVGM(t_op_ctn.fieldbyname('°ü×°').AsString)) then
begin
HasM:=True;
ShowMessage('°ü×°VGM´úÂëδÉèÖã¡');
Exit;
end;
eNode.Text:=GetPackVGM(t_op_ctn.fieldbyname('°ü×°').AsString);
eNode := dNode.AddChild('containerpackaging'); //* Ïä»õÎï°ü×°ÀàÐÍ °ü×°²»ÄÜΪ¿Õ
eNode.Text:=t_op_ctn.fieldbyname('°ü×°').AsString;
eNode := dNode.AddChild('containerdescription');
gNode := eNode.AddChild('text');
eNode := dNode.AddChild('containermarksandnumbers');
eNode := dNode.AddChild('vgmgrossmassweight'); //VGM×ÜÖØÁ¿ ²»ÄÜΪ¿Õ
if not CheckParaExist(t_op_ctn.fieldbyname('³ÆÖØÖØÁ¿').AsString) then
begin
HasM:=True;
ShowMessage('VGMÖØÁ¿²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=t_op_ctn.fieldbyname('³ÆÖØÖØÁ¿').AsString;
eNode := dNode.AddChild('vgmweighingmethod'); //VGM³ÆÖØ·½Ê½ ²»ÄÜΪ¿Õ
if (Trim(t_op_ctn.fieldbyname('³ÆÖØ·½Ê½').AsString)='') or (Trim(t_op_ctn.fieldbyname('³ÆÖØ·½Ê½').AsString)='ÀÛ¼Ó') then eNode.Text:='SM2'
else eNode.Text:='SM1';
eNode := dNode.AddChild('vgmweighingtime'); //VGM³ÆÖØʱ¼ä ²»ÄÜΪ¿Õ ¿ÕÔòÈ¡¿ª´¬Ç°ÈýÌì
if Trim(t_op_ctn.fieldbyname('VGM³ÆÖØÈÕÆÚ').AsString)='' then eNode.Text:=FormatDateTime('yyyy-mm-dd',frm_op_seae.t_op_seae.fieldbyname('¿ª´¬ÈÕÆÚ').AsDateTime-3)
else eNode.Text:=t_op_ctn.fieldbyname('VGM³ÆÖØÈÕÆÚ').AsString;
eNode := dNode.AddChild('vgmresponsibleparty'); //VGMÁªÏµµ¥Î»
if not CheckParaExist(GetDepartmentVGM(employee)) then
begin
HasM:=True;
ShowMessage('VGMÁªÏµµ¥Î»²»ÄÜΪ¿Õ£¡');
Exit;
end;
eNode.Text:=GetDepartmentVGM(employee);
eNode := dNode.AddChild('vgmauthorizedperson'); //VGMÊÚȨÁªÏµÈË
eNode.Text:=employeecode;
eNode := dNode.AddChild('vgmauthorizedpersontele'); //VGMÊÚȨÁªÏµÈ˵绰
eNode.Text:=emptel;
eNode := dNode.AddChild('vgmauthorizedpersonmail'); //VGMÊÚȨÁªÏµÈËÓʼþ
eNode := dNode.AddChild('vgmremark'); //VGMÆäËû±¸×¢ÄÚÈÝ
t_op_ctn.Next;
end;
end;
//Ôö¼Ó¶þ¼¶×Ó½Úµã goods
mNode:= pNode.AddChild('goods');
cNode := mNode.AddChild('marksandnumbers'); //* ßéÍ·
if frm_op_seae.t_op_seae.fieldbyname('ßéÍ·').AsString='' then
begin
{ShowMessage('ßéÍ·²»ÄÜΪ¿Õ£¡');
Exit; }
end
else
begin
sl:=TStringList.Create;
sl.Text:=frm_op_seae.t_op_seae.fieldbyname('ßéÍ·').AsString;
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
end;
cNode := mNode.AddChild('noofpkgs'); //* °ü×°¼þÊý
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('¼þÊý°ü×°').AsString;
cNode := mNode.AddChild('packagingcode'); //* °ü×°ÀàÐÍ´úÂë
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('°ü×°').AsString;
cNode := mNode.AddChild('packaging'); //* °ü×°ÀàÐÍ
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('°ü×°').AsString;
cNode := mNode.AddChild('cargoid'); //* »õÎïÀàÐÍ(GC/RF/DR)
cNode.Text:=frm_op_seae.t_op_seae.fieldbyname('»õÎï±êʶ').AsString;
cNode := mNode.AddChild('hscode'); //º£¹Ø±àÂë
cNode := mNode.AddChild('description'); //»õÎïÃèÊö(Ó¢ÎÄ»õÃû)
if Trim(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString)='' then
begin
dNode := cNode.AddChild('text');
end
else
begin
sl:=TStringList.Create;
sl.Text:=SeparateEC(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString);
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
end;
cNode := mNode.AddChild('dcdescription'); //»õÎïÃèÊö(ÖÐÎÄ»õÃû)
Wlength:= Length(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString);
Elength:= Length(SeparateEC(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString));
if Trim(Copy(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString,Elength,WLength-Elength-1) )=''
then
begin
dNode := cNode.AddChild('text');
end
else
begin
sl:=TStringList.Create;
sl.Text:=Copy(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString,Elength,WLength-Elength-1);
for i:=0 to sl.Count-1 do
begin
dNode := cNode.AddChild('text');
dNode.Text:=sl[i];
end;
sl.Free;
end;
cNode := mNode.AddChild('grossweight'); //* ëÖØ
cNode.Text:= frm_op_seae.t_op_seae.fieldbyname('ÖØÁ¿').AsString;
cNode := mNode.AddChild('cbm'); //* Ìå»ý
cNode.Text:= frm_op_seae.t_op_seae.fieldbyname('³ßÂë').AsString;
cNode := mNode.AddChild('specialgoods'); //ÌØÊâ»õÎï˵Ã÷
dNode := cNode.AddChild('text');
//Ôö¼Ó¶þ¼¶×Ó½Úµã dr
mNode := pNode.AddChild('dr');
cNode := mNode.AddChild('CLASS');
cNode := mNode.AddChild('PAGE');
cNode := mNode.AddChild('UNDGNO');
cNode := mNode.AddChild('TECNAME');
cNode := mNode.AddChild('PACKGROUP');
cNode := mNode.AddChild('LABEL');
dNode := cNode.AddChild('text');
cNode := mNode.AddChild('FLASHPOINT');
cNode := mNode.AddChild('FLASHUNIT');
cNode := mNode.AddChild('EMSNO');
cNode := mNode.AddChild('MFAGNO');
cNode := mNode.AddChild('MPT');
cNode := mNode.AddChild('Elinkman');
cNode := mNode.AddChild('DANGEROUS');
dNode := cNode.AddChild('text');
cNode := mNode.AddChild('TEMPERATURE');
cNode := mNode.AddChild('TEMPERATUREUNIT');
cNode := mNode.AddChild('MINTEMPERATURE');
cNode := mNode.AddChild('MAXTEMPERATURE');
cNode := mNode.AddChild('ALLCOLDTORAGE');
cNode := mNode.AddChild('VENTI');
cNode := mNode.AddChild('REEFER');
dNode := cNode.AddChild('text');
//Ôö¼Ó¶þ¼¶×Ó½Úµã loadplan
mNode := pNode.AddChild('loadplan');
cNode := mNode.AddChild('entryno');
cNode := mNode.AddChild('warehouse');
cNode := mNode.AddChild('landcarrier');
cNode := mNode.AddChild('stuffdate');
cNode := mNode.AddChild('stuffmode');
cNode := mNode.AddChild('stuffaddress');
cNode := mNode.AddChild('stuffmemo');
//Ôö¼Ó¶þ¼¶×Ó½Úµã announce
mNode := pNode.AddChild('announce');
cNode := mNode.AddChild('text');
//Ôö¼Ó¶þ¼¶×Ó½Úµã remarks
mNode := pNode.AddChild('remarks');
end;
procedure TFrm_op_seae_edi_CSSA.bsSkinButton1Click(Sender: TObject);
begin
HasM:=False;
MakeVGM;
if HasM then Exit;
if SaveDialog1.Execute then
begin
XMLDocument1.SaveToFile(SaveDialog1.FileName+'.XML');
XMLDocument1.Active:=False;
showmessage('ÎļþÉú³É³É¹¦£¡');
end
else
begin
showmessage('ÎļþÉú³Éʧ°Ü£¡');
exit;
end;
end;
procedure TFrm_op_seae_edi_CSSA.bsSkinButton2Click(Sender: TObject);
begin
XMLDocument1.Active:=False;
close;
end;
procedure TFrm_op_seae_edi_CSSA.sendmail;
begin
idsmtp1.Username:='admin@dongshengsoft.com'; //ÉèÖõǽÕʺÅ
idsmtp1.Password:='ds!@#)(*';// ÉèÖõǽÃÜÂë
idsmtp1.Host:='smtpcom.263xmail.com';// ÉèÖÃSMTPµØÖ·
idsmtp1.Port :=25;
if idsmtp1.Connected = False then
begin
try
idsmtp1.Connect;
except
//showmessage('Á¬½Óʧ°Ü,ÇëÖØÊÔ!');
Exit; // Á¬½Óʧ°Ü µÄ»° Í˳ö¸ÃÖ´Ðйý³Ì
end;
end;
with IdMessage1 do
begin
Body.Clear; // ÏÈÇå¿ÕÉϴη¢Ë͵ÄÄÚÈÝ
CharSet :='GB2312'; // ²»ÉèÖÃÕâ¸öÖÐÎÄ»áÂÒÂë
Subject :='ÉêÇë·¢ËÍVGM-Ö÷Ìáµ¥ºÅ: '+frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').AsString; // ÉèÖÃÓʼþ·¢Ë͵ıêÌâ
Body.Text := '¹«Ë¾Ãû³Æ£º'+GetCompany+#13#10+'ÉêÇëÈË£º'+employee+#13#10+'ÓÊÏ䣺'+#13#10
+'µç»°£º'+GetTelVGM(employee)+#13#10+'Ö÷Ìáµ¥ºÅ£º'+frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').AsString; //ÉèÖÃÓʼþ·¢Ë͵ÄÖ÷Ìâ
From.Address := 'admin@dongshengsoft.com'; //ÉèÖ÷¢¼þÈË
Recipients.EMailAddresses :='dongshengsoft@dongshengsoft.com'; //ÉèÖÃÊÕ¼þÈË
TIdAttachmentFile.Create(MessageParts,RequestFile);
end;
try
idsmtp1.Send(IdMessage1);
except
idsmtp1.Disconnect;
end;
end;
function FormatEncodeDate(s:string):string;
begin
Result:=StringReplace(s,' ','+',[rfreplaceall]);
Result:=StringReplace(Result,':','%3a',[rfreplaceall]);
end;
function URLEncode(const S: string; const InQueryString: Boolean): string;
var
Idx: Integer;
begin
Result := '';
for Idx := 1 to Length(S) do
begin
case S[Idx] of
'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.':
Result := Result + S[Idx];
' ':
if InQueryString then
Result := Result + '+'
else
Result := Result + '%20';
else
Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
end;
end;
end;
procedure TFrm_op_seae_edi_CSSA.SendFile;
var
s1,s2,s: string;
IdHttp : TIdHTTP;
Url : string;//ÇëÇóµØÖ·
//·µ»ØÐÅÏ¢
ResponseStream : TStringStream;
ResponseStr: string;
//ÇëÇóÐÅÏ¢
RequestStr : string;
RequestStream : TStringStream;
//ÇëÇó²ÎÊý
Realdate:TDateTime;
Requestdate,RequestOrg,RequestSign:string;
RequestContent,RequestDateSTamp:string;
aQuery:TADOQuery;
Stream:TStream; //TStringStream;
buffer: array of char;
tmpFileSize:Integer;
begin
HasM:=false;
//Ïȼì²éÓÐÎÞ±¾±àºÅµÄ·¢ËͼǼ
aQuery:=TADOQuery.Create(nil);
aQuery.Connection:=frm_main.db;
with aQuery do
begin
Close;
SQL.Clear;
SQL.Add('select * from t_op_state where ÒµÎñ״̬='+QuotedStr('VGMÒÑ·¢ËÍ')+' and ±àºÅ='+quotedstr(frm_op_seae.t_op_seae.fieldbyname('±àºÅ').AsString)+' order by ˳Ðò');
Open;
end;
//ÓÐÔòÌáʾ£¬ÊÇ·ñ¼ÌÐø ûÓеãNOÔò¼ÌÐø ÔÚºóÃæ·¢Ëͳɹ¦ÔÙ¼ÓÈëÊý¾Ý¿â t_op_state±íÄÚ
if aQuery.RecordCount>0 then
begin
if application.MessageBox('ÒѾ­Óб¾ÒµÎñµÄVGM·¢ËͼǼ£¬ÊÇ·ñ¼ÌÐø£¿','Ìáʾ',mb_yesno)=idno then
begin
FreeAndNil(aQuery);
Exit;
end;
end;
if GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString)='' then
begin
ShowMessage('Ôݲ»Ö§³Ö´Ë´¬¹«Ë¾£¬¾´ÇëÆÚ´ý£¡');
Exit;
end;
MakeVGM;
if HasM then Exit;
IdHttp := TIdHTTP.Create(nil);
idhttp.Request.ContentType:='application/x-www-form-urlencoded';
//TStringStream¶ÔÏóÓÃÓÚ±£´æÏìÓ¦ÐÅÏ¢
ResponseStream := TStringStream.Create('');
RequestStream := TStringStream.Create('');
Realdate:=Now;
//³õʼ»¯¸÷²ÎÊý
Requestdate:=FormatDateTime('yyyy-mm-dd hh:mm:ss',Realdate);
RequestDateSTamp:=FormatEncodeDate(Requestdate);
if not CheckBox1.Checked then RequestOrg:='dssoft' + 'ced93003-1577-4ff4-9fcf-73a52408eb36' + Requestdate
else RequestOrg:='nbforwarder' + '2dde55e422d2461b913f510e95da73b3' + Requestdate;
RequestSign:=UpperCase(MD5Print(MD5String(RequestOrg)));
RequestFile:=IntToStr(GetJavaTime(Realdate))+'.XML';
XMLDocument1.SaveToFile(RequestFile);
XMLDocument1.Active:=False;
XMLDocument1.LoadFromFile(RequestFile);
{¶ÁÈ¡Îļþ}
Stream := TFileStream.Create(RequestFile,fmOpenRead);
try
Stream.Position := 0;
tmpFileSize := Stream.Size;
SetLength(buffer, tmpFileSize);
Stream.Read(buffer[0], tmpFileSize);
finally
FreeAndNil(Stream);
end;
RequestContent:= PChar(buffer);
RequestContent:=URLEncode(EncodeString(RequestContent),False);
try
if not CheckBox1.Checked then Url := 'http://api.nbeport.com/router/rest' else Url := 'http://api.trainer.nbeport.com/router/rest';
try
//ÒÔÁ÷µÄ·½Ê½Ìá½»²ÎÊý
if not CheckBox1.Checked then
RequestStr:='user_id=dssoft&format=json&timestamp='+RequestDateSTamp+'&sign='+RequestSign
+'&method=cargoedi.demessage.msgrec.post&deaId='+t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString
+'&userId=dssoft&docName='+RequestFile+'&docType=VERMAS&docLength='+IntToStr(Length(RequestContent))
+'&docContent='+RequestContent+'&channel=WSTOM&destDeaId='+ GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString)
+'&port=CNTAO'
else
RequestStr:='user_id=nbforwarder&format=json&timestamp='+RequestDateSTamp+'&sign='+RequestSign
+'&method=cargoedi.demessage.msgrec.post&deaId='+t_sys_company.fieldbyname('VGM·¢ËÍ´úÂë').AsString
+'&userId=dssoft&docName='+RequestFile+'&docType=VERMAS&docLength='+IntToStr(Length(RequestContent))
+'&docContent='+RequestContent+'&channel=WSTOM&destDeaId='+ GetShipVGM(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').AsString)
+'&port=CNTAO';
RequestStream.WriteString(RequestStr);
IdHttp.Post(Url,RequestStream,ResponseStream);
// RequestContent:=DecodeString(RequestContent);
except
on e : Exception do
begin
ShowMessage(e.Message);
end;
end;
//»ñÈ¡ÍøÒ³·µ»ØµÄÐÅÏ¢
ResponseStr := ResponseStream.DataString;
//ÍøÒ³ÖеĴæÔÚÖÐÎÄʱ£¬ÐèÒª½øÐÐUTF8½âÂë
ResponseStr := UTF8Decode(ResponseStr);
if (Pos('T',ResponseStr)>0) then
begin
if (not CheckBox1.Checked) then
begin
if RadioGroup1.ItemIndex=0 then s:='ÐÂÔö';
if RadioGroup1.ItemIndex=1 then s:='ÐÞ¸Ä';
if RadioGroup1.ItemIndex=2 then s:='È¡Ïû';
with aQuery do
begin
Close;
SQL.Clear;
SQL.Add('insert into t_op_state (±àºÅ,ÒµÎñ״̬,ÊÇ·ñÍê³É,Íê³Éʱ¼ä,¼ÈëÈÕÆÚ,Íê³ÉÈË,¼ÈëÈË,±¸×¢,ϵͳ¼ÓÈë) values ('
+QuotedStr(frm_op_seae.t_op_seae.fieldbyname('±àºÅ').AsString)+','+QuotedStr('VGMÒÑ·¢ËÍ')+',1,'
+QuotedStr(FormatDateTime('yyyy-mm-dd hh:mm:ss',Now))+','+QuotedStr(FormatDateTime('yyyy-mm-dd hh:mm:ss',Now))+','
+QuotedStr(employee)+','+QuotedStr(employee)+','+QuotedStr(s)+',1)');
ExecSQL;
end;
FreeAndNil(aQuery);
sendmail;
end ;
ShowMessage('Ìá½»³É¹¦£¡') ;
end
else ShowMessage('Ìύʧ°Ü£¡'); // ShowMessage(ResponseStr);
finally
IdHttp.Free;
RequestStream.Free;
ResponseStream.Free;
end;
DeleteFile(RequestFile);
end;
procedure TFrm_op_seae_edi_CSSA.bsSkinButton4Click(Sender: TObject);
begin
SendFile;
end;
end.