unit U_SKCRFenPei;

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;

type
  TfrmSKCRFenPei = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    Label1: TLabel;
    YFName: TEdit;
    ADOQueryMain: TADOQuery;
    Label3: TLabel;
    FactoryName: TEdit;
    Label2: TLabel;
    Label6: TLabel;
    begdate: TDateTimePicker;
    Enddate: TDateTimePicker;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Label4: TLabel;
    OrderNo: TEdit;
    Label8: TLabel;
    HZFactoryName: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    VDate: TcxGridDBColumn;
    VFTYName: TcxGridDBColumn;
    v2Column5: TcxGridDBColumn;
    VYFName: TcxGridDBColumn;
    VPayMent: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    v2Column9: TcxGridDBColumn;
    v2Column8: TcxGridDBColumn;
    VYB: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    v2Column3: TcxGridDBColumn;
    v2Column10: TcxGridDBColumn;
    v2Column11: TcxGridDBColumn;
    v2Column4: TcxGridDBColumn;
    VNote: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    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 Tv2CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
  private
    { Private declarations }

    procedure InitGrid();

  public
    { Public declarations }
    KHName:String;

  end;

var
  frmSKCRFenPei: TfrmSKCRFenPei;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}



procedure TfrmSKCRFenPei.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      sql.Add(' select A.* ');
      sql.Add('  from YF_Money_CR A');
      sql.Add('where  A.CRType=''收款登记'' and isnull(WFPMoney,0)<>0 and isnull(Money,0)>0');
      sql.add(' and FactoryNo='''+Trim(KHName)+'''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmSKCRFenPei.FormDestroy(Sender: TObject);
begin
  frmSKCRFenPei:=nil;
end;

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

procedure TfrmSKCRFenPei.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('收款分配1',Tv2,'财务管理');
  Close;
end;
procedure TfrmSKCRFenPei.FormShow(Sender: TObject);
begin
  ReadCxGrid('收款分配1',Tv2,'财务管理');
  InitGrid();
end;

procedure TfrmSKCRFenPei.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;
procedure TfrmSKCRFenPei.ToolButton2Click(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmSKCRFenPei.Tv2CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  ModalResult:=1;
end;

end.
