unit U_GYSListPB;

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, cxCheckBox, cxCalendar, cxSplitter,
  RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls,
  Menus, cxButtonEdit, cxDropDownEdit, BtnEdit;

type
  TfrmGYSListPB = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    Order_Main: TClientDataSet;
    ToolButton3: TToolButton;
    Panel1: TPanel;
    v1KHNo: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    Label2: TLabel;
    GYSHZ: TEdit;
    ToolButton1: TToolButton;
    v1KHLXR: TcxGridDBColumn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
    procedure GYSHZChange(Sender: TObject);
  private
    DQdate:TDateTime;
    XZKHTYpe:string;
    procedure InitGrid();
    procedure InitForm();
    function  DelData():Boolean;
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmGYSListPB: TfrmGYSListPB;

implementation
uses
  U_DataLink,U_RTFun,U_ZDYHelp,U_SCPerson,U_PBGYSInPutMain;

{$R *.dfm}

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

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

procedure TfrmGYSListPB.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;

end;

procedure TfrmGYSListPB.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('供应商CXPB',Tv1,'供应商管理');

end;

procedure TfrmGYSListPB.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select *,GYSHZ=dbo.getpinyin(KHName)+dbo.getpinyin(KHNameJC)+KHName+KHNameJC+KHNO  ');
      sql.Add(' from KH_Main A  ');
      sql.Add(' where isnull(KHFlag,'''')=''GYS'' and isnull(Valid,'''')=''Y'' and isnull(KHType,'''')=''坯布厂'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
    TBFind.Click;
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmGYSListPB.InitForm();
begin
  ReadCxGrid('供应商CXPB',Tv1,'供应商管理');
  InitGrid();
end;

procedure TfrmGYSListPB.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;

function TfrmGYSListPB.DelData():Boolean;
begin

end;

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

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

procedure TfrmGYSListPB.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmGYSListPB.ToolButton3Click(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmGYSListPB.Tv1DblClick(Sender: TObject);
begin
  ToolButton3.Click;
end;

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

end.
