unit U_YGYPZZChkList_NXZZJL;

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, cxButtonEdit, cxDropDownEdit, cxPC, ActnMan, ActnColorMaps;

type
  TfrmYGYPZZChkList_NXZZJL = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Order_Main: TClientDataSet;
    Panel1: TPanel;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    N1: TMenuItem;
    BegDate: TDateTimePicker;
    Label3: TLabel;
    EndDate: TDateTimePicker;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1FactoryName: TcxGridDBColumn;
    v1GangWei: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    v1Dept: TcxGridDBColumn;
    DataSource2: TDataSource;
    order_Sub: TClientDataSet;
    v1GZMonth: TcxGridDBColumn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    ADOQuery1: TADOQuery;
    YGName: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Dept: TEdit;
    v1Money: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CustomerNoNameChange(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure YGNameChange(Sender: TObject);
  private
    canshu1:string;
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;
    FYGID:string;
    { Public declarations }
  end;

var
  frmYGYPZZChkList_NXZZJL: TfrmYGYPZZChkList_NXZZJL;

implementation
uses
  U_DataLink,U_RTFun,U_ZDYHelp;

{$R *.dfm}

procedure TfrmYGYPZZChkList_NXZZJL.FormDestroy(Sender: TObject);
begin
  frmYGYPZZChkList_NXZZJL:=nil;
end;

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

procedure TfrmYGYPZZChkList_NXZZJL.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('员工年薪记录表1',Tv1,'OA管理');
end;

procedure TfrmYGYPZZChkList_NXZZJL.InitGrid();
begin
  try
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select A.*');
      sql.Add(' from YF_Money_CR A');
      sql.Add(' where A.GZMonth>='''+Trim(uppercase(formatdateTime('yyyy-MM',BegDate.datetime)))+'''');
      sql.Add(' and A.GZMonth<='''+Trim(uppercase(formatdateTime('yyyy-MM',EndDate.datetime)))+'''');
      sql.Add(' and A.CRType=''工资'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmYGYPZZChkList_NXZZJL.InitForm();
begin
  EndDate.Date:=SGetServerDate(ADOQueryTemp);
  BegDate.Date:=EndDate.Date;
  ReadCxGrid('员工年薪记录表1',Tv1,'OA管理');
  InitGrid();
end;

procedure TfrmYGYPZZChkList_NXZZJL.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TfrmYGYPZZChkList_NXZZJL.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  TcxGridToExcel('员工年薪记录表',cxGrid1);
end;

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

procedure TfrmYGYPZZChkList_NXZZJL.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmYGYPZZChkList_NXZZJL.CheckBox1Click(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmYGYPZZChkList_NXZZJL.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmYGYPZZChkList_NXZZJL.CustomerNoNameChange(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TfrmYGYPZZChkList_NXZZJL.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main,True);
end;

procedure TfrmYGYPZZChkList_NXZZJL.N1Click(Sender: TObject);
begin
  SelOKNo(Order_Main,False);
end;

procedure TfrmYGYPZZChkList_NXZZJL.YGNameChange(Sender: TObject);
begin
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

end.
