unit U_DCC_CodeNameMX;

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
  TfrmDCC_CodeNameMX = class(TForm)
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    Panel2: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    cxGrid3: TcxGrid;
    Tv3: TcxGridDBTableView;
    cxGridDBColumn15: TcxGridDBColumn;
    cxGridDBColumn16: TcxGridDBColumn;
    cxGridDBColumn17: TcxGridDBColumn;
    cxGridDBColumn18: TcxGridDBColumn;
    cxGridDBColumn19: TcxGridDBColumn;
    cxGridDBColumn20: TcxGridDBColumn;
    cxGridDBColumn21: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    Panel6: TPanel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    Panel8: TPanel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DataSource2: TDataSource;
    ClientDataSet2: TClientDataSet;
    cxGridPopupMenu3: TcxGridPopupMenu;
    DataSource3: TDataSource;
    ClientDataSet3: TClientDataSet;
    Panel1: TPanel;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    cxGridDBColumn13: TcxGridDBColumn;
    cxGridDBColumn14: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    Panel3: TPanel;
    Tv1Column1: TcxGridDBColumn;
    Tv2Column1: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
  private

    { Private declarations }
    procedure InitGrid();
  public
    FBegdate,FEnddate:TDate;
    FC_CodeName:String;
   
  end;

var
  frmDCC_CodeNameMX: TfrmDCC_CodeNameMX;

implementation

uses
  U_DataLink, U_RTFun,U_DCCarMX_Worker;

{$R *.dfm}


procedure TfrmDCC_CodeNameMX.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add('exec P_BI_DC_C_CodeName_MX :begdate,:enddate,:FC_CodeName,:Type');
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FBegdate));
      Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FEnddate));;
      Parameters.ParamByName('FC_CodeName').Value:=FC_CodeName;
      Parameters.ParamByName('Type').Value:='CarNo';
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet1);
    SInitCDSData20(ADOQueryMain, ClientDataSet1);
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add('exec P_BI_DC_C_CodeName_MX :begdate,:enddate,:FC_CodeName,:Type');
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FBegdate));
      Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FEnddate));;
      Parameters.ParamByName('FC_CodeName').Value:=FC_CodeName;
      Parameters.ParamByName('Type').Value:='Worker';
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet2);
    SInitCDSData20(ADOQueryMain, ClientDataSet2);
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add('exec P_BI_DC_C_CodeName_MX :begdate,:enddate,:FC_CodeName,:Type');
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FBegdate));
      Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',FEnddate));;
      Parameters.ParamByName('FC_CodeName').Value:=FC_CodeName;
      Parameters.ParamByName('Type').Value:='JSDate';
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet3);
    SInitCDSData20(ADOQueryMain, ClientDataSet3);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmDCC_CodeNameMX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caHide;;
end;

procedure TfrmDCC_CodeNameMX.FormShow(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmDCC_CodeNameMX.FormDestroy(Sender: TObject);
begin
   frmDCC_CodeNameMX:=nil;
end;

procedure TfrmDCC_CodeNameMX.Tv1DblClick(Sender: TObject);
begin
 { try
    frmDCCarMX_Worker := TfrmDCCarMX_Worker.Create(Application);
    with frmDCCarMX_Worker do
    begin
      FBegdate := Self.FBegdate;
      FEnddate := Self.FEnddate;
      FCarNo := Trim(Self.FCarNo);
      FWorker := Trim(Self.ClientDataSet1.fieldbyname('Worker').AsString);
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmDCCarMX_Worker.Free;
  end;  }
end;

end.

