unit U_Order_KCTX;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter,
  cxData, cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, cxCalendar,
  StdCtrls, ExtCtrls, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxPC,
  cxGridCustomPopupMenu, cxGridPopupMenu, DBClient, ADODB;

type
  TFrmKCTiXing = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1CKName: TcxGridDBColumn;
    v1SPName: TcxGridDBColumn;
    v1CFDD: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Panel1: TPanel;
    Label3: TLabel;
    SPName: TEdit;
    v1QtyKC: TcxGridDBColumn;
    v1QtyUnit: TcxGridDBColumn;
    ADOQueryMain: TADOQuery;
    Order_Main: TClientDataSet;
    DataSource2: TDataSource;
    cxGridPopupMenu3: TcxGridPopupMenu;
    Label1: TLabel;
    CKName: TEdit;
    Label2: TLabel;
    CFDD: TEdit;
    procedure TBFindClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SPNameChange(Sender: TObject);
  private
    procedure initgrid();
    { Private declarations }
  public
    FMprtCodeName:string;
    { Public declarations }
  end;

var
  FrmKCTiXing: TFrmKCTiXing;

implementation

uses U_DataLink,U_Fun;

{$R *.dfm}
procedure TFrmKCTiXing.initgrid();
begin
  with ADOQueryMain do
  begin
    close;
    sql.Clear;
    sql.Add('exec P_View_CPXGKC :MPTCodeName,:PState');
    Parameters.ParamByName('MPTCodeName').Value:=trim(SPName.Text);
    Parameters.ParamByName('PState').Value:=0;
    open;
  end;
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TFrmKCTiXing.TBFindClick(Sender: TObject);
begin
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TFrmKCTiXing.TBRafreshClick(Sender: TObject);
begin
  initgrid();
end;

procedure TFrmKCTiXing.cxTabControl1Change(Sender: TObject);
begin
  initgrid();
end;

procedure TFrmKCTiXing.TBCloseClick(Sender: TObject);
begin
  close;
end;

procedure TFrmKCTiXing.FormShow(Sender: TObject);
begin
  initgrid();
end;

procedure TFrmKCTiXing.SPNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

end.
