unit U_WBTypeSel;

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, cxPC,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu,
    dxDateRanges, U_BaseHelp, U_BaseList,
  System.ImageList, Vcl.ImgList,   
      
    
     
     
    
    
    
    
    
    
     
      
     
   
     
   dxScrollbarAnnotations;

type
  TfrmWBTypeSel = class(TfrmBaseHelp)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBExport: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    CDS_Main: TClientDataSet;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    cxGrid2: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGrid2Level1: TcxGridLevel;
    Label4: TLabel;
    WBType: TEdit;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure WBTypeChange(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
  private
    canshu1, FSTKName, canshu3: string;
    procedure InitGrid();
    { Private declarations }
  public

    { Public declarations }
  end;

var
  frmWBTypeSel: TfrmWBTypeSel;

implementation

uses
  U_DataLink, U_RTFun;

{$R *.dfm}

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

procedure TfrmWBTypeSel.FormCreate(Sender: TObject);
begin
  inherited;
  canshu1 := Trim(DParameters1);
  FSTKName := Trim(DParameters2);
  canshu3 := Trim(DParameters3);
end;

procedure TfrmWBTypeSel.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add(' select distinct WBType ');
      sql.Add(' from Tat_WB_Stk ');
      Open;
    end;
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_Main);
    SInitCDSData(ADOQueryMain, CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

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

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

procedure TfrmWBTypeSel.ToolButton2Click(Sender: TObject);
begin
  WBType.SetFocus;
  ModalResult := 1;
end;

procedure TfrmWBTypeSel.Tv1DblClick(Sender: TObject);
begin
  WBType.SetFocus;
  ModalResult := 1;
end;

procedure TfrmWBTypeSel.WBTypeChange(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 TfrmWBTypeSel.ConNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  end;
end;

procedure TfrmWBTypeSel.TBCloseClick(Sender: TObject);
begin
  Close;
end;

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

procedure TfrmWBTypeSel.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    exit;
  TcxGridToExcel(trim(self.Caption), cxGrid2);
end;

procedure TfrmWBTypeSel.N1Click(Sender: TObject);
begin
  SelOKNo(CDS_Main, True);
end;

procedure TfrmWBTypeSel.N2Click(Sender: TObject);
begin
  SelOKNo(CDS_Main, False);
end;

end.

