unit U_SLTGDTP;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, jpeg, cxControls, cxContainer, cxEdit, cxImage, IdFTP,
  ShellAPI, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters, 
   UrlMon, Data.DB, Data.Win.ADODB, dxSkinWXI;

type
  TfrmSLTGDTP = class(TFrame)
    cxImage1: TcxImage;
    Panel1: TPanel;
    ADO_Temp: TADOQuery;
    procedure cxImage1Click(Sender: TObject);
    procedure cxImage1DblClick(Sender: TObject);
  private
    CYID, FileName, Furl, FDHID: string;
  //   procedure Sharpen(SrcBmp:TBitmap);
    { Private declarations }
  public
    procedure Init(fCYID: string; fFileName: string; fPicture: TJpegImage; Murl: string; MDHID: string);
    { Public declarations }
  end;

implementation

uses
  U_DataLink;
{$R *.dfm}

procedure TfrmSLTGDTP.Init(fCYID: string; fFileName: string; fPicture: TJpegImage; Murl: string; MDHID: string);
begin
  Furl := trim(Murl);
  FDHID := trim(MDHID);
  CYID := trim(fCYID);
  FileName := trim(fFileName);
  Panel1.Caption := FileName;
  cxImage1.Picture.Assign(fPicture);
end;

procedure TfrmSLTGDTP.cxImage1Click(Sender: TObject);
begin
 // Fsplcode:=splcode;
 // FPatFile:=patfile;
///  frmSample_List.Fsplcode:=splcode;
///  frmSample_List.FPatFile:=patfile;
//  showmessage(splcode);
end;

procedure TfrmSLTGDTP.cxImage1DblClick(Sender: TObject);
var
  IdFTP1: TIdFTP;
  FPath, FFName, fPdfFilePath, fPdfFilePath1: string;
  FInt: integer;
begin

 { if Furl <> '' then
  begin
    fPdfFilePath1 := 'D:\Right1209';
    if not DirectoryExists(pchar(fPdfFilePath1)) then
      CreateDirectory(pchar(fPdfFilePath1), nil);
    fPdfFilePath1 := fPdfFilePath1 + '\' + trim(FileName);
    UrlDownloadToFile(nil, PChar(Furl), PChar(fPdfFilePath1), 0, nil);
    ShellExecute(Handle, 'open', PChar(fPdfFilePath1), '', '', SW_SHOWNORMAL);
  end
  else
    MessageBox(Handle, '没有上传图片', '提示', MB_HELP);       }
  if not DirectoryExists(pchar('D:\Right1209')) then
    CreateDirectory(pchar('D:\Right1209'), nil);

  fPdfFilePath := 'D:\Right1209\' + FDHID;
  if not DirectoryExists(pchar(fPdfFilePath)) then
    CreateDirectory(pchar(fPdfFilePath), nil);
  with ADO_Temp do
  begin
    close;
    sql.Clear;
    sql.Add('select * from TP_File A');
    sql.Add('where isnull(WBID,'''')<>'''' and WBID=' + quotedstr(Trim(FDHID)));
    open;
  end;
  ADO_Temp.First;
  while not ADO_Temp.Eof do
  begin
    if Trim(ADO_Temp.FieldByName('URL').AsString) <> '' then
    begin

      fPdfFilePath1 := fPdfFilePath + '\' + trim(Trim(ADO_Temp.FieldByName('FileName').AsString));
      UrlDownloadToFile(nil, PChar(Trim(ADO_Temp.FieldByName('URL').AsString)), PChar(fPdfFilePath1), 0, nil);

    end;
    ADO_Temp.Next;
  end;
  ShellExecute(Handle, 'open', PChar(fPdfFilePath + '\' + trim(FileName)), '', '', SW_SHOWNORMAL);
end;

end.

