unit U_CP_COL_XL; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, DBClient, DB, ADODB, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView, cxControls, cxGridCustomView, cxClasses, cxGridLevel, cxGrid, cxGridDBTableView, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator; type TfrmCP_COL_XL = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBClose: TToolButton; Panel1: TPanel; Label1: TLabel; Label4: TLabel; Label9: TLabel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; P_CodeName: TEdit; ConNoM: TEdit; Label2: TLabel; ADOQueryMain: TADOQuery; DS_Main: TDataSource; CDS_main: TClientDataSet; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; Tv1: TcxGridDBBandedTableView; v1Column1: TcxGridDBBandedColumn; v1Column2: TcxGridDBBandedColumn; v1Column3: TcxGridDBBandedColumn; v1Column4: TcxGridDBBandedColumn; v1Column5: TcxGridDBBandedColumn; v1Column6: TcxGridDBBandedColumn; v1Column7: TcxGridDBBandedColumn; v1Column8: TcxGridDBBandedColumn; v1Column9: TcxGridDBBandedColumn; v1Column10: TcxGridDBBandedColumn; v1Column11: TcxGridDBBandedColumn; v1Column12: TcxGridDBBandedColumn; v1Column13: TcxGridDBBandedColumn; v1Column14: TcxGridDBBandedColumn; v1Column15: TcxGridDBBandedColumn; v1Column16: TcxGridDBBandedColumn; v1Column17: TcxGridDBBandedColumn; v1Column18: TcxGridDBBandedColumn; P_color: TEdit; Label3: TLabel; TBexcel: TToolButton; GroupBox1: TGroupBox; TV2: TcxGridDBTableView; cxGrid2Level1: TcxGridLevel; cxGrid2: TcxGrid; V2Column1: TcxGridDBColumn; V2Column2: TcxGridDBColumn; V2Column3: TcxGridDBColumn; V2Column4: TcxGridDBColumn; V2Column5: TcxGridDBColumn; V2Column6: TcxGridDBColumn; ADO_Sub: TADOQuery; DS_sub: TDataSource; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure P_CodeNameChange(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBexcelClick(Sender: TObject); procedure Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); private procedure InitGrid(); procedure initSub(); { Private declarations } public canshu1:string; { Public declarations } end; var frmCP_COL_XL: TfrmCP_COL_XL; implementation uses U_DataLink,U_Fun10; {$R *.dfm} procedure TfrmCP_COL_XL.Initsub(); begin ADO_Sub.Close; IF CDS_Main.IsEmpty then exit; with ADO_Sub do begin close; sql.Clear; sql.Add('select * from YF_money_CR '); sql.Add('where CRTime>='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' '); sql.Add('and CRTime<'''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' '); sql.Add('and P_CodeName='+quotedstr(trim(CDS_Main.fieldbyName('P_CodeName').AsString))); sql.Add('and P_Color='+quotedstr(trim(CDS_Main.fieldbyName('P_Color').AsString))); sql.Add('and SYRName='''+trim(canshu1)+''''); sql.Add('and CRType=''应收款登记'' '); sql.Add('order by CRTime desc '); open; end; end; procedure TfrmCP_COL_XL.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; Filtered:=False; sql.Clear; sql.Add(' exec P_Get_CP_col_Xl '); SQL.Add(' @begdate='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''''); SQL.Add(',@enddate='''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''''); Open; end; SCreateCDS20(ADOQueryMain,CDS_Main); SInitCDSData20(ADOQueryMain,CDS_Main); finally ADOQueryMain.EnableControls; end; TBfind.Click; Initsub(); end; procedure TfrmCP_COL_XL.FormDestroy(Sender: TObject); begin frmCP_COL_XL:=nil; end; procedure TfrmCP_COL_XL.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=cafree; end; procedure TfrmCP_COL_XL.FormCreate(Sender: TObject); begin enddate.DateTime:=now(); begdate.DateTime:=enddate.DateTime-30; cxGrid1.Align:=alclient; canshu1:=trim(DParameters1); end; procedure TfrmCP_COL_XL.TBCloseClick(Sender: TObject); begin close; end; procedure TfrmCP_COL_XL.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active=False then Exit; SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS20(ADOQueryMain,CDS_Main); SInitCDSData20(ADOQueryMain,CDS_Main); end; procedure TfrmCP_COL_XL.P_CodeNameChange(Sender: TObject); begin TBfind.Click; end; procedure TfrmCP_COL_XL.TBRafreshClick(Sender: TObject); begin initGrid(); end; procedure TfrmCP_COL_XL.FormShow(Sender: TObject); begin IF trim(canshu1)='桂华纺织'then begin tv1.Bands[2].Visible:=false; tv1.Bands[3].Visible:=false; tv1.Bands[4].Visible:=false; end; IF trim(canshu1)='尚美特'then begin tv1.Bands[1].Visible:=false; tv1.Bands[3].Visible:=false; tv1.Bands[4].Visible:=false; end; IF trim(canshu1)='金鼎丰门市部'then begin tv1.Bands[1].Visible:=false; tv1.Bands[2].Visible:=false; tv1.Bands[4].Visible:=false; end; end; procedure TfrmCP_COL_XL.TBexcelClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; TcxGridToExcel(self.Caption,cxGrid1); end; procedure TfrmCP_COL_XL.Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin Initsub(); end; end.