unit U_KWView;

interface

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

type
  TfrmKWView = class(TForm)
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column7: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    Order_Main: TClientDataSet;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryTemp: TADOQuery;
    v1Column2: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    FZIID,FFKWID:String;
    { Public declarations }
  end;

var
  frmKWView: TfrmKWView;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

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

procedure TfrmKWView.FormShow(Sender: TObject);
begin
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select *  ');   //KWName,GGQty=Sum(GGQty)
    sql.Add('from ZH_CP_Info_KC');
    sql.Add(' where ZIID='''+Trim(FZIID)+'''');
    sql.Add(' and isnull(KWID,'''')<>'''' ');
    if Trim(FFKWID)<>'' then
    begin
      sql.Add(' and KWID='''+Trim(FFKWID)+'''');
    end;
    sql.Add(' and isnull(GGQty,0)<>0');
    sql.Add(' order by KWXH');
    //sql.Add('Group by ZIID,KWName');
    open;
  end;
  SCreateCDS20(ADOQueryTemp,Order_Main);
  SInitCDSData20(ADOQueryTemp,Order_Main);
end;

end.
