unit U_HXKYHK;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList,
  StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu,IniFiles,
  cxButtonEdit, BtnEdit, cxTL, cxMaskEdit, cxInplaceContainer, cxDBTL,U_SLT_YH,
  cxTLData, cxContainer, cxCurrencyEdit, cxCheckBox, cxSplitter,jpeg,Math, Menus, cxCalendar,
  IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP,
  dxDockControl, dxDockPanel;

type
  TfrmHXKYHK = class(TForm)
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    DataSource1: TDataSource;
    Ord_TJ: TClientDataSet;
    ADOConnection1: TADOConnection;
    ThreeImgList: TImageList;
    DataSource2: TDataSource;
    Panel2: TPanel;
    DataSource4: TDataSource;
    ADOQueryTree: TADOQuery;
    Order_Tree: TClientDataSet;
    cxGridPopupMenu1: TcxGridPopupMenu;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyleRepository2: TcxStyleRepository;
    cxStyle2: TcxStyle;
    ToolBar2: TToolBar;                                           
    TSH: TToolButton;
    adoqueryPicture: TADOQuery;
    ScrollBox2: TScrollBox;
    ADOQuery1: TADOQuery;
    SaveDialog2: TSaveDialog;
    ODPat2: TOpenDialog;
    IdFTP2: TIdFTP;
    Panel1: TPanel;
    Image2: TImage;
    Image1: TImage;
    Panel16: TPanel;
    ScrollBox3: TPanel;
    BTLP: TButton;
    BTNP: TButton;
    LBCPAP: TLabel;
    ToolButton1: TToolButton;
    THXGL: TToolButton;
    Panel5: TPanel;
    Label1: TLabel;
    TJHX: TEdit;
    Label2: TLabel;
    TJMLNo: TEdit;
    Panel3: TPanel;
    TJHXType: TBtnEditA;
    Label3: TLabel;
    ToolButton2: TToolButton;
    Panel4: TPanel;
    cxDBTreeList1: TcxDBTreeList;
    VColumn2: TcxDBTreeListColumn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    Panel6: TPanel;
    TJNote: TMemo;
    Label4: TLabel;
    SMRK: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure TSHClick(Sender: TObject);
    procedure THBClick(Sender: TObject);
    procedure cxDBTreeList1DblClick(Sender: TObject);
    procedure BTLPClick(Sender: TObject);
    procedure BTNPClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure THXGLClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TJHXTypeBtnClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure TJHXTypeChange(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure SMRKKeyPress(Sender: TObject; var Key: Char);
    procedure TJHXKeyPress(Sender: TObject; var Key: Char);
    procedure TJMLNoKeyPress(Sender: TObject; var Key: Char);
    procedure N3Click(Sender: TObject);
  private
    JS:integer;
    FDYID:String;
    lstPat: TStringList;
		AJpeg: TJPEGImage;
    procedure initTree();
    procedure CreThumb(AJPeg:TJPEGImage;Image1:TImage;Width, Height: Integer);
    procedure ReadINIFile10();
    { Private declarations }
  public
    my,mz:integer;
    FIMID:string;
    procedure initimageSH(FWBID:String);
    { Public declarations }
  end;
var
  frmHXKYHK: TfrmHXKYHK;
  Mach1: array of TfrmSLT_YH;
implementation
uses
  U_DataLink,U_RTFun, U_BPZdy_HXK,U_CPTypePB,U_FileUp_TP,U_SCPerson
  ,U_FileUp,U_FileUp_PB,U_FileUp_TPSH,U_SLT_BF1,U_HXKTJ_Type,U_ZDYHelp;

{$R *.dfm}
procedure TfrmHXKYHK.initTree();
begin
  with ADOQueryTree do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select *');
    sql.Add(',JS=(select Max(A.CPlevel) from CP_TypeTJ A)');
    sql.Add(', Case when isnull(CPNo,'''')<>'''' and CPlevel=''2'' then RTrim(CPNo)+''/''+CPName else CPName end as CP ');
    SQL.Add('from CP_TypeTJ order by CPlevel,CPOrder,CPName');
    Open;
  end;
  SCreateCDS20(ADOQueryTree,Order_Tree);
  SInitCDSData20(ADOQueryTree,Order_Tree);
  JS:=Order_Tree.fieldbyname('JS').AsInteger;
  cxDBTreeList1.Items[0].Expand(true);
end;

procedure TfrmHXKYHK.initimageSH(FWBID:String);
var
  i,j,p,x:integer;
  jpg:TJpegImage;
  myStream: TADOBlobStream;
  Fstr:string;
begin
  if TJHX.Text<>'' then
  begin
    Fstr:=Fstr+' and TJHX like '''+'%'+Trim(TJHX.Text)+'%'+'''';
  end;
  if TJMLNo.Text<>'' then
  begin
    Fstr:=Fstr+' and TJMLNo like '''+'%'+Trim(TJMLNo.Text)+'%'+'''';
  end;
  if TJHXType.Text<>'' then
  begin
    Fstr:=Fstr+' and TJHXType like '''+'%'+Trim(TJHXType.Text)+'%'+'''';
  end;
  if FDYID<>'' then
  begin
    Fstr:=Fstr+' and IMID like '''+'%'+Trim(FDYID)+'%'+'''';
  end;
  j:=length(Mach1);
  if j>0 then
  begin
    for i:=0 to j-1 do
    begin
      Mach1[i].free;
    end;
  end;
  SetLength(Mach1, 0);
  try
    with adoqueryPicture do
    begin
      close;
      sql.Clear;
      sql.Add(' exec P_View_Image :WBID,:ImageType,:IFType,:Ye,:YeQty,:WPS  ');
      Parameters.ParamByName('WBID').Value:=Trim(FWBID);
      Parameters.ParamByName('ImageType').Value:='YH';
      Parameters.ParamByName('IFType').Value:='小';
      Parameters.ParamByName('Ye').Value:=my;
      Parameters.ParamByName('YeQty').Value:=18;
      Parameters.ParamByName('WPS').Value:=Trim(Fstr);
      open;
    end;
    j:=adoqueryPicture.RecordCount;
    if j<1 then exit;
    adoqueryPicture.DisableControls;
    adoqueryPicture.First;
    SetLength(Mach1, j);
    with adoqueryPicture do
    begin
      First;
      i:=0;
      x:=0;    //列
      p:=0;    //行
      while not eof do
      begin
        if (i<24*my) and (i>=24*(my-1)) then
        begin
          jpg:=TJpegImage.Create();
          myStream:=tadoblobstream.Create(tblobfield(adoqueryPicture.fieldbyname('ImageFile')),bmread);
          jpg.LoadFromStream(myStream);
          if (i-24*(my-1))<8*(p+1) then
          begin

          end
          else
          begin
            p:=p+1;
          end;
          Mach1[i]:=TfrmSLT_YH.Create(Self);
          Mach1[i].Name:=trim(adoqueryPicture.fieldbyname('IMID').AsString);
          Mach1[i].ImagePath.Caption:=trim(adoqueryPicture.fieldbyname('ImagePath').AsString);
          Mach1[i].FImagePath:=trim(adoqueryPicture.fieldbyname('ImagePath').AsString);
          Mach1[i].Parent:=ScrollBox2;
          Mach1[I].Left:=0+(x-8*p)*188;
          Mach1[I].Top:=p*308;
          Mach1[I].FIMID:=trim(adoqueryPicture.fieldbyname('IMID').AsString);
          Mach1[I].FTJHX:=trim(adoqueryPicture.fieldbyname('TJHX').AsString);
          Mach1[I].TJHX.Caption:=trim(adoqueryPicture.fieldbyname('TJHX').AsString);
          Mach1[I].TJHXType.Caption:=trim(adoqueryPicture.fieldbyname('TJHXType').AsString);
          Mach1[I].TJMLNo.Caption:=trim(adoqueryPicture.fieldbyname('TJMLNo').AsString);
          Mach1[I].FIMNO:=trim(adoqueryPicture.fieldbyname('IMNO').AsString);
          Mach1[I].FWBID:=Trim(FWBID);
          if triM(adoqueryPicture.fieldbyname('IMID').AsString)<>'' then
          begin
            Mach1[i].Init(adoqueryPicture.fieldbyname('ImagePath').AsString,jpg);
          end;
          Mach1[i].cxImage1.Visible:=True;
          Mach1[i].cxImage1.Properties.Stretch:=True;
          Mach1[i].Image11.Visible:=False;
          x:=x+1;
        end;
        i:=i+1;
        Next;
      end;
    end;
    adoqueryPicture.EnableControls;
  finally
    jpg.free;
  end;
end;


procedure TfrmHXKYHK.FormCreate(Sender: TObject);
begin
  try
    with ADOConnection1 do
    begin
      Connected:=false;
      ConnectionString:=DConString;
      Connected:=true;
    end;
  except;
    frmHXKYHK.Free;
  end;
  lstPat := TStringList.Create;
end;

procedure TfrmHXKYHK.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Finalize(Mach1);
  Action:=caFree;
end;

procedure TfrmHXKYHK.FormShow(Sender: TObject);
var FLevel:integer;
begin
  initTree();
  TSH.Visible:=false;
  Panel3.Visible:=true;
  Panel3.Refresh;
  cxDBTreeList1.Enabled:=false;
  my:=1;
  if Order_Tree.fieldbyname('CPlevel').AsInteger<>3 then
  begin
    TSH.Visible:=false;
  end
  else
  TSH.Visible:=True;
  initimageSH(Trim(Order_Tree.fieldbyname('CPID').AsString));
  if adoqueryPicture.IsEmpty=False then
  begin
    mz:=Ceil(adoqueryPicture.fieldbyname('GS').AsInteger/24);
  end else
  begin
    mz:=1;
  end;
  LBCPAP.Caption:=IntToStr(my)+'/'+IntToStr(mz);
  cxDBTreeList1.Enabled:=True;
  Panel3.Visible:=false;
end;

procedure TfrmHXKYHK.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
    AWidth :=Width;
    AWidthOffset := 0;
    AHeight := Height;
    AHeightOffset := 0;

    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 TfrmHXKYHK.ReadINIFile10();
var
  programIni:Tinifile;  //配置文件名
  FileName:string;
begin
  FileName:=ExtractFilePath(Paramstr(0))+'SYSTEMSET.INI';
  programIni:=Tinifile.create(FileName);
  server:=programIni.ReadString('SERVER','服务器地址','127.0.0.1');
  programIni.Free;
end;


procedure TfrmHXKYHK.TSHClick(Sender: TObject);
var
  i,j: Integer;
  AJpeg: TJPEGImage;
  myStream: TADOBlobStream;
  maxnoIMID,maxnoIMNO,maxnoIFID,FWBID,ImageName:String;
  imageDate:TDate;
begin
  lstPat.Clear;
  if ODPat2.Execute then
  begin
    lstPat.AddStrings(ODPat2.Files);
  end;
  if lstPat.Count > 0 then
  begin
    try
      if IdFTP2.Connected then
      begin
        IdFTP2.Quit;
      end;
      ReadINIFile10();
      server:=ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
      IdFTP2.Host :=server;
      IdFTP2.Username := 'three';
      IdFTP2.Password := '641010';
      IdFTP2.Connect();
    except
      IdFTP2.Quit;
      Application.MessageBox('无法连接到文件服务器，请检查！', '提示', MB_ICONWARNING);
      Exit;
    end;
  end else
  begin
    Exit;
  end;
  Panel16.Visible:=True;
  Panel16.Refresh;
  FWBID:=Trim(Self.Order_Tree.fieldbyname('CPID').AsString);
  imageDate:=SGetServerDate(ADOQueryTemp);
  try
    ADOQueryCmd.Connection.BeginTrans;
    for i := 0 to lstPat.Count - 1 do
    begin
      ImageName:=ExtractFileName(lstPat[i]);
      if GetLSNoHZ(ADOQueryCmd,maxnoIMID,'TJ','Image_Info',4,1,0)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取图片ID失败!','提示',0);
        Exit;
      end;
      if GetLSNoHZ(ADOQueryCmd,maxnoIMNO,'','Image_InfoTJ',4,0,0)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取图片NO失败!','提示',0);
        Exit;
      end;
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('select * from Image_Info where 1=2');
        Open;
      end;
      with ADOQueryCmd do
      begin
        Append;
        FieldByName('IMID').Value:=Trim(maxnoIMID);
        FieldByName('IMNO').Value:=Trim(maxnoIMNO);
        FieldByName('WBID').Value:=Trim(FWBID);
        FieldByName('CPID').Value:=Trim(FWBID);
        FieldByName('ImageType').Value:='TJ';
        FieldByName('ImageDate').Value:=imageDate;
        FieldByName('ImageName').Value:=Trim(ImageName);
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
        FieldByName('Valid').Value:='Y';
        Post;
      end;
      AJpeg:=TJpegImage.Create();
      AJpeg.LoadFromFile(ExtractFileName(lstPat[i]));
      if AJpeg.Width>450 then
      begin
        CreThumb(AJpeg,Image2,450, 619);
      end;
      if AJpeg.Width>150 then
      begin
        CreThumb(AJpeg,Image1,150, 206);
      end;
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('select * from Image_File where 1=2');
        Open;
      end;
      with ADOQueryCmd do
      begin
        Append;
        FieldByName('IMID').Value:=Trim(maxnoIMID);
        FieldByName('IFID').Value:=Trim(maxnoIMID)+'X';
        FieldByName('CPID').Value:=Trim(FWBID);
        FieldByName('IFType').Value:='小';
        myStream := TADOBlobStream.Create(TBlobField(ADOQueryCmd.FieldByName('ImageFile')), bmWrite);
        AJpeg.Assign(Image1.Picture.Graphic);
        AJpeg.SaveToStream(myStream);
        myStream.Free;
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
        FieldByName('Valid').Value:='Y';
        Post;
      end;
      with ADOQueryCmd do
      begin
        Append;
        FieldByName('IMID').Value:=Trim(maxnoIMID);
        FieldByName('IFID').Value:=Trim(maxnoIMID)+'D';
        FieldByName('IFType').Value:='大';
        FieldByName('CPID').Value:=Trim(FWBID);
        myStream := TADOBlobStream.Create(TBlobField(ADOQueryCmd.FieldByName('ImageFile')), bmWrite);
        AJpeg.Assign(Image2.Picture.Graphic);
        AJpeg.SaveToStream(myStream);
        myStream.Free;
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
        FieldByName('Valid').Value:='Y';
        Post;
      end;
      if IdFTP2.Connected then
        IdFTP2.Put(lstPat[i], 'TJ'+'\'+Trim(ImageName));
    end;
    ADOQueryCmd.Connection.CommitTrans;
  except
    Panel16.Visible:=False;
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('数据上传失败!','提示',0);
    Exit;
  end;
  Panel16.Visible:=False;
  initimageSH(FWBID);
end;

procedure TfrmHXKYHK.THBClick(Sender: TObject);
begin
  InitTree();
end;

procedure TfrmHXKYHK.cxDBTreeList1DblClick(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmHXKYHK.BTLPClick(Sender: TObject);
begin
  if my<=1 then exit;
  my:=my-1;
  LBCPAP.Caption:=IntToStr(my)+'/'+inttostr(mz);
  initimageSH(Order_Tree.fieldbyname('CPID').AsString);
end;

procedure TfrmHXKYHK.BTNPClick(Sender: TObject);
begin
  if my>=mz then exit;
  my:=my+1;
  LBCPAP.Caption:=IntToStr(my)+'/'+inttostr(mz);
  initimageSH(Order_Tree.fieldbyname('CPID').AsString);
end;

procedure TfrmHXKYHK.ToolButton1Click(Sender: TObject);
var
  IdFTP1: TIdFTP;
  SaveDialog: TSaveDialog;
  fFileName,FFName:string;
  fFilePath:string;
  i,j,z,c:Integer;
begin
  SaveDialog := TSaveDialog.Create(Self);
  SaveDialog.FileName:='文件名';
  if SaveDialog.Execute then
  begin
    Panel3.Refresh;
    Panel3.Visible:=true;
    with ScrollBox2 do
    begin
      for j:=0 to ControlCount-1 do
      begin
        if Controls[j] is TfrmSLT_YH then
        begin
          with TfrmSLT_YH(Controls[j]) do
          begin
            fFileName:=Trim(FImagePath);
            for c:=0 to ControlCount-1 do
            begin
              if Controls[c] is TPanel then    
              begin
                with TPanel(Controls[c]) do
                begin
                  for z:=0 to ControlCount-1 do
                  begin
                    if Controls[z] is TMemo then
                    begin
                      if TMemo(Controls[z]).Text<>'' then
                      begin
                        application.ProcessMessages;
                        try
                          IdFTP1:=TIdFTP.Create(self);
                          IdFTP1.Host :=PicSvr;
                          IdFTP1.Username := 'three';
                          IdFTP1.Password := '641010';
                          IdFTP1.Connect();
                        except
                          IdFTP1.Quit;
                          IdFTP1.Free;
                          Application.MessageBox('无法连接到文件服务器，请检查！', '提示', MB_ICONWARNING);
                          Exit;
                        end;
                        FFName:=FTJHX+'-'+trim(TJMLNo.Caption)+'.jpg';
                        if not FileExists(FFName) then
                        begin
                          IdFTP1.Get('TJ\'+fFileName,FFName);
                        end;
                        if IdFTP1.Connected then
                        begin
                          IdFTP1.Quit;
                        end;
                      end;
                    end;
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
      //IdFTP1.Free;
    end;
  end;
  Panel3.Visible:=false;
  Application.MessageBox('图片下载成功','提示');
end;

procedure TfrmHXKYHK.THXGLClick(Sender: TObject);
var
  IdFTP1: TIdFTP;
  SaveDialog: TSaveDialog;
  fFileName,FFName:string;
  fFilePath:string;
  i,j,z,c,q:Integer;
begin
  try
    frmSCPerson:=TfrmSCPerson.Create(Application);
    with frmSCPerson do
    begin
      FlagStr:='YHHXZDYType';
      if ShowModal=1 then
      begin
        Panel3.Refresh;
        Panel3.Visible:=true;
        q:=0;
        with ScrollBox2 do
        begin
          for j:=0 to ControlCount-1 do
          begin
            if Controls[j] is TfrmSLT_YH then
            begin
              with TfrmSLT_YH(Controls[j]) do
              begin
                for c:=0 to ControlCount-1 do
                begin
                  if Controls[c] is TPanel then    
                  begin
                    with TPanel(Controls[c]) do
                    begin
                      for z:=0 to ControlCount-1 do
                      begin
                        if Controls[z] is TMemo then
                        begin
                          if TMemo(Controls[z]).Text<>'' then
                          begin
                            {with ADOQueryTemp do
                            begin
                              close;
                              sql.Clear;
                              sql.Add('update ML_Manage set HXType='''+trim(FSDPerson)+''' ');
                              sql.Add('where MLTPID='''+trim(FWBID)+'''');
                              execsql;
                            end;}
                            with ADOQueryTemp do
                            begin
                              close;
                              sql.Clear;
                              sql.Add('update Image_Info set TJHXType='''+trim(FSDPerson)+''' ');
                              sql.Add('where IMID='''+trim(FIMID)+'''');
                              execsql;
                            end;
                            q:=q+1;
                          end;
                        end;
                      end;
                    end;
                  end;
                end;
              end;
            end;
          end;
          //IdFTP1.Free;
        end;
      end;
      initimageSH(Trim(Order_Tree.fieldbyname('CPID').AsString));
      Panel3.Visible:=false;
    end;
  finally
    frmSCPerson.Free;
  end;
  ShowMessage(PChar('操作成功'+FloatToStr(q)+'个'));
end;

procedure TfrmHXKYHK.FormDestroy(Sender: TObject);
begin
  frmHXKYHK:=nil;
end;

procedure TfrmHXKYHK.TJHXTypeBtnClick(Sender: TObject);
begin
  try
    frmSCPerson:=TfrmSCPerson.Create(Application);
    with frmSCPerson do
    begin
      FlagStr:='YHHXZDYType';
      if ShowModal=1 then
      begin
        Self.TJHXType.Text:=Trim(FSDPerson);
        Self.TJHXType.TxtCode:=Trim(FSDPerson);
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
  //initimageSH(Trim(Order_Tree.fieldbyname('CPID').AsString));
end;

procedure TfrmHXKYHK.ToolButton2Click(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='YHHXZDYType';
      flagname:='花型自定义';
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmHXKYHK.TJHXTypeChange(Sender: TObject);
begin
  initimageSH(Trim(Order_Tree.fieldbyname('CPID').AsString));
end;

procedure TfrmHXKYHK.N1Click(Sender: TObject);
begin
  with ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add('select * from Image_Info where IMID='''+trim(FIMID)+'''');
    open;
  end;
  with ADOQuery1 do
  begin
    edit;
    fieldbyname('TJNote').value:=trim(TJNote.Text);
    post;
  end;
  Application.MessageBox('保存成功','提示');
end;

procedure TfrmHXKYHK.N2Click(Sender: TObject);
begin
  Panel6.Visible:=false;
end;

procedure TfrmHXKYHK.SMRKKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select A.*,B.*,MLDLNo SKID ');
      sql.Add(' from ML_Manage A ');
      sql.Add(' left join Image_Info B on B.TJML=A.TJML ');
      sql.Add(' left join BP_DY C on C.TFID=B.IMID and C.MLID=A.MLID');
      sql.Add(' left join BP_DY D on D.TFID=A.PTID and D.MLID=A.MLID');
      sql.Add(' where isnull(A.MLType,'''')=''印花面料'' and isnull(C.DYID,'''')='''+trim(SMRK.Text)+'''');
      Open;
    end;
    FDYID:=Trim(ADOQueryCmd.fieldbyname('IMID').AsString);
    initimageSH(Trim(Order_Tree.fieldbyname('CPID').AsString));
    FDYID:='';
    SMRK.Text:='';
  end;
end;

procedure TfrmHXKYHK.TJHXKeyPress(Sender: TObject; var Key: Char);
begin
  IF Key=#13 then
  begin
    initimageSH('CP1910290001');               //Trim(Order_Tree.fieldbyname('CPID').AsString)
    if adoqueryPicture.IsEmpty=False then
    begin
      mz:=Ceil(adoqueryPicture.fieldbyname('GS').AsInteger/9);
    end else
    begin
      mz:=1;
    end;
    LBCPAP.Caption:=IntToStr(my)+'/'+IntToStr(mz);
  end;
end;

procedure TfrmHXKYHK.TJMLNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    initimageSH('CP1910290001');               //Trim(Order_Tree.fieldbyname('CPID').AsString)
    if adoqueryPicture.IsEmpty=False then
    begin
      mz:=Ceil(adoqueryPicture.fieldbyname('GS').AsInteger/9);
    end else
    begin
      mz:=1;
    end;
    LBCPAP.Caption:=IntToStr(my)+'/'+IntToStr(mz);
  end;
end;

procedure TfrmHXKYHK.N3Click(Sender: TObject);
begin
  with ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add('delete from Image_Info where IMID='''+trim(FIMID)+'''');
    ExecSQL;
  end;
end;

end.
