unit U_WorkDeptFeeChkList_KF;

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, cxCalendar, cxButtonEdit, cxSplitter,
  RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
  cxTextEdit, cxPC, cxCheckBox, Menus;

type
  TfrmWorkDeptFeeChkList_KF = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    Order_Sub: TClientDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    ToolButton2: TToolButton;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    CDS_Chker: TClientDataSet;
    v1KFQty: TcxGridDBColumn;
    DataSource2: TDataSource;
    v1KFName: TcxGridDBColumn;
    CDS_PRT: TClientDataSet;
    v1DJDate: TcxGridDBColumn;
    ADOQueryHZ: TADOQuery;
    v1YGName: TcxGridDBColumn;
    v1KFType: TcxGridDBColumn;
    Label3: TLabel;
    YGName: TEdit;
    v1KFNote: TcxGridDBColumn;
    Label4: TLabel;
    KFQty: TEdit;
    Label5: TLabel;
    KFName: TEdit;
    TADD: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    TCK: TToolButton;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure TADDClick(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure TCKClick(Sender: TObject);
  private
    FInt,PFInt:Integer;
    canshu1,canshu2:string;
    procedure InitGrid();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmWorkDeptFeeChkList_KF: TfrmWorkDeptFeeChkList_KF;

implementation
uses
  U_DataLink,U_RTFun,U_ModuleNote,U_WorkerDeptFeeInPut, U_ZDYHelpSel,U_WorkerDeptFeeInPut_DJ;

{$R *.dfm}

procedure TfrmWorkDeptFeeChkList_KF.FormDestroy(Sender: TObject);
begin
  frmWorkDeptFeeChkList_KF:=nil;
end;

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

procedure TfrmWorkDeptFeeChkList_KF.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('员工分数登记',Tv1,'费用管理');
end;

procedure TfrmWorkDeptFeeChkList_KF.InitGrid();
var FJieCunMoney: Double;
    Fint: integer;
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select * from OA_DangAn_KF');
      sql.add('where DJDate>='''+formatdatetime('yyyy-MM-dd',Begdate.DateTime)+'''');
      sql.add(' and DJDate<'''+formatdatetime('yyyy-MM-dd',Enddate.DateTime+1)+''' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally;
    ADOQueryMain.EnableControls;
  end; 
end;

procedure TfrmWorkDeptFeeChkList_KF.TBExportClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  TcxGridToExcel('员工分数登记',cxGrid1);
end;

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

procedure TfrmWorkDeptFeeChkList_KF.FormShow(Sender: TObject);
begin
  ReadCxGrid('员工分数登记',Tv1,'费用管理');
  endDate.Date:=SGetServerDate(ADOQueryTemp);
  BegDate.Date:=EndDate.Date-7;
  InitGrid();
end;

procedure TfrmWorkDeptFeeChkList_KF.FormCreate(Sender: TObject);
begin
  canshu1:=Trim(DParameters1);
  canshu2:=Trim(DParameters2);
end;

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

procedure TfrmWorkDeptFeeChkList_KF.TADDClick(Sender: TObject);
begin
  frmWorkerDeptFeeInPut_DJ:=TfrmWorkerDeptFeeInPut_DJ.Create(Application);
  with frmWorkerDeptFeeInPut_DJ do
  begin
    PState:=0;
    FMainId:='';
    if ShowModal=1 then
    begin
      initGrid();
    end;
    Free;
  end;
end;

procedure TfrmWorkDeptFeeChkList_KF.ToolButton3Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then exit;
  frmWorkerDeptFeeInPut_DJ:=TfrmWorkerDeptFeeInPut_DJ.Create(Application);
  with frmWorkerDeptFeeInPut_DJ do
  begin
    PState:=1;
    FMainId:=trim(Order_Main.fieldbyname('KFID').AsString);
    if ShowModal=1 then
    begin
      initGrid();
    end;
    Free;
  end;
end;

procedure TfrmWorkDeptFeeChkList_KF.ToolButton4Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  if Application.MessageBox('确定要删除吗','提示',1)=2 then exit;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    sql.add('delete from OA_DangAn_KF ');
    sql.add('where KFID='''+trim(Order_Main.fieldbyname('KFID').AsString)+'''');
    ExecSQL;
  end;
  Order_Main.Delete;
end;

procedure TfrmWorkDeptFeeChkList_KF.TCKClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then exit;
  frmWorkerDeptFeeInPut_DJ:=TfrmWorkerDeptFeeInPut_DJ.Create(Application);
  with frmWorkerDeptFeeInPut_DJ do
  begin
    PState:=1;
    FMainId:=trim(Order_Main.fieldbyname('KFID').AsString);
    ToolBar1.Visible:=false;
    if ShowModal=1 then
    begin
      initGrid();
    end;
    Free;
  end;
end;

end.
