unit U_JTSInfoSelList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class,
  RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxPC, cxCheckBox,
  Menus, cxDropDownEdit;

type
  TfrmJTSInfoSelList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DS_Main: TDataSource;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMXLSExport1: TRMXLSExport;
    RMDB_Main: TRMDBDataSet;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column18: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    cxTabControl1: TcxTabControl;
    v1Column1: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    Panel1: TPanel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
  private
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    { Public declarations }
  end;
var
  frmJTSInfoSelList:TfrmJTSInfoSelList;
implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;

{$R *.dfm}


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



procedure TfrmJTSInfoSelList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('品名管理Sel', Tv1, '加弹丝');
  Close;
end;

procedure TfrmJTSInfoSelList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;

    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add(' select * from  YT_Plan_Main');
      case cxTabControl1.TabIndex of
        0:
          begin
            sql.Add(' where isnull(Status,''0'')=''0'' ');
          end;
        1:
          begin
            sql.Add(' where isnull(Status,''0'')=''1'' ');
          end;
      end;
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);

  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmJTSInfoSelList.InitForm();
begin
  ReadCxGrid('品名管理Sel', Tv1, '加弹丝');
  InitGrid();
end;

procedure TfrmJTSInfoSelList.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active = False then
    Exit;
  SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  SCreateCDS20(ADOQueryMain, Order_Main);
  SInitCDSData20(ADOQueryMain, Order_Main);
end;

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

procedure TfrmJTSInfoSelList.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmJTSInfoSelList.cxTabControl1Change(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmJTSInfoSelList.FormDestroy(Sender: TObject);
begin
  frmJTSInfoSelList:=nil;
end;

procedure TfrmJTSInfoSelList.Tv1DblClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  ModalResult:=1;
end;

end.

