unit U_ShaKCHZList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
  cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
  cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
  ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
  cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset,
  RM_System, RM_GridReport, Menus, cxCalendar, cxButtonEdit, cxTextEdit,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;

type
  TfrmShaKCHZList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    CDS_Main: TClientDataSet;
    cxGrid2: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column14: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v2Column6: TcxGridDBColumn;
    cxGrid2Level1: TcxGridLevel;
    v1Column10: TcxGridDBColumn;
    Panel1: TPanel;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    Label1: TLabel;
    Label2: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
  private
    procedure InitGrid();
    { Private declarations }
  public
    FDYFlag: string;
    { Public declarations }
  end;

var
  frmShaKCHZList: TfrmShaKCHZList;

implementation

uses
  U_DataLink, U_RTFun,U_ShaKCHZMXList;

{$R *.dfm}

procedure TfrmShaKCHZList.FormDestroy(Sender: TObject);
begin
  frmShaKCHZList := nil;
end;

procedure TfrmShaKCHZList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action :=cafree ;
end;

procedure TfrmShaKCHZList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_View_SXKCHZ :begdate,:enddate   ');
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date));
      Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1));
      Open;
      //ShowMessage(SQL.Text);
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;

end;

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

procedure TfrmShaKCHZList.ConNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  end;
end;

procedure TfrmShaKCHZList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('加弹丝库存汇总查询', Tv1, '原料仓库');
  Close;
end;

procedure TfrmShaKCHZList.FormShow(Sender: TObject);
begin
  ReadCxGrid('加弹丝库存汇总查询', Tv1, '原料仓库');
  EndDate.Date:=SGetServerDate(ADOQueryTemp);
  BegDate.Date:=EndDate.Date-30;
end;

procedure TfrmShaKCHZList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  try
    frmShaKCHZMXList:=TfrmShaKCHZMXList.Create(Application);
    with frmShaKCHZMXList do
    begin
      frmShaKCHZMXList.BegDate.Date:=Self.BegDate.Date;
      frmShaKCHZMXList.EndDate.Date:=Self.EndDate.Date;
      frmShaKCHZMXList.FactoryName1:=Trim(Self.CDS_Main.fieldbyname('FactoryName').AsString);
      frmShaKCHZMXList.Y_CodeName1:=Trim(Self.CDS_Main.fieldbyname('Y_CodeName').AsString);
      frmShaKCHZMXList.Y_Spec1:=Trim(Self.CDS_Main.fieldbyname('Y_Spec').AsString);
      frmShaKCHZMXList.BatchNo1:=Trim(Self.CDS_Main.fieldbyname('BatchNo').AsString);
      frmShaKCHZMXList.Y_CodeNameCP1:=Trim(Self.CDS_Main.fieldbyname('Y_CodeNameCP').AsString);
      frmShaKCHZMXList.Y_Type1:=Trim(Self.CDS_Main.fieldbyname('Y_Type').AsString);
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmShaKCHZMXList.Free;
  end;
end;

end.

