unit U_YSSKList;

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, cxPC;

type
  TfrmYSSKList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    ToolButton1: TToolButton;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    Label3: TLabel;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    Label2: TLabel;
    Label6: TLabel;
    begdate: TDateTimePicker;
    Enddate: TDateTimePicker;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    v2USDSQMoney: TcxGridDBColumn;
    v2FactoryName: TcxGridDBColumn;
    v2USDYFMoney: TcxGridDBColumn;
    v2USDFKMoney: TcxGridDBColumn;
    v2USDBQMoney: TcxGridDBColumn;
    Label1: TLabel;
    ComTaiTou: TEdit;
    Label4: TLabel;
    FHAddress: TEdit;
    Label5: TLabel;
    FHdq: TEdit;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    V1FactoryName: TcxGridDBColumn;
    cxSplitter1: TcxSplitter;
    FactoryName: TComboBox;
    TKP: TToolButton;
    ToolButton3: TToolButton;
    cxTabControl1: TcxTabControl;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure FactoryNameChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure TV1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure TKPClick(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
  private
    { Private declarations }
    procedure InitGrid();
  public
    fDParameters1:string;
    { Public declarations }
    RKFlag,FCYID:String;

  end;

var
  frmYSSKList: TfrmYSSKList;

implementation
uses
  U_DataLink,U_Fun,U_ZDYHelp,U_YSSKList_KP;

{$R *.dfm}



procedure TfrmYSSKList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      if cxTabControl1.TabIndex=0 then
        sql.Add(' exec P_YSSK_List_TJ :begdate,:Enddate')
      else
        SQL.Add(' exec P_YSSK_List :begdate,:Enddate');
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime));
      Parameters.ParamByName('Enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1));
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  finally
    ADOQueryMain.EnableControls;
  end;
  ToolButton2.Click;
end;


procedure TfrmYSSKList.FormDestroy(Sender: TObject);
begin
  frmYSSKList:=nil;
end;

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

procedure TfrmYSSKList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('应收收款统计',Tv2,'财务管理');
  WriteCxGrid('应收收款统计1',Tv2,'财务管理');
  Close;
end;
procedure TfrmYSSKList.FormShow(Sender: TObject);
var fsj:string;
begin
  ReadCxGrid('应收收款统计',Tv2,'财务管理');
  ReadCxGrid('应收收款统计1',Tv2,'财务管理');
  Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
  begdate.DateTime:=Enddate.DateTime;
  fsj:='select distinct (A.FactoryName) name from YF_Money_CR A where A.CRType=''应收款登记'' ';
  SInitComBoxBySql(ADOQueryCmd,FactoryName,False,fsj);
  if Trim(DParameters5)='开票' then
  begin
  //  v2BQKP.Hidden:=False;
  //  v2BQKP.Visible:=True;
 //   v2WKP.Hidden:=False;
 //   v2WKP.Visible:=True;
  end else
  begin
  //  v2BQKP.Hidden:=True;
  //  v2BQKP.Visible:=False;
  //  v2WKP.Hidden:=True;
  //  v2WKP.Visible:=False;
  end;
  {if Trim(DParameters9)='支付台头' then
  begin
    v2GSTT.Hidden:=False;
    v2GSTT.Visible:=True;
    Label1.Visible:=True;
    ComTaiTou.Visible:=True;
  end else
  begin
    v2GSTT.Hidden:=True;
    v2GSTT.Visible:=False;
    Label1.Visible:=False;
    ComTaiTou.Visible:=False;
  end; }

  //InitGrid();
end;

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

procedure TfrmYSSKList.ToolButton2Click(Sender: TObject);
var
  fsj:string;
begin
  if ADOQueryMain.Active=False then Exit;

  SDofilter(ADOQueryMain,Trim(SGetFilters(Panel1,1,2)));
  SCreateCDS20(ADOQueryMain,CDS_HZ);
  SInitCDSData20(ADOQueryMain,CDS_HZ);
end;

procedure TfrmYSSKList.FactoryNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmYSSKList.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  SelExportData(Tv2,ADOQueryMain,'应收收款美金统计列表');
end;

procedure TfrmYSSKList.TV1CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  TKP.Click;
end;

procedure TfrmYSSKList.TKPClick(Sender: TObject);
begin
  frmYSSKList_KP:=TfrmYSSKList_KP.create(self);
  with frmYSSKList_KP do
  begin
    frmYSSKList_KP.FFactoryName:=trim(self.CDS_HZ.fieldbyname('FactoryName').AsString);
    if showmodal=1 then
    begin
      
    end;
    free;
  end;
end;

procedure TfrmYSSKList.ToolButton3Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  SelExportData(Tv1,ADOQueryMain,'应收收款人民币统计列表');
end;

procedure TfrmYSSKList.cxTabControl1Change(Sender: TObject);
begin
  TBRafresh.Click;
end;

end.
