695 lines
19 KiB
ObjectPascal
695 lines
19 KiB
ObjectPascal
unit U_ClothContractListJY;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
|
||
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter,
|
||
RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
|
||
cxTextEdit, cxPC, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP,ShellAPI, cxCheckBox,jpeg,IniFiles;
|
||
|
||
type
|
||
TfrmClothContractListJY = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Label3: TLabel;
|
||
ConNo: TEdit;
|
||
Label5: TLabel;
|
||
C_Code: TEdit;
|
||
TBExport: TToolButton;
|
||
Order_Main: TClientDataSet;
|
||
Label4: TLabel;
|
||
FactoryNoName: TEdit;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
CDS_PRT: TClientDataSet;
|
||
ToolButton1: TToolButton;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1OrderNo: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1DeliveryDate: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1FactoryNo1Name: TcxGridDBColumn;
|
||
v1PRTSpec: TcxGridDBColumn;
|
||
v1Qty1: TcxGridDBColumn;
|
||
v1PRTOrderQty: TcxGridDBColumn;
|
||
v1OrderUnit: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column3: TcxGridDBColumn;
|
||
ConType: TComboBox;
|
||
Label14: TLabel;
|
||
ToolButton2: TToolButton;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
ComboBox1: TComboBox;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
ToolButton5: TToolButton;
|
||
ODPat: TOpenDialog;
|
||
IdFTP1: TIdFTP;
|
||
SaveDialog1: TSaveDialog;
|
||
Panel16: TPanel;
|
||
Panel2: TPanel;
|
||
ToolButton6: TToolButton;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure conPress(Sender: TObject; var Key: Char);
|
||
procedure cxPageControl1Change(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure ToolButton6Click(Sender: TObject);
|
||
private
|
||
FInt,PFInt:Integer;
|
||
canshu1:string;
|
||
lstPat: TStringList;
|
||
AJpeg: TJPEGImage;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData():Boolean;
|
||
procedure ReadINIFile10();
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmClothContractListJY: TfrmClothContractListJY;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_ClothContractInPutJY,U_ModuleNote;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmClothContractListJY.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmClothContractListJY:=nil;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBCloseClick(Sender: TObject);
|
||
var
|
||
FPath:String;
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>');
|
||
{FPath:='D:\Right1209\';
|
||
if DirectoryExists(ExtractFileDir(FPath)) then
|
||
winexec('cmd /c rd /s /q D:\Right1209\',sw_hide); }
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,B.* from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId ');
|
||
sql.Add(' where A.FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
|
||
sql.Add(' and A.FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''');
|
||
sql.Add(' and isnull(A.JYType,'''')<>'''' ');
|
||
sql.Add(' and A.Filler='''+Trim(DName)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.InitForm();
|
||
var
|
||
FSJ:string;
|
||
begin
|
||
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>');
|
||
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
||
BegDate.DateTime:=EndDate.DateTime-30;
|
||
FSJ:='select ZdyName Name,ZdyName Code from KH_Zdy where TYpe=''JGGX'' and ZdyName not like ''%<25>ؼ<EFBFBD>%'' ';
|
||
SInitComBoxBySql(ADOQueryTemp,ConType,False,Fsj);
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBEditClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Trim(canshu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
try
|
||
frmClothContractInPutJY:=TfrmClothContractInPutJY.Create(Application);
|
||
with frmClothContractInPutJY do
|
||
begin
|
||
PState:=1;
|
||
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
|
||
FConNo:=Trim(Self.Order_Main.fieldbyname('ConNo').AsString);
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothContractInPutJY.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
{if Trim(canshu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end; }
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD where COnMainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=false then
|
||
begin
|
||
Application.MessageBox('<27>Ѿ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>뵥<EFBFBD><EBB5A5><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
sql.Add(' and isnull(ChkStatus,'''')<>'''' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
if DelData() then
|
||
begin
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
|
||
function TfrmClothContractListJY.DelData():Boolean;
|
||
begin
|
||
try
|
||
Result:=false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Sub where SubId='''+Trim(Order_Main.fieldbyname('SubId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
if Trim(Order_Main.fieldbyname('SubId').AsString)='' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result:=False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBPrintClick(Sender: TObject);
|
||
var
|
||
fPrintFile,FConNoM,RPTName:string;
|
||
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Trim(ComboBox1.Text)='' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
RPTName:='Report\'+Trim(ComboBox1.Text)+'.rmf';
|
||
// fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬ.rmf' ;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) +RPTName;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,B.*,Money=B.ConQty*B.ConPrice,C.*,D.KHName,D.ZKTelNo,D.ZKFax,D.ZKAddress ');
|
||
sql.Add(' ,C.ZdyName,C.ZdyStr1,C.ZdyStr2,C.ZdyStr3,C.ZdyStr4');
|
||
sql.Add(' from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId');
|
||
sql.Add(' left join KH_Zdy C on A.CompanyName=C.ZdyName and C.Type=''GSTT'' ');
|
||
sql.Add(' left join ZH_KH_Info D on A.FactoryNo=D.ZKID');
|
||
sql.Add(' where A.Mainid='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,CDS_PRT);
|
||
SInitCDSData20(ADOQueryTemp,CDS_PRT);
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
//RMVariables['begindate']:=begindate.DateTime;
|
||
//RMVariables['enddate']:=enddate.DateTime;
|
||
//RMVariables['printtime']:=Now;
|
||
//RMVariables['printer']:=Trim(gUserName);
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+RPTName),'<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.TBAddClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmClothContractInPutJY:=TfrmClothContractInPutJY.Create(Application);
|
||
with frmClothContractInPutJY do
|
||
begin
|
||
PState:=0;
|
||
FMainId:='';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothContractInPutJY.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ConNoChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.conPress(Sender: TObject;
|
||
var Key: Char);
|
||
begin
|
||
if Key=#13 then
|
||
begin
|
||
if Length(Trim(ConNo.Text))<3 then Exit;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,B.*,Money=B.C_Qty*B.Price from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId ');
|
||
sql.Add(' where A.ConNo like '''+'%'+Trim(ConNo.text)+'%'+'''');
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.cxPageControl1Change(Sender: TObject);
|
||
begin
|
||
// InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
try
|
||
frmClothContractInPutJY:=TfrmClothContractInPutJY.Create(Application);
|
||
with frmClothContractInPutJY do
|
||
begin
|
||
PState:=1;
|
||
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
|
||
FConNo:=Trim(Self.Order_Main.fieldbyname('ConNo').AsString);
|
||
PCopyInt:=1;
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothContractInPutJY.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmClothContractInPutJY:=TfrmClothContractInPutJY.Create(Application);
|
||
with frmClothContractInPutJY do
|
||
begin
|
||
PState:=1;
|
||
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
|
||
FConNo:=Trim(Self.Order_Main.fieldbyname('ConNo').AsString);
|
||
TBSave.Visible:=False;
|
||
ToolBar2.Visible:=False;
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothContractInPutJY.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmModuleNote:=TfrmModuleNote.Create(Application);
|
||
with frmModuleNote do
|
||
begin
|
||
flag:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmModuleNote.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.FormCreate(Sender: TObject);
|
||
begin
|
||
lstPat := TStringList.Create;
|
||
canshu1:=Trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton4Click(Sender: TObject);
|
||
var
|
||
i,j: Integer;
|
||
PatFile,HZStr: String;
|
||
FTPPath,FConNo,MaxNo:string;
|
||
begin
|
||
{if Trim(canshu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end; }
|
||
lstPat.Clear;
|
||
if ODPat.Execute then
|
||
begin
|
||
lstPat.AddStrings(ODPat.Files);
|
||
end;
|
||
|
||
if lstPat.Count > 0 then
|
||
begin
|
||
try
|
||
ReadINIFile10();
|
||
server:=ReadINIFileStr('SYSTEMSET.INI','SERVER','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ','127.0.0.1');
|
||
IdFTP1.Host :=server;//PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
IdFTP1.Quit;
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飡', '<27><>ʾ', MB_ICONWARNING);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
Exit;
|
||
end;
|
||
Panel16.Visible:=True;
|
||
Panel16.Refresh;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select isnull(Count(*),0) MM from XD_File where ');
|
||
SQL.Add(' filetype=''NXHT''');
|
||
Open;
|
||
j:=fieldbyname('MM').AsInteger;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
for i := 0 to lstPat.Count - 1 do
|
||
begin
|
||
PatFile := ExtractFileName(lstPat[i]);
|
||
HZStr:=Copy(PatFile,(Pos('.',PatFile)+1),(Length(PatFile)-Pos('.',PatFile)) ) ;
|
||
if IdFTP1.Connected then
|
||
begin
|
||
try
|
||
{if not DirectoryExists('D:\ͼƬ\'+Trim(gDef1)) then
|
||
ForceDirectories('D:\ͼƬ\'+Trim(gDef1)); }
|
||
// IdFTP1.Put(lstPat[i], Trim('\SC')+'\'+Trim(PatFile));
|
||
if GetLSNo(ADOQueryCmd,MaxNo,'NH','XD_File',4,1)=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
IdFTP1.Put(lstPat[i], Trim('\NH')+'\'+Trim(MaxNo)+'.'+Trim(HZStr));
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from XD_File where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('XFID').Value:=Trim(MaxNo);
|
||
FieldByName('CYID').Value:=Trim(Order_Main.fieldbyname('MainId').AsString);
|
||
FieldByName('CYNO').Value:=Trim(Order_Main.fieldbyname('ConNo').AsString);
|
||
FieldByName('filename').Value:=Trim(PatFile);
|
||
FieldByName('FileDate').Value:=SGetServerDate(ADOQueryTemp);
|
||
fieldbyname('FileType').value:=Trim('NXHT');
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('HZStr').Value:='.'+Trim(HZStr);
|
||
Post;
|
||
end;
|
||
except
|
||
//ADOQueryCmd.Connection.RollbackTrans;
|
||
//Application.MessageBox('ͼƬ<CDBC>ϴ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update Contract_Main Set FileFlag=1 where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
Panel16.Visible:=False;
|
||
Application.MessageBox('<27>ϴ<EFBFBD><CFB4>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27>ϴ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
procedure TfrmClothContractListJY.ReadINIFile10();
|
||
var
|
||
programIni:Tinifile; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||
FileName:string;
|
||
begin
|
||
FileName:=ExtractFilePath(Paramstr(0))+'SYSTEMSET.INI';
|
||
programIni:=Tinifile.create(FileName);
|
||
server:=programIni.ReadString('SERVER','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ','127.0.0.1');
|
||
programIni.Free;
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton5Click(Sender: TObject);
|
||
var
|
||
fHandle:THandle;
|
||
FInt:Integer;
|
||
FFName,FPath:String;
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Order_Main.fieldbyname('FileFlag').AsBoolean=False then Exit;
|
||
Panel2.Visible:=True;
|
||
Panel2.Refresh;
|
||
{ }
|
||
try
|
||
ReadINIFile10();
|
||
server:=ReadINIFileStr('SYSTEMSET.INI','SERVER','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ','127.0.0.1');
|
||
if Length(server)<6 then
|
||
begin
|
||
server:='127.0.0.1';
|
||
end;
|
||
IdFTP1.Host :=server;//PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
IdFTP1.Quit;
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飡', '<27><>ʾ', MB_ICONWARNING);
|
||
Exit;
|
||
end;
|
||
FPath:='D:\Right1209\';
|
||
if not DirectoryExists(ExtractFileDir(FPath)) then
|
||
CreateDir(ExtractFileDir(FPath));
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from XD_File where CYID='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
FFName:=Trim(ADOQueryTemp.fieldbyname('XFID').AsString)+Trim(ADOQueryTemp.fieldbyname('HZStr').AsString);
|
||
if FileExists(FPath+FFName)=false then
|
||
begin
|
||
IdFTP1.Get('NH\'+FFName,FPath+FFName);
|
||
end;
|
||
Panel2.Visible:=False;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
if FileExists(FPath+FFName) then
|
||
begin
|
||
ShellExecute(Handle, 'open',PChar(FPath+FFName),'', '', SW_SHOWNORMAL);
|
||
end;
|
||
{FFName:=Trim(CDS_SC.fieldbyname('FileName').AsString);
|
||
|
||
FFName:=FPath+FFName;
|
||
if FileExists(FFName)=false then
|
||
begin
|
||
IdFTP1.Get('SC\'+Trim(CDS_SC.fieldbyname('FileName').AsString),
|
||
FPath+Trim(CDS_SC.fieldbyname('FileName').AsString)
|
||
);
|
||
end;
|
||
Panel2.Visible:=False;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open',PChar(FPath+Trim(CDS_SC.fieldbyname('FileName').AsString)),'', '', SW_SHOWNORMAL); }
|
||
|
||
end;
|
||
|
||
procedure TfrmClothContractListJY.ToolButton6Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update Contract_Main Set FileFlag=0 where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
|
||
sql.Add(' delete XD_File where CYID='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|