379 lines
10 KiB
ObjectPascal
379 lines
10 KiB
ObjectPascal
|
|
unit U_FileUp_GRWJ;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
|
cxDataStorage, cxEdit, DB, cxDBData, ComCtrls, ToolWin, ExtCtrls,
|
|||
|
|
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|||
|
|
cxClasses, cxControls, cxGridCustomView, cxGrid, IdBaseComponent,
|
|||
|
|
IdComponent, IdTCPConnection, IdTCPClient, IdFTP, StdCtrls, ADODB,jpeg,
|
|||
|
|
BtnEdit,IniFiles, cxGridCustomPopupMenu, cxGridPopupMenu, DBClient,ShellAPI,
|
|||
|
|
cxCalendar, cxCheckBox;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmFileUp_GRWJ = class(TForm)
|
|||
|
|
cxGrid7: TcxGrid;
|
|||
|
|
TV7: TcxGridDBTableView;
|
|||
|
|
vFileName: TcxGridDBColumn;
|
|||
|
|
cxGridLevel6: TcxGridLevel;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Code: TEdit;
|
|||
|
|
ODPat: TOpenDialog;
|
|||
|
|
IdFTP1: TIdFTP;
|
|||
|
|
SaveDialog1: TSaveDialog;
|
|||
|
|
ADOQueryFile: TADOQuery;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
ToolBar6: TToolBar;
|
|||
|
|
FileUp: TToolButton;
|
|||
|
|
FileDel: TToolButton;
|
|||
|
|
ToolButton1: TToolButton;
|
|||
|
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
|
CDS_SC: TClientDataSet;
|
|||
|
|
FileDown: TToolButton;
|
|||
|
|
ToolButton2: TToolButton;
|
|||
|
|
Panel3: TPanel;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
FileName: TEdit;
|
|||
|
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
|
cxStyle1: TcxStyle;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ADOQuery2: TADOQuery;
|
|||
|
|
ToolButton3: TToolButton;
|
|||
|
|
V7FileDate: TcxGridDBColumn;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
BegDate: TDateTimePicker;
|
|||
|
|
EndDate: TDateTimePicker;
|
|||
|
|
Panel4: TPanel;
|
|||
|
|
Label6: TLabel;
|
|||
|
|
Label5: TLabel;
|
|||
|
|
Panel5: TPanel;
|
|||
|
|
Image1: TImage;
|
|||
|
|
TSure: TButton;
|
|||
|
|
ETaiTou: TEdit;
|
|||
|
|
FileDate: TDateTimePicker;
|
|||
|
|
Label7: TLabel;
|
|||
|
|
Label8: TLabel;
|
|||
|
|
FCYNO: TEdit;
|
|||
|
|
Panel2: TPanel;
|
|||
|
|
Panel16: TPanel;
|
|||
|
|
cxStyle2: TcxStyle;
|
|||
|
|
FYWYName: TBtnEditA;
|
|||
|
|
procedure FileUpClick(Sender: TObject);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure FileDelClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
|
procedure FileDownClick(Sender: TObject);
|
|||
|
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
|
procedure FileNameChange(Sender: TObject);
|
|||
|
|
procedure Image1Click(Sender: TObject);
|
|||
|
|
procedure TSureClick(Sender: TObject);
|
|||
|
|
procedure FYWYNameBtnClick(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
lstPat: TStringList;
|
|||
|
|
AJpeg: TJPEGImage;
|
|||
|
|
Canshu1,FDEPT,FDPName:string;
|
|||
|
|
procedure ReadINIFile10();
|
|||
|
|
procedure InitGrid();
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
CYID:String;
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmFileUp_GRWJ: TfrmFileUp_GRWJ;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_RTFun, U_ZDYHelp;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.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 TfrmFileUp_GRWJ.FileUpClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
fileDate.DateTime:=SGetServerDate(ADOQuery2);
|
|||
|
|
TSure.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
lstPat := TStringList.Create;
|
|||
|
|
canShu1:=trim(DParameters1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FileDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CDS_SC.IsEmpty then Exit;
|
|||
|
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
|||
|
|
if CDS_SC.fieldbyname('filler').AsString<>trim(DName) then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>','<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
SQL.Add(' Delete XD_File where XFID='''+Trim(CDS_SC.fieldbyname('XFID').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
initGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
WriteCxGrid('<27>鵵',TV7,'<27>ļ<EFBFBD><C4BC>ϴ<EFBFBD>');
|
|||
|
|
EndDate.Date:=SGetServerDate(ADOQueryTemp);
|
|||
|
|
BegDate.Date:=EndDate.Date-7;
|
|||
|
|
InitGrid();
|
|||
|
|
if Trim(canShu1)='<27><>ѯ' then
|
|||
|
|
begin
|
|||
|
|
FileUp.Visible:=False;
|
|||
|
|
FileDel.Visible:=False;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
FileUp.Visible:=True;
|
|||
|
|
FileDel.Visible:=True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.InitGrid();
|
|||
|
|
begin
|
|||
|
|
with ADOQueryFile do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.add('select * ');
|
|||
|
|
sql.add(' from XD_File where ');
|
|||
|
|
sql.Add(' FileType=''GD'' ');
|
|||
|
|
sql.add(' and FileDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and FileDate<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+'''');
|
|||
|
|
sql.add(' and CYID=''<27><><EFBFBD>˹鵵'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryFile,CDS_SC);
|
|||
|
|
SInitCDSData20(ADOQueryFile,CDS_SC);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmFileUp_GRWJ:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.ToolButton1Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FPath:String;
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
WriteCxGrid('<27>鵵',TV7,'<27>ļ<EFBFBD><C4BC>ϴ<EFBFBD>');
|
|||
|
|
FPath:='D:\Right1209\';
|
|||
|
|
if DirectoryExists(ExtractFileDir(FPath)) then
|
|||
|
|
winexec('cmd /c rd /s /q D:\Right1209\',sw_hide);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FileDownClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
fHandle:THandle;
|
|||
|
|
FInt:Integer;
|
|||
|
|
FFName,FPath:String;
|
|||
|
|
begin
|
|||
|
|
if CDS_SC.IsEmpty then Exit;
|
|||
|
|
{ }
|
|||
|
|
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));
|
|||
|
|
if Trim(CDS_SC.fieldbyname('XFID').AsString)<'GD1310280002' then
|
|||
|
|
begin
|
|||
|
|
FFName:=Trim(CDS_SC.fieldbyname('FileName').AsString);
|
|||
|
|
|
|||
|
|
FFName:=FPath+FFName;
|
|||
|
|
if FileExists(FFName)=false then
|
|||
|
|
begin
|
|||
|
|
IdFTP1.Get('GD\'+Trim(CDS_SC.fieldbyname('FileName').AsString),
|
|||
|
|
FPath+Trim(CDS_SC.fieldbyname('FileName').AsString)
|
|||
|
|
);
|
|||
|
|
end;
|
|||
|
|
if IdFTP1.Connected then IdFTP1.Quit;
|
|||
|
|
ShellExecute(Handle, 'open',PChar(FPath+Trim(CDS_SC.fieldbyname('FileName').AsString)),'', '', SW_SHOWNORMAL);
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
FFName:=Trim(CDS_SC.fieldbyname('XFID').AsString)+Trim(CDS_SC.fieldbyname('HZStr').AsString);
|
|||
|
|
if FileExists(FPath+FFName)=false then
|
|||
|
|
begin
|
|||
|
|
IdFTP1.Get('GD\'+FFName,FPath+FFName);
|
|||
|
|
end;
|
|||
|
|
if IdFTP1.Connected then IdFTP1.Quit;
|
|||
|
|
if FileExists(FPath+FFName) then
|
|||
|
|
begin
|
|||
|
|
ShellExecute(Handle, 'open',PChar(FPath+FFName),'', '', SW_SHOWNORMAL);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.ToolButton2Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.ToolButton3Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SDofilter(ADOQueryFile,SGetFilters(Panel1,1,2));
|
|||
|
|
SCreateCDS20(ADOQueryFile,CDS_SC);
|
|||
|
|
SInitCDSData20(ADOQueryFile,CDS_SC);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.FileNameChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
toolButton3.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.Image1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Panel4.Visible:=False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmFileUp_GRWJ.TSureClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
i,j: Integer;
|
|||
|
|
PatFile,HZStr: String;
|
|||
|
|
FTPPath,FConNo,MaxNo:string;
|
|||
|
|
begin
|
|||
|
|
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;
|
|||
|
|
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 GetLSNo(ADOQueryCmd,MaxNo,'GD','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('\GD')+'\'+Trim(MaxNo)+'.'+Trim(HZStr));
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
SQL.Add('select * from XD_File where 1=2');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('XFID').Value:=Trim(MaxNo);
|
|||
|
|
FieldByName('CYID').Value:='<27><><EFBFBD>˹鵵';
|
|||
|
|
FieldByName('CYNO').Value:=Trim(FDPName);
|
|||
|
|
FieldByName('filename').Value:=Trim(PatFile);
|
|||
|
|
FieldByName('FileDate').Value:=fileDate.DateTime;
|
|||
|
|
FieldByName('Filltime').Value:=SGetServerDate(ADOQueryTemp);
|
|||
|
|
fieldbyname('FileType').value:=Trim('GD');
|
|||
|
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
|
FieldByName('YWYName').Value:=Trim(FYWYName.Text);
|
|||
|
|
FieldByName('HZStr').Value:='.'+Trim(HZStr);
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
except
|
|||
|
|
//ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
//Application.MessageBox('ͼƬ<CDBC>ϴ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
if IdFTP1.Connected then IdFTP1.Quit;
|
|||
|
|
Panel16.Visible:=False;
|
|||
|
|
Panel4.Visible:=False;
|
|||
|
|
InitGrid();
|
|||
|
|
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 TfrmFileUp_GRWJ.FYWYNameBtnClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmZDYHelp:=TfrmZDYHelp.Create(self);
|
|||
|
|
with frmZDYHelp do
|
|||
|
|
begin
|
|||
|
|
flag:='FYWYName';
|
|||
|
|
flagname:='ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>';
|
|||
|
|
if showModal=1 then
|
|||
|
|
begin
|
|||
|
|
FYWYName.Text:=trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
|||
|
|
end;
|
|||
|
|
free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|