unit U_frameHelp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, cxGraphics, cxCustomData, cxStyles, cxTL, DB,
  ADODB, cxControls, cxInplaceContainer, cxTLData, cxDBTL, cxMaskEdit,
  ImgList;

type
  TfrmFrameHelp = class(TForm)
    ToolBar2: TToolBar;
    TOk: TToolButton;
    ToolButton7: TToolButton;
    cxDBTreeList1: TcxDBTreeList;
    ADOQueryHelp: TADOQuery;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
    ImageList24: TImageList;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle_gridRow: TcxStyle;
    cxStyle_gridFoot: TcxStyle;
    cxStyle_gridHead: TcxStyle;
    cxStyle_gridGroupBox: TcxStyle;
    cxStyle_yellow: TcxStyle;
    cxStyle_Red: TcxStyle;
    cxStyleTree: TcxStyle;
    cxStyle3: TcxStyle;
    procedure ToolButton7Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TOkClick(Sender: TObject);
    procedure cxDBTreeList1DblClick(Sender: TObject);
  private
    procedure DoQuery();
  public
    fIsMakeFrame:Boolean;
    fFrameNo:string;
    fFrameName:string;
    FframeLevel:integer;
  end;

var
  frmFrameHelp: TfrmFrameHelp;

implementation
uses
  U_global;
{$R *.dfm}

procedure TfrmFrameHelp.ToolButton7Click(Sender: TObject);
begin
  close;
end;

procedure TfrmFrameHelp.FormCreate(Sender: TObject);
begin
  cxDBTreeList1.Align :=alClient;
  with ADOConnection1 do
  begin
    Connected:=false;
    ConnectionString:=gConString;
    Connected:=true;
  end;
end;
///////////////////////////////////////////////////////////
  //
///////////////////////////////////////////////////////////
procedure TfrmFrameHelp.DoQuery();
begin
  with ADOQueryHelp do
  begin
    close;
    sql.Clear ;
    sql.Add('select * from YC_frame');
    sql.Add('where valid=''Y''');
    sql.Add('and frameLevel>=0');
    if trim(fFrameNo)<>'' then
    begin
      sql.Add('and frameNo='+quotedStr(fFrameNo));
    end;
    if trim(fFrameName)<>'' then
    begin
      sql.Add('and frameName like '+quotedStr('%'+fFrameName+'%'));
    end;
    if FframeLevel>0 then
    begin
      sql.Add('and frameLevel='+intTostr(FframeLevel));
    end;
    if fIsMakeFrame then
    begin
      sql.Add('and exists(select * from dc_machine where dept=frameNO)');
    end;
    sql.Add('order by frameLevel'); 
    Open;
  end;
end;

procedure TfrmFrameHelp.FormShow(Sender: TObject);
begin
  DoQuery();
end;

procedure TfrmFrameHelp.TOkClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then
     ModalResult:=-1
  else
    ModalResult:=1;
end;

procedure TfrmFrameHelp.cxDBTreeList1DblClick(Sender: TObject);
begin
  tok.Click  ;
end;

end.
