unit U_Cust_Cloth_PSC; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, MovePanel, cxButtonEdit, cxCalendar, RM_System, RM_Common, RM_Class, RM_GridReport, RM_Dataset, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu; type TfrmCust_Cloth_PS = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBExport: TToolButton; TBPrint: TToolButton; TBClose: TToolButton; Panel1: TPanel; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; cxGridPopupMenu1: TcxGridPopupMenu; Label3: TLabel; C_Name: TEdit; Label1: TLabel; Label2: TLabel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; CDS_Main: TClientDataSet; cxGrid2Level1: TcxGridLevel; cxGrid2: TcxGrid; MovePanel2: TMovePanel; Label10: TLabel; RMGridReport1: TRMGridReport; FromCoName: TEdit; Label13: TLabel; TV1: TcxGridDBBandedTableView; TV1Column1: TcxGridDBBandedColumn; TV1Column2: TcxGridDBBandedColumn; TV1Column3: TcxGridDBBandedColumn; TV1Column8: TcxGridDBBandedColumn; TV1Column9: TcxGridDBBandedColumn; TV1Column11: TcxGridDBBandedColumn; TV1Column12: TcxGridDBBandedColumn; TV1Column14: TcxGridDBBandedColumn; TV1Column15: TcxGridDBBandedColumn; ThreeColorBase: TcxStyleRepository; SHuangSe: TcxStyle; SkyBlue: TcxStyle; Default: TcxStyle; QHuangSe: TcxStyle; Red: TcxStyle; FontBlue: TcxStyle; TextSHuangSe: TcxStyle; FonePurple: TcxStyle; FoneClMaroon: TcxStyle; FoneRed: TcxStyle; RowColor: TcxStyle; handBlack: TcxStyle; cxBlue: TcxStyle; cxStyle1: TcxStyle; RMDBMain: TRMDBDataSet; Label6: TLabel; Saleser: TEdit; TV1Column10: TcxGridDBBandedColumn; TV1Column4: TcxGridDBBandedColumn; TV1Column5: TcxGridDBBandedColumn; TV1Column6: TcxGridDBBandedColumn; TV1Column7: TcxGridDBBandedColumn; TV1Column13: TcxGridDBBandedColumn; TV1Column17: TcxGridDBBandedColumn; TV1Column18: TcxGridDBBandedColumn; TV1Column20: TcxGridDBBandedColumn; TV1Column16: TcxGridDBBandedColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ConNoMChange(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure C_NameChange(Sender: TObject); procedure PRTColorChange(Sender: TObject); procedure TBPrintClick(Sender: TObject); private FLeft, FTop: Integer; procedure InitGrid(); { Private declarations } public { Public declarations } end; var frmCust_Cloth_PS: TfrmCust_Cloth_PS; implementation uses U_DataLink, U_RTFun, U_ZDYHelp; {$R *.dfm} procedure TfrmCust_Cloth_PS.FormDestroy(Sender: TObject); begin inherited; frmCust_Cloth_PS := nil; end; procedure TfrmCust_Cloth_PS.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmCust_Cloth_PS.FormCreate(Sender: TObject); begin inherited; EndDate.DateTime := SGetServerDateTime(ADOQueryTemp); BegDate.DateTime := EndDate.DateTime - 30; end; procedure TfrmCust_Cloth_PS.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; sql.Clear; Filtered := False; sql.Add('EXEC P_Dye_Cust_Cloth_PSC '); sql.Add('@begdate=''' + formatdateTime('yyyy-MM-dd', begdate.DateTime) + ''' '); sql.Add(',@enddate=''' + formatdateTime('yyyy-MM-dd', enddate.DateTime + 1) + ''' '); // ShowMessage(sql.Text); Open; end; SCreateCDS(ADOQueryMain, CDS_Main); SInitCDSData(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmCust_Cloth_PS.TBRafreshClick(Sender: TObject); begin MovePanel2.Visible := True; MovePanel2.Refresh; InitGrid(); MovePanel2.Visible := False; end; procedure TfrmCust_Cloth_PS.ConNoMChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); end; end; procedure TfrmCust_Cloth_PS.TBCloseClick(Sender: TObject); begin WriteCxBandedGrid(self.Caption + tv1.Name, Tv1, '成品仓库'); Close; end; procedure TfrmCust_Cloth_PS.FormShow(Sender: TObject); begin inherited; ReadCxBandedGrid(self.Caption + tv1.Name, Tv1, '成品仓库'); end; procedure TfrmCust_Cloth_PS.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; TcxGridToExcel(self.Caption, cxgrid2); // TcxGridToExcel(self.Caption,cxGrid2); end; procedure TfrmCust_Cloth_PS.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_Main); SInitCDSData(ADOQueryMain, CDS_Main); end; end; procedure TfrmCust_Cloth_PS.C_NameChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmCust_Cloth_PS.PRTColorChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmCust_Cloth_PS.TBPrintClick(Sender: TObject); var fPrintFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\统计报表.rmf'; if FileExists(fPrintFile) then begin RMGridReport1.LoadFromFile(fPrintFile); //MVariables['SYRName']:=Trim(SYRName); RMVariables['begdate'] := formatdateTime('yyyy-MM-dd', begdate.DateTime); RMVariables['enddate'] := formatdateTime('yyyy-MM-dd', enddate.DateTime); RMGridReport1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + trim(fPrintFile)), '提示', 0); end; end; end.