unit U_XJMonthList;

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, cxDropDownEdit, cxPC, RM_e_Xls, Menus, ComObj;

type
  FdDy = record
    inc: integer; //客户端套接字句柄
    FDdys: string[32]; //客户端套接字
    FdDysName: string[32]; //客户端套接字
  end;

  TfrmXJMonthList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ADOQueryMain: TADOQuery;
    ToolButton1: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    Label2: TLabel;
    begdate: TDateTimePicker;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_FP: TDataSource;
    CDS_FP: TClientDataSet;
    v1InvoiceDate: TcxGridDBColumn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    v1Column10: TcxGridDBColumn;
    cxTabControl1: TcxTabControl;
    v1Column3: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
  private
    { Private declarations }
    procedure InitGrid();
  public

    { Public declarations }
  end;

var
  frmXJMonthList: TfrmXJMonthList;

implementation

uses
  U_DataLink, U_Fun, U_XJBXInPut;

{$R *.dfm}



procedure TfrmXJMonthList.InitGrid();
begin
  try
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_Qty_XJ_Month :begdate,:syrname');
      Parameters.ParamByName('begdate').Value:=Trim(formatdatetime('yyyy', begdate.datetime));
      Parameters.ParamByName('syrname').Value:=Trim(cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_FP);
    SInitCDSData20(ADOQueryMain, CDS_FP);
  finally

  end;
end;

procedure TfrmXJMonthList.FormDestroy(Sender: TObject);
begin
  frmXJMonthList := nil;
end;

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

procedure TfrmXJMonthList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('报销管理Month', Tv1, '财务管理');
  Close;
end;

procedure TfrmXJMonthList.FormShow(Sender: TObject);
begin
  ReadCxGrid('报销管理Month', Tv1, '财务管理');
  begdate.DateTime := SGetServerDate(ADOQueryTemp);
  //InitGrid();
end;

procedure TfrmXJMonthList.TBRafreshClick(Sender: TObject);
begin
  begdate.SetFocus;
  InitGrid();
end;

procedure TfrmXJMonthList.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  TcxGridToExcel(self.Caption, cxgrid1);
end;

procedure TfrmXJMonthList.cxTabControl1Change(Sender: TObject);
begin
  initGrid();
end;

procedure TfrmXJMonthList.Tv1DblClick(Sender: TObject);
begin
  {if CDS_FP.IsEmpty then Exit;
  if CDS_FP.fieldbyname('InvoiceNo').AsInteger=-1 then
  begin
    frmXJBXInPut := TfrmXJBXInPut.Create(self);
    with frmXJBXInPut do
    begin
      InvoiceNo.Enabled := False;
      FInvoiceNo := trim(CDS_FP.fieldbyname('InvoiceNo').asstring);
      ToolBar2.Visible:=False;
      frmXJBXInPut.TSave.Visible:=False;
      if showmodal = 1 then
      begin
        
      end;
      free;
    end;
  end; }
end;

end.

