378 lines
9.3 KiB
ObjectPascal
378 lines
9.3 KiB
ObjectPascal
unit U_SLT_BF1;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ExtCtrls,jpeg, cxControls, cxContainer, cxEdit, cxImage,IdFTP,ShellAPI,
|
||
StdCtrls, DB, ADODB, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, Menus,DBClient,IniFiles, cxTextEdit, cxCurrencyEdit;
|
||
|
||
type
|
||
TfrmSLT_BF1 = class(TFrame)
|
||
ADOQuery1: TADOQuery;
|
||
ADOQuery2: TADOQuery;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
ODPat: TOpenDialog;
|
||
IdFTP1: TIdFTP;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQuery3: TADOQuery;
|
||
ADOQuery4: TADOQuery;
|
||
SaveDialog1: TSaveDialog;
|
||
Image2: TImage;
|
||
Panel3: TPanel;
|
||
Panel4: TPanel;
|
||
Panel5: TPanel;
|
||
Panel6: TPanel;
|
||
N2: TMenuItem;
|
||
N3: TMenuItem;
|
||
Panel7: TPanel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
procedure cxImage1DblClick(Sender: TObject);
|
||
procedure cxImage1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure N3Click(Sender: TObject);
|
||
procedure Panel7MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
private
|
||
CYID,FileName:string;
|
||
lstPat: TStringList;
|
||
AJpeg: TJPEGImage;
|
||
procedure CreThumb(AJPeg:TJPEGImage;Image1:TImage;Width, Height: Integer);
|
||
procedure ReadINIFile10();
|
||
procedure SaveImageOther();
|
||
// procedure Sharpen(SrcBmp:TBitmap);
|
||
{ Private declarations }
|
||
public
|
||
SKID,FXFID:string;
|
||
Formid:string;
|
||
procedure Init(fCYID:string;fFileName:string;fPicture:TJpegImage);
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_BPZdy_LRSHK,U_MLManage_LRRS,U_BPZdy_Panel;
|
||
{$R *.dfm}
|
||
|
||
|
||
procedure TfrmSLT_BF1.Init(fCYID:string;fFileName:string;fPicture:TJpegImage);
|
||
begin
|
||
CYID:=trim(fCYID);
|
||
FileName:=trim(fFileName);
|
||
lstPat := TStringList.Create;
|
||
//Panel1.Caption:=FileName;
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.cxImage1DblClick(Sender: TObject);
|
||
var
|
||
IdFTP1: TIdFTP;
|
||
FPath,FFName:string;
|
||
FInt:integer;
|
||
maxno:string;
|
||
j,i:Integer;
|
||
begin
|
||
if Formid='1' then
|
||
begin
|
||
self.Visible:=false;
|
||
if TScrollBox(Self.Parent).ParentCtl3D then
|
||
begin
|
||
frmMLManage_LRRS.imagePL(1);
|
||
end else
|
||
begin
|
||
frmMLManage_LRRS.imagePL(2);
|
||
end;
|
||
|
||
end;
|
||
if Formid='' then
|
||
begin
|
||
try
|
||
IdFTP1:=TIdFTP.Create(self);
|
||
IdFTP1.Host :=PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
IdFTP1.Quit;
|
||
IdFTP1.Free;
|
||
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));
|
||
FFName:=Trim(FileName);
|
||
FFName:=FPath+FFName;
|
||
if DirectoryExists(ExtractFileDir(FFName)) then
|
||
DeleteFile(FFName);
|
||
if FileExists(FFName) then
|
||
begin
|
||
FInt:=1;
|
||
end;
|
||
if FInt<>1 then
|
||
IdFTP1.Get('YP\'+FileName,FFName);
|
||
if IdFTP1.Connected then
|
||
begin
|
||
IdFTP1.Quit;
|
||
IdFTP1.Free;
|
||
end;
|
||
ShellExecute(Handle, 'open',PChar(FFName),'', '', SW_SHOWNORMAL);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.cxImage1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
// IF Button= mbRight then exit;
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.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 TfrmSLT_BF1.SaveImageOther();
|
||
var
|
||
AJpeg: TJPEGImage;
|
||
myStream: TADOBlobStream;
|
||
ImgMaxNo:String;
|
||
i,j: Integer;
|
||
PatFile: String;
|
||
FTPPath,FConNo,FTFID:string;
|
||
begin
|
||
if Image2.Picture=nil then Exit;
|
||
AJpeg:=TJpegImage.Create();
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File where TFID='''+Trim(self.Name)+'''');
|
||
open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTemp);
|
||
AJpeg.Assign(Image2.Picture.Graphic);
|
||
//CreThumb(AJpeg,Image1,160, 120);
|
||
myStream := TADOBlobStream.Create(TBlobField(ADOQueryCmd.FieldByName('FilesOther')), bmWrite);
|
||
AJpeg.Assign(Image2.Picture.Graphic);
|
||
AJpeg.SaveToStream(myStream);
|
||
myStream.Free;
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.CreThumb(AJPeg:TJPEGImage;Image1:TImage;Width, Height: Integer);
|
||
var
|
||
Bitmap: TBitmap;
|
||
Ratio: Double;
|
||
ARect: TRect;
|
||
AHeight, AHeightOffset: Integer;
|
||
AWidth, AWidthOffset: Integer;
|
||
begin
|
||
Bitmap := TBitmap.Create;
|
||
try
|
||
Ratio := AJPeg.Width /AJPeg.Height;
|
||
if Ratio > 1.333 then
|
||
begin
|
||
AHeight := Round(Width / Ratio);
|
||
AHeightOffset := (Height - AHeight) div 2;
|
||
AWidth := Width;
|
||
AWidthOffset := 0;
|
||
end
|
||
else
|
||
begin
|
||
AWidth := Round(Height * Ratio);
|
||
AWidthOffset := (Width - AWidth) div 2;
|
||
AHeight := Height;
|
||
AHeightOffset := 0;
|
||
end;
|
||
Bitmap.Width := Width;
|
||
Bitmap.Height := Height;
|
||
Bitmap.Canvas.Brush.Color := clBtnFace;
|
||
Bitmap.Canvas.FillRect(Rect(0, 0, Width, Height));
|
||
ARect := Rect(AWidthOffset, AHeightOffset, AWidth + AWidthOffset, AHeight + AHeightOffset);
|
||
Bitmap.Canvas.StretchDraw(ARect, AJPeg);
|
||
Image1.Picture.Assign(BitMap);
|
||
finally
|
||
Bitmap.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.N1Click(Sender: TObject);
|
||
var
|
||
i,j: Integer;
|
||
PatFile: String;
|
||
FTPPath,FConNo,MaxNo:string;
|
||
AJpeg: TJPEGImage;
|
||
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;
|
||
AJpeg:=TJpegImage.Create();
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select filename from XD_File where XFID='''+Trim(self.Name)+''' ');
|
||
SQL.Add('and filetype=''YP''');
|
||
//ShowMessage(sql.Text);
|
||
Open;
|
||
end;
|
||
Image2.Picture.LoadFromFile(ODPat.FileName);
|
||
AJpeg.Assign(Image2.Picture.Graphic);
|
||
CreThumb(AJpeg,Image2,216, 187);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
for i := 0 to lstPat.Count - 1 do
|
||
begin
|
||
PatFile := ExtractFileName(lstPat[i]);
|
||
PatFile:=ADOQueryTemp.fieldbyname('Filename').AsString;
|
||
//ShowMessage(PatFile);
|
||
if IdFTP1.Connected then
|
||
begin
|
||
IdFTP1.Put(lstPat[i], 'YP'+'\'+Trim(PatFile));
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from XD_File where XFID='''+Trim(self.Name)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
edit;
|
||
FieldByName('filename').Value:=Trim(PatFile);
|
||
FieldByName('FileDate').Value:=SGetServerDate(ADOQueryTemp);
|
||
fieldbyname('FileType').value:=Trim('YP');
|
||
Post;
|
||
end;
|
||
end;
|
||
end;
|
||
SaveImageOther();
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ͼƬ<CDBC>ϴ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
if i>0 then
|
||
//Application.MessageBox(PChar(inttostr(i)+'<27><><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4>ɹ<EFBFBD><C9B9><EFBFBD>'),'<27><>ʾ',0);
|
||
//frmBPZDY_LRSHK.initimageSH();
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.N2Click(Sender: TObject);
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add(' Delete XD_File where XFID='''+Trim(self.Name)+'''');
|
||
SQL.Add(' Delete TP_File where TFID='''+Trim(self.Name)+''' ');
|
||
ExecSQL;
|
||
end;
|
||
// frmBPZDY_LRSHK.initimageSH();
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.N3Click(Sender: TObject);
|
||
var
|
||
IdFTP1: TIdFTP;
|
||
FPath,FFName:string;
|
||
FInt:integer;
|
||
begin
|
||
try
|
||
IdFTP1:=TIdFTP.Create(self);
|
||
IdFTP1.Host :=PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
IdFTP1.Quit;
|
||
IdFTP1.Free;
|
||
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));
|
||
FFName:=Trim(FileName);
|
||
FFName:=FPath+FFName;
|
||
if DirectoryExists(ExtractFileDir(FFName)) then
|
||
DeleteFile(FFName);
|
||
if FileExists(FFName) then
|
||
begin
|
||
FInt:=1;
|
||
end;
|
||
if FInt<>1 then
|
||
IdFTP1.Get('YP\'+FileName,FFName);
|
||
if IdFTP1.Connected then
|
||
begin
|
||
IdFTP1.Quit;
|
||
IdFTP1.Free;
|
||
end;
|
||
ShellExecute(Handle, 'open',PChar(FFName),'', '', SW_SHOWNORMAL);
|
||
end;
|
||
|
||
procedure TfrmSLT_BF1.Panel7MouseDown(Sender: TObject;
|
||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
if label1.Visible=False then
|
||
begin
|
||
label1.Visible:=true;
|
||
end
|
||
else
|
||
begin
|
||
label1.Visible:=false;
|
||
end;
|
||
if label2.Visible=False then
|
||
begin
|
||
label2.Visible:=true;
|
||
end
|
||
else
|
||
begin
|
||
label2.Visible:=false;
|
||
end;
|
||
if label3.Visible=False then
|
||
begin
|
||
label3.Visible:=true;
|
||
end
|
||
else
|
||
begin
|
||
label3.Visible:=false;
|
||
end;
|
||
end;
|
||
|
||
end.
|