unit U_QXSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
  cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
  cxTextEdit, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, 
   dxDateRanges, dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters,
  dxScrollbarAnnotations;

type
  TfrmQXSel = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Label1: TLabel;
    QXName: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v2PSType: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    TSsel: TToolButton;
    Tv2Column1: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ZdyNameChange(Sender: TObject);
    procedure TSselClick(Sender: TObject);
    procedure TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
  private
    { Private declarations }
    procedure InitGrid();
  public
    fDEFstr5: string;
  end;

var
  frmQXSel: TfrmQXSel;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp;

{$R *.dfm}

procedure TfrmQXSel.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add(' select * from Dye_Technics ');
      Open;
    end;
    SCreateCDS(ADOQueryMain, CDS_HZ);
    SInitCDSData(ADOQueryMain, CDS_HZ);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmQXSel.FormDestroy(Sender: TObject);
begin
  frmQXSel := nil;
end;

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

procedure TfrmQXSel.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('工序查询', Tv2, '客户自定义');
  Close;
end;

procedure TfrmQXSel.FormShow(Sender: TObject);
begin
  ReadCxGrid('工序查询', Tv2, '客户自定义');
  InitGrid();
end;

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

procedure TfrmQXSel.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_HZ);
    SInitCDSData(ADOQueryMain, CDS_HZ);
  end;
end;

procedure TfrmQXSel.ZdyNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmQXSel.TSselClick(Sender: TObject);
begin
  if CDS_HZ.IsEmpty then
    exit;
  ModalResult := 1;
end;

procedure TfrmQXSel.TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  CDS_HZ.Delete;
end;

end.

