unit U_GYSListPB;

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
  TfrmGYSListPB = 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);
  private
    { Private declarations }
    procedure InitGrid();
  public
    FGYSType:string;
  end;

//var
  //frmGYSListPB: TfrmGYSListPB;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}


procedure TfrmGYSListPB.InitGrid();
begin
  with ADOQueryMain do
  begin
    Filtered:=False;
    Close;
    SQL.Clear;
    sql.Add(' select *,zjm=dbo.getpinyin(KHName) ');
    sql.add(',SHStatus=(case when isnull(status,''0'')=''0'' then ''未审核'' else ''已审核'' end)');
    sql.Add(' from KH_Main A ');
    sql.add(' where isnull(KHFlag,'''')='''+Trim(canshu2)+''' and isnull(Valid,'''')=''Y''  ');
    if Trim(canshu1)='录入' then
    begin
      sql.Add(' and exists(select * from KH_Owner B where B.KHMainId=A.KHMainId and B.UserName='''+Trim(DName)+''')');
    end;
    Open;
  end;
  SCreateCDS20(ADOQueryMain,CDS_HZ);
  SInitCDSData20(ADOQueryMain,CDS_HZ);
end;

procedure TfrmGYSListPB.FormDestroy(Sender: TObject);
begin
  //frmGYSListPB:=nil;
end;

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

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

procedure TfrmGYSListPB.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 TfrmGYSListPB.zjmChange(Sender: TObject);
begin
  ToolButton2.Click;
end;


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

end.


