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.

392 lines
15 KiB
Plaintext

This file contains ambiguous Unicode 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_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;
procedure bsSkinButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
private
{ 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','');
inifile1.free;
end;
procedure Tfrm_op_seae_edi_yh.bsSkinButton1Click(Sender: TObject);
var
str:Tstringlist;
i,j,Count:integer;
strsql,strRmain:string;
rs:Tadoquery;
wide_str:widestring;
k:integer;
inifile1:Tinifile;
strType:string;
strDatetime:string;
SenderCode,ReciverCode:string;
begin
SenderCode:=trim(edit1.Text) ;
ReciverCode:=trim(edit2.Text) ;
strType:='9';
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
begin
str:=Tstringlist.Create;
str.Clear;
str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39);
Count:=0;
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) +':'
+':::::::::::::'+ #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)
+ '::::::::::' +#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) +#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;
str.Add ('20:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('·¢»õÈË´úÂë').asstring) +#39);
str.Add ('21:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('ÊÕ»õÈË´úÂë').asstring) +#39);
str.Add ('22:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('֪ͨÈË´úÂë').asstring) +#39);
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 ('44:'+ Changestr(frm_op_seae.t_op_seae.fieldbyname('ßéÍ·').asstring)+#39);
str.Add ('47:'+ Changestr(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').asstring)+#39);
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;
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]));
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) +':'
+':::::::::::::'+ #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)
+ '::::::::::' +#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) +#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;
str.Add ('20:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('·¢»õÈË´úÂë').asstring)+#39);
str.Add ('21:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('ÊÕ»õÈË´úÂë').asstring)+#39);
str.Add ('22:'+':'
+Changestr(frm_op_seae.t_op_seae.fieldbyname('֪ͨÈË´úÂë').asstring)+#39);
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 ('44:'+ Changestr(frm_op_seae.t_op_seae.fieldbyname('ßéÍ·').asstring)+#39);
str.Add ('47:'+ Changestr(frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').asstring)+#39);
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;
str.Add ('99:'+ inttostr(Count+2)+#39);
end;
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').asstring;
if SaveDialog1.Execute then
begin
str.SaveToFile(SaveDialog1.FileName+'.txt');
showmessage('ÎļþÉú³É³É¹¦£¡');
end
else
begin
showmessage('ÎļþÉú³Éʧ°Ü£¡');
exit;
end;
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('EDI','YHSEND',edit1.text);
inifile1.WriteString('EDI','YHRECIEVE',edit2.text);
inifile1.free;
close;
end;
end.