unit U_DjdDjClList;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxStyles, cxCustomData,
  cxFilter, cxData, cxDataStorage, cxEdit, cxNavigator, dxDateRanges,
  dxScrollbarAnnotations, Data.DB, cxDBData, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
  Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls, Vcl.ToolWin,U_BaseList,
  Data.Win.ADODB, Data.FMTBcd, dxBarBuiltInMenu, cxGridCustomPopupMenu,
  cxGridPopupMenu, Data.SqlExpr, cxContainer, dxCore, cxDateUtils, cxTextEdit,
  cxMaskEdit, cxDropDownEdit, cxCalendar, dxLayoutcxEditAdapters,
  dxLayoutContainer, dxLayoutControl, frxRich, frxBarcode, frxClass, frxDBSet, frxTableObject, frxExportBaseDialog, frxExportPDF,
  cxProgressBar;

type
  TfrmDjdDjClList = class(TFrmBaseList)
    toolbar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBExport: TToolButton;
    Tbcgs: TToolButton;
    TBClose: TToolButton;
    Filler: TcxTextEdit;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    TV1Column1: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    begdate: TcxDateEdit;
    enddate: TcxDateEdit;
    TV1ConNo: TcxGridDBColumn;
    dxLayoutControl_query: TdxLayoutControl;
    C_name: TcxTextEdit;
    orderNo: TcxTextEdit;
    C_color: TcxTextEdit;
    conNo: TcxTextEdit;
    dxLayoutControl_queryGroup_Root: TdxLayoutGroup;
    dxLayoutItem2: TdxLayoutItem;
    dxLayoutItem_color: TdxLayoutItem;
    dxLayoutItem_pm: TdxLayoutItem;
    dxLayoutItem_hth: TdxLayoutItem;
    dxLayoutGroup1: TdxLayoutGroup;
    dxLayoutGroup2: TdxLayoutGroup;
    dxLayoutItem_beg: TdxLayoutItem;
    dxLayoutItem_end: TdxLayoutItem;
    dxLayoutItem1: TdxLayoutItem;
    frxReport1: TfrxReport;
    frxDB_1: TfrxDBDataset;
    frxBarCodeObject1: TfrxBarCodeObject;
    frxRichObject1: TfrxRichObject;
    frxReportTableObject1: TfrxReportTableObject;
    frxPDFExport1: TfrxPDFExport;
    TV1CustName: TcxGridDBColumn;
    TV1operators: TcxGridDBColumn;
    TV1Column2: TcxGridDBColumn;
    TV1Column3: TcxGridDBColumn;
    CustName: TcxTextEdit;
    dxLayoutItem3: TdxLayoutItem;
    TV1Column4: TcxGridDBColumn;
    procedure FormCreate(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBFindClick(Sender: TObject);
    procedure TbcgsClick(Sender: TObject);
  private
    procedure InitGrid();
  public
    { Public declarations }
  end;

var
  frmDjdDjClList: TfrmDjdDjClList;

implementation
uses
  U_RTFun,U_DataLink,U_globalVar,U_FormLayOutDesign;
{$R *.dfm}

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

procedure TfrmDjdDjClList.FormCreate(Sender: TObject);
begin
  inherited  ;
  cxGrid1.Align:=alClient;
  BegDate.Date:=SGetServerDateTime(ADOQueryBaseTemp);
  EndDate.Date:=SGetServerDateTime(ADOQueryBaseTemp)
end;

procedure TfrmDjdDjClList.FormShow(Sender: TObject);
begin
  inherited;
  TBRafresh.Click;
   ReadCxGrid(Trim(self.Caption) + 'Tv1', Tv1, gDllFileCaption);
end;

procedure TfrmDjdDjClList.InitGrid();
begin
try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      Filtered:=False;
      sql.Add('exec p_select_djcl_list');
      sql.Add('@begdate='+ quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.Date)));
      sql.Add(',@enddate='+ quotedstr(FormatDateTime('yyyy-MM-dd', endDate.Date+1)));
      sql.Add(',@djMan='+ quotedstr(gUserName));
      sql.Add(',@cltype='+ quotedstr('´ò¾í²úÁ¿'));
      Open;
    end;

  finally
    ADOQueryMain.EnableControls;
  end
end;

procedure TfrmDjdDjClList.TbcgsClick(Sender: TObject);
begin
  inherited;
   WriteCxGrid(Trim(self.Caption) + 'Tv1', Tv1, gDllFileCaption);
  if gIsCanDesign then
  begin
    saveLayOut(application, dxLayoutControl_query, ADOQueryBaseCmd, PWideChar(  fDllFileName + '|' + Self.Name + '|' + dxLayoutControl_query.Name + '.ini'));
  end;
end;

procedure TfrmDjdDjClList.TBCloseClick(Sender: TObject);
begin
  inherited;
  close;
end;

procedure TfrmDjdDjClList.TBExportClick(Sender: TObject);
begin
  inherited;
  if ADOQueryMain.IsEmpty then exit;
  TcxGridToExcel(self.Caption,cxGrid1);
end;

procedure TfrmDjdDjClList.TBFindClick(Sender: TObject);
begin
  inherited;
   if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SLGetFilters(dxLayoutControl_query,1,2));
  end;
end;

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

end.
