unit U_DJCLList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
  cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
  RM_e_Jpeg, RM_e_txt, RM_e_csv, RM_E_llPDF, Math, Clipbrd, cxPC, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters,
  dxSkinscxPCPainter;

type
  TfrmDJCLList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DS_Main: TDataSource;
    TBExport: TToolButton;
    CDS_Main: TClientDataSet;
    RM2: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ADOQueryPrint: TADOQuery;
    RMXLSExport1: TRMXLSExport;
    Panel1: TPanel;
    Label8: TLabel;
    Label11: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Filler: TComboBox;
    btnfind: TToolButton;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    Label1: TLabel;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Label3: TLabel;
    MPRTCODENAME: TEdit;
    Label2: TLabel;
    OrderNo: TEdit;
    Tv1Column3: TcxGridDBColumn;
    Label4: TLabel;
    BPBigType: TComboBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnfindClick(Sender: TObject);
    procedure FillerChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    DQdate: TDateTime;
    FLeft, FTop: Integer;
    CurrentPage, RecordsNumber: Integer;
    procedure InitGrid();
  
    { Private declarations }
  public
    FFInt: Integer;
    canshu1: string;
    { Public declarations }
  end;

var
  frmDJCLList: TfrmDJCLList;

implementation

uses
  U_DataLink, U_Fun;

{$R *.dfm}
procedure TfrmDJCLList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmDJCLList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('每日打卷产量表', Tv1, '进度管理');
  Close;
end;

procedure TfrmDJCLList.InitGrid();
var
  fwhere, Pwhere: string;
begin

  Pwhere := SGetFilters(Panel1, 1, 2);

  if trim(fwhere) <> '' then
  begin
    fwhere := fwhere + ' and ' + trim(Pwhere);
  end
  else
  begin
    fwhere := ' where ' + trim(Pwhere);
  end;

  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_View_MRDJCL ');
      sql.Add('@BegDate=' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)));
      sql.Add(',@EndDate=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)));

      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);

  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmDJCLList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  SelExportData(Tv1, ADOQueryMain, Self.Caption);
end;

procedure TfrmDJCLList.TBRafreshClick(Sender: TObject);
begin

  InitGrid();

end;

procedure TfrmDJCLList.FormCreate(Sender: TObject);
var
  fsj: string;
begin
  ReadCxGrid('每日打卷产量表', Tv1, '进度管理');
  fsj := 'select distinct(Filler) name from WFB_MJJY   ';
  SInitComBoxBySql(ADOQueryCmd, Filler, False, fsj);
  Filler.ItemIndex := Filler.Items.IndexOf(trim(DName));
  EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
  BegDate.DateTime := EndDate.DateTime - 14;
end;

procedure TfrmDJCLList.btnfindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
  end;
end;

procedure TfrmDJCLList.FillerChange(Sender: TObject);
begin
  btnfind.Click;
end;

procedure TfrmDJCLList.FormDestroy(Sender: TObject);
begin
  frmDJCLList := nil;
end;

end.

