unit U_ShaWFHList;

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
  TfrmShaWFHList = 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;
    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
  frmShaWFHList: TfrmShaWFHList;

implementation

uses
  U_DataLink, U_RTFun,U_ShaWFHMXList;

{$R *.dfm}

procedure TfrmShaWFHList.FormDestroy(Sender: TObject);
begin
  frmShaWFHList := nil;
end;

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

procedure TfrmShaWFHList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_View_SXYLFH :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 TfrmShaWFHList.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

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

procedure TfrmShaWFHList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('原料未发货', Tv1, '原料仓库');
  Close;
end;

procedure TfrmShaWFHList.FormShow(Sender: TObject);
begin
  ReadCxGrid('原料未发货', Tv1, '原料仓库');
  EndDate.Date:=SGetServerDate(ADOQueryTemp);
  BegDate.Date:=EndDate.Date-30;
end;

procedure TfrmShaWFHList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  try
    frmShaWFHMXList:=TfrmShaWFHMXList.Create(Application);
    with frmShaWFHMXList do
    begin
      frmShaWFHMXList.BegDate.Date:=Self.BegDate.Date;
      frmShaWFHMXList.EndDate.Date:=Self.EndDate.Date;
      frmShaWFHMXList.FactoryName1:=Trim(Self.CDS_Main.fieldbyname('FactoryName').AsString);
      frmShaWFHMXList.Y_CodeName1:=Trim(Self.CDS_Main.fieldbyname('Y_CodeName').AsString);
      frmShaWFHMXList.Y_Spec1:=Trim(Self.CDS_Main.fieldbyname('Y_Spec').AsString);
      frmShaWFHMXList.BatchNo1:=Trim(Self.CDS_Main.fieldbyname('BatchNo').AsString);
      frmShaWFHMXList.ToFactoryName1:=Trim(Self.CDS_Main.fieldbyname('ToFactoryName').AsString);
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmShaWFHMXList.Free;
  end;
end;

end.

