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.

995 lines
25 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_zxd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls,inifiles, DB, ADODB,IdFTP,IdFTPCommon,
ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, dxDBTLCl,
dxGrClms;
type
TCarrier = Record //ÏûÏ¢¿Í»§¶ËÏûÏ¢½á¹¹
EdiNo :String;
CarrierName :String;
end;
Tfrm_op_seae_edi_zxd = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
SaveDialog1: TSaveDialog;
t_op_ctn: TADOQuery;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
bsSkinButton3: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
GroupBox1: TGroupBox;
Label8: TLabel;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Label9: TLabel;
Label10: TLabel;
Edit11: TEdit;
Label11: TLabel;
t_op_edi: TADOQuery;
Label12: TLabel;
Edit12: TEdit;
bsck: TbsSkinCheckRadioBox;
t_op_edictn: TADOQuery;
Panel1: TPanel;
Label2: TLabel;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Edit1: TEdit;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
Edit3: TEdit;
Edit4: TEdit;
RadioGroup1: TRadioGroup;
RadioGroup3: TRadioGroup;
dxDBGrid1: TdxDBGrid;
t_op_ctn1: TDataSource;
dxDBGrid1Column2: TdxDBGridColumn;
dxDBGrid1Column3: TdxDBGridColumn;
dxDBGrid1Column4: TdxDBGridColumn;
dxDBGrid1Column5: TdxDBGridColumn;
dxDBGrid1Column6: TdxDBGridColumn;
dxDBGrid1Column7: TdxDBGridColumn;
dxDBGrid1Column8: TdxDBGridColumn;
dxDBGrid1Column1: TdxDBGridCheckColumn;
procedure bsSkinButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
function get_txtBooking(str:Tstringlist):integer;
function get_goods(str:widestring):widestring;
procedure bsSkinButton3Click(Sender: TObject);
function isEditrue(DataSet:TDataSet):boolean;
function Changestr(str:widestring):string;
function GetLengthword(var s: String; l: Integer;str:String): String;
procedure GetLengthTString(var sl:TStringList;l:integer);
function GetStrNum(str:String):integer;
function GetCharNum(str:String):integer;
procedure bsSkinButton4Click(Sender: TObject);
function GetvesselEdi(avessel: String): String;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
aCarrier:TCarrier;
SelectCarrier:Boolean;
function FormatEdiString(old:String;Strlength:integer):String;
function GetpkgsEdi(pkgs:String):String;
function GetShipEdiNO(Ship:String): String;
end;
var
frm_op_seae_edi_zxd: Tfrm_op_seae_edi_zxd;
implementation
uses u_op_seae, my_sys_function, u_main, u_data_share, u_op_seae_assistant;
{$R *.dfm}
function Tfrm_op_seae_edi_zxd.GetShipEdiNO(Ship:String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ´úÂë,EDI´úÂë,¿Í»§¼ò³Æ,¿Í»§È«³Æ,À¿»õÈË,¼ÈëÈË,¼ÈëÈÕÆÚ from t_crm_client');
SQL.Add('where ¿Í»§¼ò³Æ='''+Ship+'''');
SQL.Add('order by ´úÂë');
Open;
if not IsEmpty then
Result:=Trim(FieldByName('´úÂë').asstring)
else
Result:='';
end;
finally
FreeAndNil(aQuery);
end;
end;
function Tfrm_op_seae_edi_zxd.GetpkgsEdi(pkgs: String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select Edi´úÂë from t_code_package where ´úÂë='''+pkgs+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('Edi´úÂë').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function Tfrm_op_seae_edi_zxd.FormatEdiString(old:String;Strlength:integer):String;
var
i:integer;
begin
Result:=Trim(Old);
Result:=StringReplace(Result,'?','??',[rfReplaceAll]);
Result:=StringReplace(Result,':','?:',[rfReplaceAll]);
Result:=StringReplace(Result,'''','?''',[rfReplaceAll]);
Result:=StringReplace(Result,'+','?+',[rfReplaceAll]);
end;
function Tfrm_op_seae_edi_zxd.GetvesselEdi(avessel: String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select ´¬²°ºôºÅ from t_code_vessel where Ó¢ÎÄ´¬Ãû='''+avessel+'''');
Open;
if IsEmpty then
Result:=''
else
Result:=FieldByName('´¬²°ºôºÅ').AsString;
end;
finally
FreeAndNil(aQuery);
end;
end;
function Tfrm_op_seae_edi_zxd.isEditrue(DataSet:TDataSet): boolean;
var
cntrs:String;
begin
result:=true;
if trim(DataSet.fieldbyname('Ö÷Ìáµ¥ºÅ').asstring)='' then
begin
result:=false;
MessageDlg('Ìáµ¥ºÅ²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('¿ª´¬ÈÕÆÚ').asstring)='' then begin
result:=false;
MessageDlg('¿ª´¬ÈÕÆÚ²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('´¬Ãû').asstring)='' then begin
result:=false;
MessageDlg('´¬Ãû²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('³¡Õ¾').asstring)='' then begin
result:=false;
MessageDlg('³¡Õ¾²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('°ü×°').asstring)='' then begin
result:=false;
MessageDlg('°ü×°²»´æÔÚ!',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('»õÎïÃèÊö').asstring)='' then begin
result:=false;
MessageDlg('»õÎïÃèÊö²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(DataSet.fieldbyname('ßéÍ·').asstring)='' then begin
result:=false;
MessageDlg('ßéÍ·²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if DataSet.fieldbyname('¼þÊý').asinteger=0 then begin
result:=false;
MessageDlg('¼þÊý²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if DataSet.fieldbyname('ÖØÁ¿').asFloat=0 then begin
result:=false;
MessageDlg('×ÜÖØÁ¿²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if DataSet.fieldbyname('³ßÂë').asFloat=0 then begin
result:=false;
MessageDlg('×ܳßÂë²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(frm_op_seae.t_op_seae.fieldbyname('»õÎï±êʶ').asstring)='' then begin
result:=false;
MessageDlg('»õÎï±êʶ²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if trim(frm_op_seae.t_op_seae.FieldByName('»õÎï±êʶ').asstring)='D' then begin
if Trim(frm_op_seae.t_op_seae.fieldbyname('ΣÏÕÆ··ÖÀà').asstring)='' then begin
result:=false;
MessageDlg('ΣÏÕÆ·µÈ¼¶²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if Trim(frm_op_seae.t_op_seae.fieldbyname('ΣÏÕÆ·±àºÅ').asstring)='' then begin
result:=false;
MessageDlg('ΣÏÕÆ·±àºÅ²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if GetStrNum(Trim(frm_op_seae.t_op_seae.fieldbyname('ΣÏÕÆ·±àºÅ').asstring))<>4 then begin
result:=false;
MessageDlg('ΣÏÕÆ·±àºÅ±ØÐëÊÇ4λÊý×Ö',mtWarning,[mbOk],0);
exit;
end;
end;
if trim(frm_op_seae.t_op_seae.FieldByName('»õÎï±êʶ').asstring)='R' then begin
if Trim(frm_op_seae.t_op_seae.fieldbyname('ÉèÖÃζÈ').asstring)='' then begin
result:=false;
MessageDlg('ÉèÖÃζȲ»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if Trim(frm_op_seae.t_op_seae.fieldbyname('Àä²Øͨ·çÁ¿').asstring)='' then begin
result:=false;
MessageDlg('Àä²Øͨ·çÁ¿²»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if Trim(frm_op_seae.t_op_seae.fieldbyname('×îµÍζÈ').asstring)='' then begin
result:=false;
MessageDlg('×îµÍζȲ»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
if Trim(frm_op_seae.t_op_seae.fieldbyname('×î¸ßζÈ').asstring)='' then begin
result:=false;
MessageDlg('×î¸ßζȲ»ÄÜΪ¿Õ',mtWarning,[mbOk],0);
exit;
end;
end;
end;
function Tfrm_op_seae_edi_zxd.get_goods(str:widestring):widestring;
var
str_all:Tstringlist;
r_str:widestring;
i:integer;
begin
str:=Changestr(trim(str));
str_all:=Tstringlist.Create;
str_all.Text:=str;
for i:=0 to str_all.Count-1 do
begin
r_str:=r_str+' '+str_all[i];
end;
result:=trim(r_str);
end;
function Tfrm_op_seae_edi_zxd.Changestr(str:widestring):string;
var
i:integer;
strC:widestring;
begin
strC:='';
for i:=1 to length(str) do
begin
if ((str[i]=#39) or (str[i]=':') or (str[i]='''') or (str[i]='+') or (str[i]='?')) then
begin
strC:=strC+'?'+str[i];
end
else
begin
strC:=strC+str[i];
end;
end;
result:=strC;
end;
function Tfrm_op_seae_edi_zxd.GetLengthword(var s: String; l: Integer;str:String): String;
var
i:Integer;
b:Boolean;
begin
s:='';
if Length(str)<=l then begin
result:=str;
end else begin
b:=true;
s:=Copy(str,l+1,Length(str)-l);
str:=Copy(str,1,l);
result:='';
for i:=Length(str) downto 1 do begin
if (str[i]<>' ') and b then
s:=str[i]+s
else begin
b:=false;
result:=str[i]+Result;
end;
end;
s:=s+' ';
end;
end;
procedure Tfrm_op_seae_edi_zxd.GetLengthTString(var sl: TStringList; l: integer);
var
i:integer;
str_head,S:String;
Stemp:TStrings;
begin
Stemp:=TStringList.Create;
try
str_head:='';
S:='';
for i:=0 to sl.Count-1 do begin
if sl[i]<>'' then
stemp.add(GetLengthword(str_head,l,s+sl[i]));
S:=Str_head;
end;
while S<>'' do begin
stemp.add(GetLengthword(str_head,l,s));
S:=Str_head;
end;
SL.Assign(Stemp);
finally
FreeAndNil(Stemp);
end;
end;
function Tfrm_op_seae_edi_zxd.GetStrNum(str:String):integer;
var
i:integer;
begin
result:=0;
if str='' then exit;
for i:=1 to length(Str) do begin
if str[i] in ['0','1','2','3','4','5','6','7','8','9'] then
result:=result+1;
end;
end;
function Tfrm_op_seae_edi_zxd.GetCharNum(str:String):integer;
var
i:integer;
begin
result:=0;
if str='' then exit;
for i:=1 to length(Str) do begin
if str[i] in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] then
result:=result+1;
end;
end;
function Tfrm_op_seae_edi_zxd.get_txtBooking(str:Tstringlist):integer;
var
str_all,sl,sl1:Tstringlist;
l,count,m:integer;
FILEFUNCTION,s:string;
Qty:integer;
pkg,cmb:double;
begin
if RadioGroup3.ItemIndex=0 then
FILEFUNCTION:='9' //9ԭʼ 5 ¸üÐÂ
else FILEFUNCTION:='4;';
Qty:=0;
pkg:=0;
cmb:=0;
count:=0;
str.Add ('00:'+'COSTCO'
+':'+'CONTAINER LOAD PLAN'
+':'+FILEFUNCTION
+':'+trim(Edit1.Text)
+':'+trim(Edit3.Text)
+':'+FormatDateTime('YYYYMMDDhhmm',Now)
+':'+frm_op_seae.t_op_seae.fieldbyname('×°¸Û´úÂë').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('×°¸Û´úÂë').asstring+#39);
count:=count+1;
str.Add ('10:'+trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('´¬Ãû').asstring))
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('´¬Ãû').asstring)
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('º½´Î').asstring)
+':'
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('´¬¹«Ë¾').asstring)+#39);
count:=count+1;
with t_op_ctn do
begin
First;
while not eof do
begin
if t_op_ctn.FieldByName('A').AsBoolean then
begin
str.Add ('50:'+trim(fieldbyname('ÏäºÅ').asstring)
+':'+trim(fieldbyname('³ß´ç').asstring)+trim(fieldbyname('ÏäÐÍ').asstring)
+':'+'F'
+':'+'O'
+':'+GetShipEdiNO(trim(frm_op_seae.t_op_seae.fieldbyname('³¡Õ¾').asstring)) //×°ÏäµØµã´úÂë
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('³¡Õ¾').asstring) //×°ÏäµØµã
+':'+FormatDateTime('YYYYMMDDhhmm',Now)
+':'+trim(fieldbyname('·âºÅ').asstring)
+':' // Ïä¾­ÓªÈË´úÂë
+':' //Ïä¾­ÓªÈË
+#39);
count:=count+1;
Qty:=Qty+fieldbyname('¼þÊý').asInteger;
pkg:=pkg+fieldbyname('ÖØÁ¿').AsFloat;
cmb:=cmb+fieldbyname('³ßÂë').AsFloat;
end;
next;
end;
end;
str.Add ('51:'+trim(frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').asstring)
+':'+frm_op_seae.t_op_seae.fieldbyname('ж»õ´úÂë').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('ж»õ¸Û').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('×°¸Û´úÂë').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('×°»õ¸Û').asstring
+':'
+':'
+':'+frm_op_seae.t_op_seae.fieldbyname('½»»õ´úÂë').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('½»»õµØµã').asstring
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('»õ´ú¹«Ë¾').asstring)+#39);
count:=count+1;
if trim(frm_op_seae.t_op_seae.FieldByName('»õÎï±êʶ').asstring)='R' then
begin
str.Add ('52:'+'1'
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('ÔËÊ䷽ʽ').asstring) // »õÎï´úÂë
+':'
+':'+IntToStr(Qty)
+':'+GetpkgsEdi(trim(frm_op_seae.t_op_seae.fieldbyname('°ü×°').asstring))
+':'+frm_op_seae.t_op_seae.fieldbyname('°ü×°').asstring
+':'+FormatFloat(';;',pkg)
+':'+FormatFloat(';;',cmb)
+':'+'C'
+':'+frm_op_seae.t_op_seae.fieldbyname('ζÈ').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('×îµÍζÈ').asstring
+':'+frm_op_seae.t_op_seae.fieldbyname('×î¸ßζÈ').asstring+#39);
count:=count+1;
end
else
if trim(frm_op_seae.t_op_seae.FieldByName('»õÎï±êʶ').asstring)='D' then
begin
end
else
begin
str.Add ('52:'+'1'
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('ÔËÊ䷽ʽ').asstring) // »õÎï´úÂë
+':'
+':'+IntToStr(Qty)
+':'+GetpkgsEdi(trim(frm_op_seae.t_op_seae.fieldbyname('°ü×°').asstring))
+':'+frm_op_seae.t_op_seae.fieldbyname('°ü×°').asstring
+':'+FormatFloat(';;',pkg)
+':'+FormatFloat(';;',cmb)+#39);
count:=count+1;
end;
sl:=Tstringlist.Create;
sl1:=Tstringlist.Create;
sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('»õÎïÃèÊö').AsString;
GetLengthTString(sl1,70);
sl.text:='';
for L:=0 to sl1.Count-1 do begin
if Trim(sl1.Strings[L])<>'' then
sl.Add(sl1.Strings[L]);
end;
M:=1;
for L:=0 to sl.Count-1 do begin
if M<=5 then
begin
if M=1 then
begin
s:='53:'+FormatEdiString(sl.Strings[L],0)+':';
end
else
begin
if M=5 then
s:=s+FormatEdiString(sl.Strings[L],0)
else
s:=s+FormatEdiString(sl.Strings[L],0)+':';
end;
end
else
begin
S:=S+'''';
Str.Add(S);
M:=1;
s:='53:'+FormatEdiString(sl.Strings[L],0)+':';
end;
M:=M+1;
end;
S:=S+'''';
Str.Add(S);
Count:=Count+M+1;
sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('ßéÍ·').AsString;
GetLengthTString(sl1,70);
sl.text:='';
for L:=0 to sl1.Count-1 do begin
if Trim(sl1.Strings[L])<>'' then
sl.Add(sl1.Strings[L]);
end;
M:=1;
for L:=0 to sl.Count-1 do begin
if M<=5 then
begin
if M=1 then
begin
s:='54:'+FormatEdiString(sl.Strings[L],0)+':';
end
else
begin
if M=5 then
s:=s+FormatEdiString(sl.Strings[L],0)
else
s:=s+FormatEdiString(sl.Strings[L],0)+':';
end;
end
else
begin
S:=S+'''';
Str.Add(S);
M:=1;
s:='54:'+FormatEdiString(sl.Strings[L],0)+':';
end;
M:=M+1;
end;
S:=S+'''';
Str.Add(S);
Count:=Count+M+1;
if trim(frm_op_seae.t_op_seae.FieldByName('»õÎï±êʶ').asstring)='D' then
begin
str.Add ('55:'+trim(frm_op_seae.t_op_seae.fieldbyname('ΣÏÕÆ··ÖÀà').asstring)
+':'+frm_op_seae.t_op_seae.fieldbyname('ΣÏÕÆ·±àºÅ').asstring
+':'
+':'
+':'
+':'
+':'+#39);
count:=count+1;
end;
with t_op_ctn do
begin
First;
while not eof do
begin
if t_op_ctn.FieldByName('A').AsBoolean then
begin
str.Add ('56:'+trim(fieldbyname('ÏäºÅ').asstring)
+':'+fieldbyname('¼þÊý').asString
+':'+fieldbyname('ÖØÁ¿').asString
+':'+fieldbyname('ÖØÁ¿').asString
+':'+fieldbyname('³ßÂë').asString
+#39);
count:=count+1;
end;
next;
end;
end;
result:=count;
end;
procedure Tfrm_op_seae_edi_zxd.bsSkinButton1Click(Sender: TObject);
var
str:Tstringlist;
i,Count,get_Count,bill_count:integer;
inifile1:Tinifile;
begin
try
str:=Tstringlist.Create;
str.Clear;
count:=0;
bill_count:=0;
if frm_op_seae.dxdbgrid1.SelectedCount>1 then
begin
for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
begin
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i]));
if not isEditrue(frm_op_seae.t_op_seae) then
exit;
if RadioGroup1.ItemIndex=1 then
// get_Count:=frm_op_seae_edi_zxd.get_txtSI(str)
else
get_Count:=frm_op_seae_edi_zxd.get_txtBooking(str);
if get_Count=-1 then
exit
else
count:=count+get_Count;
bill_count:=bill_count+1;
end;
str.Add('99:'+intToStr(count+1)+'''');
end
else
begin
if not isEditrue(frm_op_seae.t_op_seae) then
exit;
if RadioGroup1.ItemIndex=1 then
// get_Count:=frm_op_seae_edi_zxd.get_txtSI(str)
else
get_Count:=frm_op_seae_edi_zxd.get_txtBooking(str);
if get_Count=-1 then
exit
else
count:=count+get_Count;
str.Add('99:'+intToStr(count+1)+'''');
end;
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('Ö÷Ìáµ¥ºÅ').asstring+GetDatetime(datetimetostr(now),1);
if SaveDialog1.Execute then
begin
str.SaveToFile(SaveDialog1.FileName+'.txt');
showmessage('ÎļþÉú³É³É¹¦£¡');
end
else
begin
showmessage('ÎļþÉú³Éʧ°Ü£¡');
exit;
end;
except
on e:exception do
begin
ShowMessage(e.Message);
end;
end;
end;
{procedure Tfrm_op_seae_edi_zxd.bsSkinButton1Click(Sender: TObject);
var
str:Tstringlist;
i,Count,get_Count,bill_count:integer;
inifile1:Tinifile;
begin
str:=Tstringlist.Create;
str.Clear;
count:=0;
bill_count:=0;
if frm_op_seae.dxdbgrid1.SelectedCount>1 then
begin
for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
begin
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i]));
get_Count:=frm_op_seae_edi_zxd.get_txt(str);
if get_Count=-1 then
exit
else
count:=count+get_Count;
bill_count:=bill_count+1;
end;
str.Add('UNT+'+INTTOSTR(count)+'+1'+#39);
str.Add('UNZ+'+inttostr(bill_count)+'+100'+#39);
end
else
begin
get_Count:=frm_op_seae_edi_zxd.get_txt(str);
if get_Count=-1 then
exit
else
count:=count+get_Count;
str.Add('UNT+'+INTTOSTR(count)+'+1'+#39);
str.Add('UNZ+1+100'+#39);
end;
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('Ö÷Ö÷Ìáµ¥ºÅ').asstring;
if SaveDialog1.Execute then
begin
str.SaveToFile(SaveDialog1.FileName+'.txt');
showmessage('ÎļþÉú³É³É¹¦£¡');
end
else
begin
showmessage('ÎļþÉú³Éʧ°Ü£¡');
exit;
end;
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('INTRA','SEND_CODE',edit1.text);
inifile1.WriteString('INTRA','SEND_NAME',edit2.text);
inifile1.WriteString('INTRA','RECEIVE_CODE',edit3.text);
inifile1.WriteString('INTRA','RECEIVE_NAME',edit4.text);
inifile1.free;
close;
end;}
procedure Tfrm_op_seae_edi_zxd.FormShow(Sender: TObject);
var
inifile1:Tinifile;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
edit1.text:=inifile1.ReadString('EDI','SEND_CODE_ZXD','');
edit2.text:=inifile1.ReadString('EDI','SEND_NAME_ZXD','');
edit3.text:=inifile1.ReadString('EDI','RECEIVE_CODE_ZXD','');
edit4.text:=inifile1.ReadString('EDI','RECEIVE_NAME_ZXD','');
edit5.text:=inifile1.ReadString('EDI','SEND_TEL_ZXD','');
edit6.text:=inifile1.ReadString('EDI','SEND_MAIL_ZXD','');
edit7.text:=inifile1.ReadString('EDI','SEND_ATTN_ZXD','');
edit8.text:=inifile1.ReadString('EDI','FTPADD_ZXD','');
edit9.text:=inifile1.ReadString('EDI','FTPNAME_ZXD','');
edit10.text:=inifile1.ReadString('EDI','FTPPASS_ZXD','');
edit11.text:=inifile1.ReadString('EDI','FTPPATH_ZXD','/');
edit12.text:=inifile1.ReadString('EDI','ADDR_ZXD','');
inifile1.free;
end;
procedure Tfrm_op_seae_edi_zxd.bsSkinButton3Click(Sender: TObject);
begin
if frm_op_seae_edi_zxd.Width=650 then
frm_op_seae_edi_zxd.Width:=305
else
frm_op_seae_edi_zxd.Width:=650;
end;
procedure Tfrm_op_seae_edi_zxd.bsSkinButton4Click(Sender: TObject);
var
IdFTP1:TIdFTP;
str:widestring;
str_file:widestring;
ftpar,ftpname,ftppass,ftppath,ScriptPath:String;
StrL:Tstringlist;
i,Count,get_Count,bill_count,i_soi:integer;
begin
i_soi:=0;
if bsck.Checked then
begin
if frm_op_seae_assistant=nil then
begin
ShowMessage('ÇëÔÚ(ίÍкÍÌáµ¥)½çÃæ·¢ËÍ·Öµ¥Edi');
exit;
end
end;
ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\';
if not DirectoryExists(ScriptPath) then
CreateDir(ScriptPath);
ftpar:=Trim(Edit8.Text);
if ftpar='' then begin
MessageDlg('ÇëÉèÖÃFTPµØÖ·£¡',mtWarning,[mbOk],0);
exit;
end;
ftpname:=Trim(Edit9.Text);;
if ftpar='' then begin
MessageDlg('ÇëÉèÖÃFTPÓû§Ãû£¡',mtWarning,[mbOk],0);
exit;
end;
ftppass:=Trim(Edit10.Text);;
if ftpar='' then begin
MessageDlg('ÇëÉèÖÃFTPÃÜÂ룡',mtWarning,[mbOk],0);
exit;
end;
ftppath:=Trim(Edit11.Text);;
str:=ScriptPath
+frm_op_seae.t_op_seae.fieldbyname('ÒµÎñ±àºÅ').asstring
+FormatDateTime('yyyy',now)
+FormatDateTime('mm',now)
+FormatDateTime('dd',now)
+FormatDateTime('hh',now)
+FormatDateTime('nn',now)+'.txt';
str_file:=frm_op_seae.t_op_seae.fieldbyname('ÒµÎñ±àºÅ').asstring
+FormatDateTime('yyyy',now)
+FormatDateTime('mm',now)
+FormatDateTime('dd',now)
+FormatDateTime('hh',now)
+FormatDateTime('nn',now)+'.txt';
StrL:=Tstringlist.Create;
StrL.Clear;
count:=0;
bill_count:=0;
if frm_op_seae.dxdbgrid1.SelectedCount>1 then
begin
for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
begin
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i]));
if not isEditrue(frm_op_seae.t_op_seae) then
exit;
if RadioGroup1.ItemIndex=1 then
// get_Count:=frm_op_seae_edi_zxd.get_txtSI(StrL)
else
get_Count:=frm_op_seae_edi_zxd.get_txtBooking(StrL);
if get_Count=-1 then
exit
else
count:=count+get_Count;
bill_count:=bill_count+1;
end;
StrL.Add('99:'+intToStr(count+1)+'''');
end
else
begin
if not isEditrue(frm_op_seae.t_op_seae) then
exit;
if RadioGroup1.ItemIndex=1 then
// get_Count:=frm_op_seae_edi_zxd.get_txtSI(StrL)
else
get_Count:=frm_op_seae_edi_zxd.get_txtBooking(StrL);
if get_Count=-1 then
exit
else
count:=count+get_Count;
StrL.Add('99:'+intToStr(count+1)+'''');
end;
StrL.SaveToFile(str);
try
IdFTP1:=TIdFTP.Create(application);
with idftp1 do
begin
Username:=ftpname;
Password:=ftppass;
Host:=ftpar;
Connect;
end;
idftp1.ChangeDir(ftppath);
idftp1.TransferType:=ftBinary;
idftp1.Put(str,str_file);
idftp1.Disconnect;
showmessage('ÎļþÉÏ´«³É¹¦£¡');
except
deletefile(str);
i_soi:=1;
showmessage('ÎļþÉÏ´«´íÎó£¡');
end;
idftp1.Free;
if i_soi=0 then UpdateSOIStatus(RadioGroup1.ItemIndex,frm_op_seae.t_op_seae.fieldbyname('񅧏').asstring);
end;
procedure Tfrm_op_seae_edi_zxd.FormClose(Sender: TObject;
var Action: TCloseAction);
VAR
inifile1:TIniFile;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('EDI','SEND_CODE_ZXD',edit1.text);
inifile1.WriteString('EDI','ZXDSEND_NAME_ZXD',edit2.text);
inifile1.WriteString('EDI','RECEIVE_CODE_ZXD',edit3.text);
inifile1.WriteString('EDI','RECEIVE_NAME_ZXD',edit4.text);
inifile1.WriteString('EDI','SEND_TEL_ZXD',edit5.text);
inifile1.WriteString('EDI','SEND_MAIL_ZXD',edit6.text);
inifile1.WriteString('EDI','SEND_ATTN_ZXD',edit7.text);
inifile1.WriteString('EDI','FTPADD_ZXD',edit8.text);
inifile1.WriteString('EDI','FTPNAME_ZXD',edit9.text);
inifile1.WriteString('EDI','FTPPASS_ZXD',Edit10.text);
inifile1.WriteString('EDI','FTPPATH_ZXD',Edit11.text);
inifile1.WriteString('EDI','ADDR_ZXD',edit12.text);
inifile1.WriteInteger('EDI','CMASEND_TYPE_ZXD',RadioGroup1.ItemIndex);
inifile1.free;
action:=cafree;
frm_op_seae_edi_zxd:=nil;
end;
procedure Tfrm_op_seae_edi_zxd.FormCreate(Sender: TObject);
begin
t_op_ctn.Close;
t_op_ctn.Parameters.ParamByName('񅧏').Value:=frm_op_seae.t_op_seae.fieldbyname('񅧏').asstring;
t_op_ctn.Open;
end;
end.