unit U_CheckMdList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
  cxGridCustomView, cxGrid, ImgList, ComCtrls, ToolWin, ADODB, ExtCtrls;

type
  TfrmCheckMdList = class(TForm)
    cxGrid1: TcxGrid;
    tv1: TcxGridDBTableView;
    tv1listNo: TcxGridDBColumn;
    tv1rollNum: TcxGridDBColumn;
    tv1Quantity: TcxGridDBColumn;
    DBGrid1Level1: TcxGridLevel;
    tv1Qty: TcxGridDBColumn;
    tv1P_color: TcxGridDBColumn;
    ToolBar2: TToolBar;
    TOk: TToolButton;
    TBClose: TToolButton;
    ImageList1: TImageList;
    DataSource1: TDataSource;
    ADOQueryHelp: TADOQuery;
    Panel1: TPanel;
    procedure TBCloseClick(Sender: TObject);
    procedure TOkClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure tv1DblClick(Sender: TObject);
  private
    procedure DoQuery();
  public
    fKeyType:integer;
    fPlanNO:string;
    fP_seqNO:string;
    fGangNo:string;
    fCarNo:string;
  end;

var
  frmCheckMdList: TfrmCheckMdList;

implementation
uses
  U_adodbmd;
{$R *.dfm}

procedure TfrmCheckMdList.TBCloseClick(Sender: TObject);
begin
  close;
end;

procedure TfrmCheckMdList.TOkClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then
  begin
    ModalResult:=-1
  end
  else
    ModalResult:=1;
end;
///////////////////////////////////////////////////////
procedure TfrmCheckMdList.DoQuery();
begin
  try
    ADOQueryHelp.DisableControls ;
    with ADOQueryHelp do
    begin
      close;
      sql.Clear ;
      sql.Add('exec P_SELECT_CheckMdList');
      sql.Add('@keyType='+intTostr(fKeyType));
      sql.Add(',@planNo='+quotedStr(fPlanNO));
      sql.Add(',@P_seqNo='+quotedStr(fP_seqNo));
      sql.Add(',@gangNO='+QuotedStr(fGangNo));
      sql.Add(',@carNo='+QuotedStr(fCarNo));
      Open;
    end;
  finally
    ADOQueryHelp.EnableControls ;
  end;
end;
procedure TfrmCheckMdList.FormShow(Sender: TObject);
begin
  DoQuery();
end;

procedure TfrmCheckMdList.FormCreate(Sender: TObject);
begin
  cxGrid1.Align :=alClient;
end;

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

procedure TfrmCheckMdList.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case key of
     VK_RETURN:
         begin
           Tok.Click ;
         end;
     vk_Escape:
         begin
           TBClose.Click ;
         end;
  end;
end;

procedure TfrmCheckMdList.tv1DblClick(Sender: TObject);
begin
  Tok.Click ;
end;

end.
