unit U_PBNameDayQtyList;

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, cxDBLookupComboBox, cxContainer, cxDropDownEdit, cxPC, Menus,
  TeEngine, Series, TeeProcs, Chart, DbChart, GanttCh, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator;

type
  TfrmPBNameDayQtyList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Panel2: TPanel;
    Panel3: TPanel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v2Column12: TcxGridDBColumn;
    v2Column7: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    Panel10: TPanel;
    ToolButton1: TToolButton;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    Panel1: TPanel;
    Label2: TLabel;
    TBFind: TToolButton;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    C_CodeName: TEdit;
    Label1: TLabel;
    CarNo: TEdit;
    Label3: TLabel;
    APBatchNo: TEdit;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    Tv1Column9: TcxGridDBColumn;
    Tv1Column10: TcxGridDBColumn;
    Tv1Column11: TcxGridDBColumn;
    Tv1Column12: TcxGridDBColumn;
    Tv1Column13: TcxGridDBColumn;
    Tv1Column14: TcxGridDBColumn;
    Tv1Column15: TcxGridDBColumn;
    Tv1Column16: TcxGridDBColumn;
    Tv1Column17: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure C_CodeNameChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private

    { Private declarations }
    procedure InitGrid();
  public
   
  end;

var
  frmPBNameDayQtyList: TfrmPBNameDayQtyList;

implementation

uses
  U_DataLink, U_RTFun;

{$R *.dfm}


procedure TfrmPBNameDayQtyList.InitGrid();
begin
  Panel10.Visible:=True;
  Panel10.Refresh;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add('exec P_BI_PBCarCL_JD ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet1);
    SInitCDSData20(ADOQueryMain, ClientDataSet1);
  finally
    ADOQueryMain.EnableControls;
  end;
  Panel10.Visible:=False;
end;

procedure TfrmPBNameDayQtyList.FormDestroy(Sender: TObject);
begin
  frmPBNameDayQtyList := nil;
end;

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

procedure TfrmPBNameDayQtyList.TBCloseClick(Sender: TObject);
begin
  if Trim(DName)='ADMIN' then
  begin
    WriteCxGridAll(trim(self.Caption), Tv1,ADOQueryCmd,ADOQueryTemp);
  end;
  Close;
end;

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

procedure TfrmPBNameDayQtyList.ToolButton1Click(Sender: TObject);
begin
  TcxGridToExcel('品名日产量分析表',cxGrid1);
end;

procedure TfrmPBNameDayQtyList.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, ClientDataSet1);
    SInitCDSData20(ADOQueryMain, ClientDataSet1);
  end;
end;

procedure TfrmPBNameDayQtyList.C_CodeNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmPBNameDayQtyList.FormShow(Sender: TObject);
begin
  ReadCxGridAll(trim(self.Caption), Tv1);
end;

end.

