unit U_DDDJJHMX;

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
  TfrmDDDJJHMX = class(TForm)
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Panel2: TPanel;
    Panel3: TPanel;
    SH1: TPanel;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    DataSource3: TDataSource;
    ClientDataSet3: TClientDataSet;
    cxGrid3: TcxGrid;
    Tv3: TcxGridDBTableView;
    Tv3Column1: TcxGridDBColumn;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure Tv3DblClick(Sender: TObject);
  private

    { Private declarations }
    procedure InitGrid();
  public
    FBegdate, FEnddate: TDate;
    FKHName, FSPName: string;
  end;

var
  frmDDDJJHMX: TfrmDDDJJHMX;

implementation

uses
  U_DataLink, U_RTFun,U_DDDJJHMXGang;

{$R *.dfm}

procedure TfrmDDDJJHMX.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add('exec P_BI_DJMoneyAll_MX_PM_Ord :begdate,:enddate,:KHName,:SPName');
      Parameters.ParamByName('begdate').Value := Trim(FormatDateTime('yyyy-MM-dd', FBegdate));
      Parameters.ParamByName('enddate').Value := Trim(FormatDateTime('yyyy-MM-dd', FEnddate));
      Parameters.ParamByName('KHName').Value := FKHName;
      Parameters.ParamByName('SPName').Value := FSPName;
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet1);
    SInitCDSData20(ADOQueryMain, ClientDataSet1);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

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

procedure TfrmDDDJJHMX.FormShow(Sender: TObject);
begin
  SH1.Caption := '' + '  ( ' + FKHName + ' )  ';
  InitGrid();
end;

procedure TfrmDDDJJHMX.Tv3DblClick(Sender: TObject);
begin
  if ClientDataSet1.IsEmpty then
    Exit;
  try
    frmDDDJJHMXGang := TfrmDDDJJHMXGang.Create(Application);
    with frmDDDJJHMXGang do
    begin
      FBegdate := Self.FBegdate;
      FEnddate := Self.FEnddate;
      FOrderNo := Trim(Self.ClientDataSet1.fieldbyname('OrderNO').AsString);
      FCarNo := Trim(FKHName);
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmDDDJJHMXGang.Free;
  end;
end;

end.

