D7szYidui/Z99Dependency/ThreeFun/Form/U_FjList10.pas

446 lines
11 KiB
ObjectPascal
Raw Normal View History

2025-07-19 14:23:30 +08:00
unit U_FjList10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
2025-10-18 14:10:28 +08:00
Dialogs, ExtCtrls, ComCtrls, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons,
DB, ADODB, ImgList, shellapi, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, strutils;
2025-07-19 14:23:30 +08:00
type
TfrmFjList10 = 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;
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);
private
procedure InitData();
{ Private declarations }
public
2025-10-18 14:10:28 +08:00
fkeyNO: string;
fType: string;
fId: integer;
fstatus: integer;
2025-07-19 14:23:30 +08:00
{ Public declarations }
end;
var
2025-10-18 14:10:28 +08:00
frmFjList10: TfrmFjList10;
2025-07-19 14:23:30 +08:00
implementation
2025-10-18 14:10:28 +08:00
uses
U_DataLink, U_Fun10, U_CompressionFun;
2025-07-19 14:23:30 +08:00
{$R *.dfm}
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
procedure TfrmFjList10.InitData();
var
2025-10-18 14:10:28 +08:00
ListItem: TListItem;
Flag: Cardinal;
info: SHFILEINFOA;
Icon: TIcon;
2025-07-19 14:23:30 +08:00
begin
ListView1.Items.Clear;
try
2025-10-18 14:10:28 +08:00
with adoqueryTmp do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
close;
sql.Clear;
sql.Add('select * from TP_File ');
sql.Add('where WBID=' + quotedstr(trim(fkeyNO)));
sql.Add('and TFType=' + quotedstr(trim(fType)));
open;
if not IsEmpty then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
while not eof do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with ListView1 do
begin
LargeImages := ImageList1;
Icon := TIcon.Create;
ListItem := Items.Add;
ListItem.Caption := trim(fieldbyname('fileName').AsString);
2025-07-19 14:23:30 +08:00
// Listitem.SubItems.Add(OpenDiaLog.FileName);
2025-10-18 14:10:28 +08:00
Flag := (SHGFI_SMALLICON or SHGFI_ICON or SHGFI_USEFILEATTRIBUTES);
SHGetFileInfo(Pchar(trim(fieldbyname('fileName').AsString)), 0, info, Sizeof(info), Flag);
Icon.Handle := info.hIcon;
ImageList1.AddIcon(Icon);
ListItem.ImageIndex := ImageList1.Count - 1;
end;
next;
2025-07-19 14:23:30 +08:00
end;
end;
end;
except
end;
end;
procedure TfrmFjList10.cxButton3Click(Sender: TObject);
begin
ADOQueryTmp.Close;
ADOQuerycmd.Close;
ListView1.Items.Free;
2025-10-18 14:10:28 +08:00
ModalResult := -1;
2025-07-19 14:23:30 +08:00
end;
procedure TfrmFjList10.FormDestroy(Sender: TObject);
begin
2025-10-18 14:10:28 +08:00
frmFjList10 := nil;
2025-07-19 14:23:30 +08:00
end;
procedure TfrmFjList10.FileNameClick(Sender: TObject);
var
OpenDiaLog: TOpenDialog;
2025-10-18 14:10:28 +08:00
fFileName: string;
fFilePath: string;
maxNo: string;
2025-07-19 14:23:30 +08:00
// myStream: TADOBlobStream;
// FJStream : TMemoryStream;
2025-10-18 14:10:28 +08:00
FJStream: TMemoryStream;
mfileSize: integer;
mCreationTime: TdateTime;
mWriteTime: TdateTime;
2025-07-19 14:23:30 +08:00
begin
try
OpenDiaLog := TOpenDialog.Create(Self);
if OpenDiaLog.Execute then
begin
2025-10-18 14:10:28 +08:00
fFilePath := OpenDiaLog.FileName;
fFileName := ExtractFileName(OpenDiaLog.FileName);
2025-07-19 14:23:30 +08:00
with adoqueryCmd do
begin
close;
sql.Clear;
sql.Add('select TFId from TP_File ');
2025-10-18 14:10:28 +08:00
sql.Add('where WBID<>' + quotedstr(trim(fkeyNO)));
sql.Add('and TFType=' + quotedstr(trim(fType)));
sql.Add('and FileName=' + quotedstr(trim(fFileName)));
2025-07-19 14:23:30 +08:00
open;
2025-10-18 14:10:28 +08:00
if not adoqueryCmd.IsEmpty then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
application.MessageBox('<27>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>޸<EFBFBD><DEB8>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
2025-07-19 14:23:30 +08:00
exit;
end;
end;
2025-10-18 14:10:28 +08:00
Panel2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
Panel2.Visible := true;
2025-07-19 14:23:30 +08:00
application.ProcessMessages;
2025-10-18 14:10:28 +08:00
if GetLSNo(ADOQueryCmd, maxNo, 'FJ', 'TP_File', 4, 1) = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
Exit;
end;
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
2025-10-18 14:10:28 +08:00
GetFileInfo(fFilePath, mfileSize, mCreationTime, mWriteTime);
2025-07-19 14:23:30 +08:00
adoqueryCmd.Connection.BeginTrans;
with adoqueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from TP_File ');
2025-10-18 14:10:28 +08:00
sql.Add('where WBID=' + quotedstr(trim(fkeyNO)));
sql.Add('and TFType=' + quotedstr(trim(fType)));
sql.Add('and FileName=' + quotedstr(trim(fFileName)));
2025-07-19 14:23:30 +08:00
execsql;
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
FJStream := TMemoryStream.Create;
2025-07-19 14:23:30 +08:00
with adoqueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from TP_File ');
2025-10-18 14:10:28 +08:00
sql.Add('where WBID=' + quotedstr(trim(fkeyNO)));
sql.Add('and TFType=' + quotedstr(trim(fType)));
sql.Add('and FileName=' + quotedstr(trim(fFileName)));
2025-07-19 14:23:30 +08:00
open;
append;
2025-10-18 14:10:28 +08:00
fieldbyname('TFID').Value := trim(maxNo);
fieldbyname('WBID').Value := trim(fkeyNO);
fieldbyname('TFType').Value := trim(fType);
fieldbyname('FileName').Value := trim(fFileName);
2025-07-19 14:23:30 +08:00
FJStream.LoadFromFile(fFilePath);
CompressionStream(FJStream);
tblobfield(FieldByName('Filesother')).LoadFromStream(FJStream);
// tblobfield(FieldByName('Filesother')).LoadFromFile(fFilePath);
post;
end;
{ if fFilePath <> '' then
begin
try
IdFTP1.Host := PicSvr;
IdFTP1.Username := 'three';
IdFTP1.Password := '641010';
IdFTP1.Connect();
IdFTP1.Put(fFilePath, 'FJ\' + Trim(fFileName));
IdFTP1.Quit;
except
IdFTP1.Quit;
Application.MessageBox('<27>ϴ<EFBFBD><CFB4>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
end;
end;
IdFTP1.Quit; }
2025-10-18 14:10:28 +08:00
Panel2.Visible := false;
2025-07-19 14:23:30 +08:00
initdata();
finally
// FJStream.Free;
end;
adoqueryCmd.Connection.CommitTrans;
end;
except
adoqueryCmd.Connection.RollbackTrans;
2025-10-18 14:10:28 +08:00
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
procedure TfrmFjList10.FormCreate(Sender: TObject);
begin
2025-10-18 14:10:28 +08:00
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
2025-07-19 14:23:30 +08:00
//ConnectionString:='';
2025-10-18 14:10:28 +08:00
Connected := true;
end;
ListView1.Align := alclient;
fstatus := 0;
2025-07-19 14:23:30 +08:00
end;
procedure TfrmFjList10.FormShow(Sender: TObject);
begin
2025-10-18 14:10:28 +08:00
if fstatus = 0 then
Panel1.Visible := true
else
Panel1.Visible := false;
2025-07-19 14:23:30 +08:00
initdata();
end;
procedure TfrmFjList10.ListView1DblClick(Sender: TObject);
var
2025-10-18 14:10:28 +08:00
sFieldName: string;
fileName: string;
ff: TADOBlobStream;
FJStream: TMemoryStream;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if ListView1.Items.Count < 1 then
EXIT;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
if listView1.SelCount < 1 then
exit;
sFieldName := leftbstr(ExtractFilePath(Application.ExeName), 1) + ':\ͼƬ<CDBC>鿴';
2025-07-19 14:23:30 +08:00
if not DirectoryExists(pchar(sFieldName)) then
2025-10-18 14:10:28 +08:00
CreateDirectory(pchar(sFieldName), nil);
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
fileName := ListView1.Selected.Caption;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
sFieldName := sFieldName + '\' + trim(fileName);
2025-07-19 14:23:30 +08:00
{ 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,true, false);
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);
}
try
2025-10-18 14:10:28 +08:00
adoqueryTmp.Locate('FileName', fileName, []);
2025-07-19 14:23:30 +08:00
ff := TADOBlobstream.Create(adoqueryTmp.fieldByName('FilesOther') as TblobField, bmRead);
2025-10-18 14:10:28 +08:00
FJStream := TMemoryStream.Create;
ff.SaveToStream(FJStream);
UnCompressionStream(FJStream);
FJStream.SaveToFile(sFieldName);
ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL);
2025-07-19 14:23:30 +08:00
finally
2025-10-18 14:10:28 +08:00
FJStream.free;
2025-07-19 14:23:30 +08:00
ff.Free;
end;
end;
procedure TfrmFjList10.cxButton1Click(Sender: TObject);
var
2025-10-18 14:10:28 +08:00
fFileName: string;
fFilePath: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if listView1.SelCount < 1 then
exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
fFileName := ListView1.Selected.Caption;
2025-07-19 14:23:30 +08:00
// ADOQueryTmp.Locate('fileName',fFileName,[]);
2025-10-18 14:10:28 +08:00
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from TP_File ');
sql.Add('where WBID=' + quotedstr(trim(fkeyNO)));
sql.Add('and TFType=' + quotedstr(trim(fType)));
sql.Add('and FileName=' + quotedstr(trim(fFileName)));
execsql;
end;
2025-07-19 14:23:30 +08:00
initData();
except
end;
end;
procedure TfrmFjList10.cxButton2Click(Sender: TObject);
var
SaveDialog: TSaveDialog;
2025-10-18 14:10:28 +08:00
fFileName: string;
fFilePath: string;
ff: TADOBlobStream;
FJStream: TMemoryStream;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if listView1.SelCount < 1 then
exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
fFileName := ListView1.Selected.Caption;
adoqueryTmp.Locate('FileName', fFileName, []);
2025-07-19 14:23:30 +08:00
SaveDialog := TSaveDialog.Create(Self);
2025-10-18 14:10:28 +08:00
SaveDialog.FileName := fFileName;
2025-07-19 14:23:30 +08:00
if SaveDialog.Execute then
begin
2025-10-18 14:10:28 +08:00
Panel2.Caption := '<27><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
Panel2.Visible := true;
2025-07-19 14:23:30 +08:00
application.ProcessMessages;
2025-10-18 14:10:28 +08:00
fFilePath := SaveDialog.FileName;
try
ff := TADOBlobstream.Create(adoqueryTmp.fieldByName('FilesOther') as TblobField, bmRead);
FJStream := TMemoryStream.Create;
ff.SaveToStream(FJStream);
UnCompressionStream(FJStream);
FJStream.SaveToFile(fFilePath);
2025-07-19 14:23:30 +08:00
// ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL);
finally
2025-10-18 14:10:28 +08:00
FJStream.free;
ff.Free;
Panel2.Visible := false;
2025-07-19 14:23:30 +08:00
end;
end;
{ 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(fFileName), fFilePath,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;
end; }
except
2025-10-18 14:10:28 +08:00
Panel2.Visible := false;
2025-07-19 14:23:30 +08:00
end;
end;
procedure TfrmFjList10.FormClose(Sender: TObject; var Action: TCloseAction);
begin
2025-10-18 14:10:28 +08:00
if fId = 10 then
Action := cafree
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
Action := cahide;
2025-07-19 14:23:30 +08:00
end;
procedure TfrmFjList10.Panel2DblClick(Sender: TObject);
begin
2025-10-18 14:10:28 +08:00
Panel2.Visible := false;
2025-07-19 14:23:30 +08:00
end;
end.
2025-10-18 14:10:28 +08:00