unit U_EmptyBeamStkList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
  cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
  cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
  ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
  cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset,
  RM_System, RM_GridReport, Menus, cxCalendar, cxButtonEdit, cxTextEdit,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges,
  dxBarBuiltInMenu, U_BaseList, dxScrollbarAnnotations, cxContainer,
  dxSkinsCore, dxSkinsDefaultPainters, cxProgressBar;

type
  TfrmEmptyBeamStkList = class(TfrmBaseList)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    CDS_Main: TClientDataSet;
    CDS_HZ: TClientDataSet;
    PopupMenu1: TPopupMenu;
    Label4: TLabel;
    FromCoName: TcxTextEdit;
    ToolButton2: TToolButton;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxGridDBColumn16: TcxGridDBColumn;
    cxGridDBColumn18: TcxGridDBColumn;
    cxGridDBColumn20: TcxGridDBColumn;
    cxGridDBColumn21: TcxGridDBColumn;
    cxGridDBColumn22: TcxGridDBColumn;
    cxGridDBColumn23: TcxGridDBColumn;
    TV1Column22: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    TV1Column1: TcxGridDBColumn;
    TV1Column2: TcxGridDBColumn;
    Label1: TLabel;
    WBNO: TcxTextEdit;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure MPRTCodeNameChange(Sender: TObject);
    procedure SXBatchNOChange(Sender: TObject);
    procedure FromCoNameChange(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure FromCoNamePropertiesChange(Sender: TObject);
  private
    canshu1, FStkName, canshu3: string;
    procedure InitGrid();

    { Private declarations }
  public

    { Public declarations }
  end;

var
  frmEmptyBeamStkList: TfrmEmptyBeamStkList;

implementation

uses
  U_DataLink, U_RTFun;

{$R *.dfm}

procedure TfrmEmptyBeamStkList.FormDestroy(Sender: TObject);
begin
  inherited;
  frmEmptyBeamStkList := nil;
end;

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

procedure TfrmEmptyBeamStkList.FormCreate(Sender: TObject);
begin
  inherited;
  canshu1 := Trim(self.fParameters1);
  FStkName := Trim(self.fParameters2);
  canshu3 := Trim(self.fParameters3);
end;

procedure TfrmEmptyBeamStkList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add(' EXEC P_TatWB_StkALL ');
      sql.Add(' select A.*,B.* from Tat_WB_Stk A inner join Tat_WB_IO B on A.STKTWIOID=B.TWIOID ');
      sql.Add(' where  B.IOFlag =''入库'' and isnull(B.stkName,'''')=''' + Trim(FstkName) + '''');
      Open;
    end;
    SCreateCDS(ADOQueryMain, CDS_Main);
    SInitCDSData(ADOQueryMain, CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmEmptyBeamStkList.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmEmptyBeamStkList.ConNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  end;
end;

procedure TfrmEmptyBeamStkList.TBCloseClick(Sender: TObject);
begin

  Close;
end;

procedure TfrmEmptyBeamStkList.FormShow(Sender: TObject);
begin
  inherited;
  ReadCxGrid(trim(Self.Caption), Tv1, '染色坯布仓库');
  InitGrid();
end;

procedure TfrmEmptyBeamStkList.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_Main);
    SInitCDSData(ADOQueryMain, CDS_Main);
  end;
end;

procedure TfrmEmptyBeamStkList.MPRTCodeNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmEmptyBeamStkList.SXBatchNOChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmEmptyBeamStkList.FromCoNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmEmptyBeamStkList.FromCoNamePropertiesChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmEmptyBeamStkList.ToolButton2Click(Sender: TObject);
begin
  WriteCxGrid(trim(Self.Caption), Tv1, '染色坯布仓库');
end;

procedure TfrmEmptyBeamStkList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  ModalResult := 1;
end;

end.

