405 lines
10 KiB
ObjectPascal
405 lines
10 KiB
ObjectPascal
unit U_FjList_BG;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ExtCtrls, ComCtrls, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons,
|
||
DB, ADODB, ImgList, shellapi, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, cxDBData, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
||
cxGrid, cxLookAndFeels, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
|
||
dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
|
||
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
|
||
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
|
||
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
|
||
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
|
||
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
|
||
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
|
||
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
|
||
dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
|
||
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
|
||
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters,
|
||
dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue,
|
||
dxSkinscxPCPainter, cxNavigator;
|
||
|
||
type
|
||
TfrmFjList_BG = class(TForm)
|
||
ListView1: TListView;
|
||
Panel1: TPanel;
|
||
FileName: TcxButton;
|
||
cxButton1: TcxButton;
|
||
cxButton2: TcxButton;
|
||
cxButton3: TcxButton;
|
||
ADOQueryTmp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ImageList1: TImageList;
|
||
Panel2: TPanel;
|
||
IdFTP1: TIdFTP;
|
||
ADOConnection1: TADOConnection;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxGrid1: TcxGrid;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
DataSource1: TDataSource;
|
||
v1Column4: TcxGridDBColumn;
|
||
procedure cxButton3Click(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FileNameClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ListView1DblClick(Sender: TObject);
|
||
procedure cxButton1Click(Sender: TObject);
|
||
procedure cxButton2Click(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure Panel2DblClick(Sender: TObject);
|
||
procedure Tv1DblClick(Sender: TObject);
|
||
private
|
||
procedure InitData();
|
||
{ Private declarations }
|
||
public
|
||
fkeyNO: string;
|
||
fType: string;
|
||
fId: integer;
|
||
fstatus: integer;
|
||
// fmanage:string;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmFjList_BG: TfrmFjList_BG;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun10, U_CompressionFun; //
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmFjList_BG.InitData();
|
||
var
|
||
ListItem: TListItem;
|
||
Flag: Cardinal;
|
||
info: SHFILEINFOA;
|
||
Icon: TIcon;
|
||
begin
|
||
ListView1.Items.Clear;
|
||
try
|
||
|
||
with adoqueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File ');
|
||
sql.Add('where WBID=' + quotedstr(trim(fkeyNO)));
|
||
sql.Add('and TFType=' + quotedstr(trim(fType)));
|
||
open;
|
||
end;
|
||
except
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.cxButton3Click(Sender: TObject);
|
||
begin
|
||
ADOQueryTmp.Close;
|
||
ADOQuerycmd.Close;
|
||
ListView1.Items.Free;
|
||
ModalResult := -1;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmFjList_BG := nil;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.FileNameClick(Sender: TObject);
|
||
var
|
||
OpenDiaLog: TOpenDialog;
|
||
fFileName: string;
|
||
fFilePath: string;
|
||
maxNo: string;
|
||
// myStream: TADOBlobStream;
|
||
FJStream: TMemoryStream;
|
||
mfileSize: integer;
|
||
mCreationTime: TdateTime;
|
||
mWriteTime: TdateTime;
|
||
begin
|
||
|
||
try
|
||
adoqueryCmd.Connection.BeginTrans;
|
||
OpenDiaLog := TOpenDialog.Create(Self);
|
||
if OpenDiaLog.Execute then
|
||
begin
|
||
fFilePath := OpenDiaLog.FileName;
|
||
fFileName := ExtractFileName(OpenDiaLog.FileName);
|
||
Panel2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
|
||
Panel2.Visible := true;
|
||
application.ProcessMessages;
|
||
|
||
if GetLSNo(ADOQueryCmd, maxNo, 'FJ', 'TP_File', 4, 1) = False then
|
||
begin
|
||
adoqueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
|
||
GetFileInfo(fFilePath, mfileSize, mCreationTime, mWriteTime);
|
||
with adoqueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from TP_File ');
|
||
sql.Add('where TFID=' + quotedstr(trim(maxNo)));
|
||
execsql;
|
||
end;
|
||
try
|
||
FJStream := TMemoryStream.Create;
|
||
with adoqueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File ');
|
||
sql.Add('where TFID=' + quotedstr(trim(maxNo)));
|
||
// sql.Add('where WBID='+quotedstr(trim(fkeyNO)));
|
||
// sql.Add('and TFType='+quotedstr(trim(fType)));
|
||
// sql.Add('and FileName='+quotedstr(trim(fFileName)));
|
||
open;
|
||
append;
|
||
fieldbyname('TFID').Value := trim(maxNo);
|
||
// fieldbyname('WBID').Value:=trim(fkeyNO);
|
||
fieldbyname('WBID').Value := trim(fFileName);
|
||
fieldbyname('TFType').Value := trim(fType);
|
||
fieldbyname('Filler').Value := trim(DName);
|
||
fieldbyname('FileName').Value := trim(fFileName);
|
||
fieldbyname('TFDate').Value := mWriteTime;
|
||
FJStream.LoadFromFile(fFilePath);
|
||
// CompressionStream(FJStream);
|
||
tblobfield(FieldByName('Filesother')).LoadFromStream(FJStream);
|
||
post;
|
||
end;
|
||
Panel2.Visible := false;
|
||
initdata();
|
||
finally
|
||
FJStream.Free;
|
||
end;
|
||
|
||
end;
|
||
adoqueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
except
|
||
adoqueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.FormCreate(Sender: TObject);
|
||
begin
|
||
with ADOConnection1 do
|
||
begin
|
||
Connected := false;
|
||
ConnectionString := DConString;
|
||
//ConnectionString:='';
|
||
Connected := true;
|
||
end;
|
||
cxGrid1.Align := alclient;
|
||
fstatus := 0;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.FormShow(Sender: TObject);
|
||
begin
|
||
if fstatus = 0 then
|
||
Panel1.Visible := true
|
||
else
|
||
Panel1.Visible := false;
|
||
initdata();
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.ListView1DblClick(Sender: TObject);
|
||
var
|
||
sFieldName: string;
|
||
fileName: string;
|
||
begin
|
||
if ListView1.Items.Count < 1 then
|
||
EXIT;
|
||
|
||
if listView1.SelCount < 1 then
|
||
exit;
|
||
sFieldName := 'D:\ͼƬ<CDBC>鿴';
|
||
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName), nil);
|
||
|
||
fileName := ListView1.Selected.Caption;
|
||
|
||
sFieldName := sFieldName + '\' + trim(fileName);
|
||
|
||
try
|
||
IdFTP1.Host := PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
;
|
||
end;
|
||
|
||
if IdFTP1.Connected then
|
||
begin
|
||
|
||
Panel2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
|
||
Panel2.Visible := true;
|
||
application.ProcessMessages;
|
||
try
|
||
IdFTP1.Get('FJ\' + Trim(fileName), sFieldName, false, true);
|
||
except
|
||
Panel2.Visible := false;
|
||
Application.MessageBox('<27>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Panel2.Visible := false;
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
Panel2.Visible := false;
|
||
if IdFTP1.Connected then
|
||
IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL);
|
||
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.cxButton1Click(Sender: TObject);
|
||
var
|
||
fFileName: string;
|
||
fFilePath: string;
|
||
begin
|
||
// if listView1.SelCount<1 then exit;
|
||
|
||
if ADOQueryTmp.IsEmpty then
|
||
exit;
|
||
|
||
try
|
||
// fFileName:=ListView1.Selected.Caption;
|
||
// ADOQueryTmp.Locate('fileName',fFileName,[]);
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from TP_File ');
|
||
sql.Add('where TFID=' + quotedstr(trim(ADOQueryTmp.fieldbyname('TFID').AsString)));
|
||
// sql.Add('and TFType='+quotedstr(trim(fType)));
|
||
// sql.Add('and FileName='+quotedstr(trim(fFileName)));
|
||
execsql;
|
||
end;
|
||
|
||
initData();
|
||
|
||
except
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.cxButton2Click(Sender: TObject);
|
||
var
|
||
SaveDialog: TSaveDialog;
|
||
fFileName: string;
|
||
fFilePath: string;
|
||
ff: TADOBlobStream;
|
||
FJStream: TMemoryStream;
|
||
begin
|
||
if adoqueryTmp.IsEmpty then
|
||
exit;
|
||
|
||
try
|
||
|
||
fFileName := adoqueryTmp.fieldbyname('FileName').AsString;
|
||
|
||
SaveDialog := TSaveDialog.Create(Self);
|
||
|
||
SaveDialog.FileName := fFileName;
|
||
if SaveDialog.Execute then
|
||
begin
|
||
Panel2.Caption := '<27><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
|
||
Panel2.Visible := true;
|
||
application.ProcessMessages;
|
||
fFilePath := SaveDialog.FileName;
|
||
|
||
try
|
||
ff := TADOBlobstream.Create(adoqueryTmp.fieldByName('FilesOther') as TblobField, bmRead);
|
||
|
||
FJStream := TMemoryStream.Create;
|
||
ff.SaveToStream(FJStream);
|
||
UnCompressionStream(FJStream);
|
||
FJStream.SaveToFile(fFilePath);
|
||
// ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL);
|
||
finally
|
||
FJStream.free;
|
||
ff.Free;
|
||
end;
|
||
|
||
Panel2.Visible := false;
|
||
// if IdFTP1.Connected then IdFTP1.Quit;
|
||
end;
|
||
except
|
||
Panel2.Visible := false;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
if fId = 10 then
|
||
Action := cafree
|
||
else
|
||
Action := cahide;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.Panel2DblClick(Sender: TObject);
|
||
begin
|
||
Panel2.Visible := false;
|
||
end;
|
||
|
||
procedure TfrmFjList_BG.Tv1DblClick(Sender: TObject);
|
||
var
|
||
sFieldName: string;
|
||
fileName: string;
|
||
ff: TADOBlobStream;
|
||
FJStream: TMemoryStream;
|
||
begin
|
||
|
||
if adoqueryTmp.IsEmpty then
|
||
exit;
|
||
|
||
sFieldName := 'D:\ͼƬ<CDBC>鿴';
|
||
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName), nil);
|
||
|
||
fileName := adoqueryTmp.fieldbyname('FileName').AsString;
|
||
|
||
sFieldName := sFieldName + '\' + trim(fileName);
|
||
|
||
try
|
||
ff := TADOBlobstream.Create(adoqueryTmp.fieldByName('FilesOther') as TblobField, bmRead);
|
||
|
||
FJStream := TMemoryStream.Create;
|
||
ff.SaveToStream(FJStream);
|
||
UnCompressionStream(FJStream);
|
||
FJStream.SaveToFile(sFieldName);
|
||
ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL);
|
||
finally
|
||
FJStream.free;
|
||
ff.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|
||
|