unit U_GYSListSel;

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, cxPC, cxDropDownEdit, Menus, BtnEdit;

type
  TfrmGYSListSel = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    zjm: TEdit;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Label2: TLabel;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    V1Column1: TcxGridDBColumn;
    cxGYSName: TcxGridDBColumn;
    cxGridDBGYSNameZC: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    V1Column2: TcxGridDBColumn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure zjmChange(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TV1DblClick(Sender: TObject);
  private
    { Private declarations }
    procedure InitGrid();
  public
    FGYSType:string;
  end;

var
  frmGYSListSel: TfrmGYSListSel;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}


procedure TfrmGYSListSel.InitGrid();
begin
  with ADOQueryMain do
  begin
    Filtered:=False;
    Close;
    SQL.Clear;
    sql.Add(' select *,zjm=dbo.getpinyin(KHName)+dbo.getpinyin(KHNameJC)+KHName+KHNameJC ');
    sql.Add(' from KH_Main A ');
    sql.add(' where isnull(KHFlag,'''')=''GYS'' and isnull(Valid,'''')=''Y''  ');
    sql.Add(' and isnull(KHType,'''')='''+Trim(FGYSType)+'''');
    Open;
  end;
  SCreateCDS20(ADOQueryMain,CDS_HZ);
  SInitCDSData20(ADOQueryMain,CDS_HZ);
end;

procedure TfrmGYSListSel.FormDestroy(Sender: TObject);
begin
  frmGYSListSel:=nil;
end;

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

procedure TfrmGYSListSel.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('PBGYS11YXSelYX',Tv1,'供应商管理');
  Close;
end;
procedure TfrmGYSListSel.TBRafreshClick(Sender: TObject);
begin
  ToolBar1.SetFocus;
  InitGrid();
end;

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

procedure TfrmGYSListSel.zjmChange(Sender: TObject);
begin
  ToolButton2.Click;
end;


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

procedure TfrmGYSListSel.FormShow(Sender: TObject);
begin
  ReadCxGrid('PBGYS11YXSelYX',Tv1,'供应商管理');
  InitGrid();
end;

procedure TfrmGYSListSel.TV1DblClick(Sender: TObject);
begin
  if CDS_HZ.IsEmpty then Exit;
  ModalResult:=1;
end;

end.


