unit U_UserSel;

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, cxDBLookupComboBox, ComObj;

type
  FdDy = record
    inc: integer; //客户端套接字句柄
    FDdys: string[32]; //客户端套接字
    FdDysName: string[32]; //客户端套接字
  end;

  TfrmUserSel = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    Label3: TLabel;
    CoName: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_User: TClientDataSet;
    Label1: TLabel;
    CoCode: TEdit;
    ToolButton1: TToolButton;
    v2Column1: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    v2Column3: TcxGridDBColumn;
    v2Column4: 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 CoNameChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
  private
 
    { Private declarations }
    procedure InitGrid();
  public
  end;

var
  frmUserSel: TfrmUserSel;

implementation

uses
  U_DataLink, U_Fun;

{$R *.dfm}

procedure TfrmUserSel.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add(' select * from SY_User where Udept in (''生产部'',''印花加工部'') ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_User);
    SInitCDSData20(ADOQueryMain, CDS_User);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmUserSel.FormDestroy(Sender: TObject);
begin
  frmUserSel := nil;
end;

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

procedure TfrmUserSel.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid(trim(self.caption), Tv2, '供应商管理');
  Close;
end;

procedure TfrmUserSel.FormShow(Sender: TObject);
begin
  ReadCxGrid(trim(self.Caption), Tv2, '供应商管理管理');
  InitGrid();
end;

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

procedure TfrmUserSel.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, CDS_User);
    SInitCDSData20(ADOQueryMain, CDS_User);
  end;
end;

procedure TfrmUserSel.CoNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmUserSel.ToolButton1Click(Sender: TObject);
begin
  ModalResult := 1;
end;

end.

