238 lines
6.4 KiB
ObjectPascal
238 lines
6.4 KiB
ObjectPascal
unit U_CP_CRC;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
|
||
cxGridCustomView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, DBClient,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Common, RM_Class, RM_e_Xls,
|
||
RM_GridReport, RM_System, RM_Dataset, cxCheckBox, cxCalendar,
|
||
cxGridBandedTableView, cxGridDBBandedTableView, Buttons;
|
||
|
||
type
|
||
TfrmCP_CRC = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
Tqry: TToolButton;
|
||
Tprint: TToolButton;
|
||
Txls: TToolButton;
|
||
tclose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
begdate: TDateTimePicker;
|
||
enddate: TDateTimePicker;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxGrid1: TcxGrid;
|
||
ADOQueryTmp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Panetime: TPanel;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
RMDBDataSet1: TRMDBDataSet;
|
||
RMGridReport1: TRMGridReport;
|
||
RMXLSExport1: TRMXLSExport;
|
||
Label7: TLabel;
|
||
userID: TEdit;
|
||
Label8: TLabel;
|
||
userName: TEdit;
|
||
Label3: TLabel;
|
||
ComboBox1: TComboBox;
|
||
begTime: TDateTimePicker;
|
||
endTime: TDateTimePicker;
|
||
Label2: TLabel;
|
||
Label4: TLabel;
|
||
dept: TComboBox;
|
||
TV1: TcxGridDBBandedTableView;
|
||
V1Column2: TcxGridDBBandedColumn;
|
||
V1Column3: TcxGridDBBandedColumn;
|
||
V1Column6: TcxGridDBBandedColumn;
|
||
V1Column7: TcxGridDBBandedColumn;
|
||
V1Column8: TcxGridDBBandedColumn;
|
||
V1Column9: TcxGridDBBandedColumn;
|
||
V1Column10: TcxGridDBBandedColumn;
|
||
V1Column11: TcxGridDBBandedColumn;
|
||
V1Column12: TcxGridDBBandedColumn;
|
||
V1Column13: TcxGridDBBandedColumn;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label9: TLabel;
|
||
C_Color: TEdit;
|
||
C_CodeName: TEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TqryClick(Sender: TObject);
|
||
procedure TxlsClick(Sender: TObject);
|
||
procedure tcloseClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TprintClick(Sender: TObject);
|
||
procedure userIDChange(Sender: TObject);
|
||
private
|
||
fstr1:string;
|
||
fstr2:string;
|
||
procedure DoQuery();
|
||
procedure FilterData();
|
||
{ Private declarations }
|
||
public
|
||
istyjp:boolean;
|
||
fdept:string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmCP_CRC: TfrmCP_CRC;
|
||
|
||
implementation
|
||
uses U_Fun10,U_DataLink;
|
||
{$R *.dfm}
|
||
|
||
|
||
procedure TfrmCP_CRC.DoQuery();
|
||
var
|
||
mBegdate,mEnddate:string;
|
||
i:integer;
|
||
begin
|
||
mbegdate:=FormatDateTime('yyyy-MM-dd',begdate.Date);//+' '+FormatDateTime('HH:nn',begTime.Time);
|
||
menddate:=FormatDateTime('yyyy-MM-dd',enddate.Date+1);//+' '+FormatDateTime('HH:nn',endTime.Time);
|
||
screen.Cursor:=crsqlwait;
|
||
Panetime.Visible:=true;
|
||
Panetime.Left:=(Width-Panetime.Width) div 2;
|
||
Panetime.top:=(Height-Panetime.Height-200) div 2;
|
||
application.ProcessMessages;
|
||
|
||
try
|
||
with adoqueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
filtered:=false;
|
||
sql.Add(' exec P_Get_CP_CRC ');
|
||
sql.Add(' @begdate='+quotedstr(trim(mbegdate)));
|
||
sql.Add(',@Enddate='+quotedstr(trim(menddate)));
|
||
sql.Add(',@otherwhere='+quotedstr(trim('')));
|
||
open;
|
||
end;
|
||
FilterData();
|
||
finally
|
||
Panetime.Visible:=false;
|
||
screen.Cursor:=crdefault;
|
||
end;
|
||
end;
|
||
procedure TfrmCP_CRC.FilterData();
|
||
var
|
||
filterStr:string;
|
||
begin
|
||
filterStr:='';
|
||
if trim(dept.Text)<>'' then
|
||
filterStr:=filterStr+' and dept like '+quotedstr('%'+trim(dept.Text)+'%');
|
||
if trim(userID.Text)<>'' then
|
||
filterStr:=filterStr+' and userID like '+quotedstr('%'+trim(userID.Text)+'%');
|
||
if trim(userName.Text)<>'' then
|
||
filterStr:=filterStr+' and UserName like '+quotedstr('%'+trim(userName.Text)+'%');
|
||
if trim(C_Color.Text)<>'' then
|
||
filterStr:=filterStr+' and C_Color like '+quotedstr('%'+trim(C_Color.Text)+'%');
|
||
if trim(C_Codename.Text)<>'' then
|
||
filterStr:=filterStr+' and C_Codename like '+quotedstr('%'+trim(C_Codename.Text)+'%');
|
||
|
||
try
|
||
ADOQueryTmp.DisableControls ;
|
||
if trim(filterStr)='' then
|
||
begin
|
||
ADOQueryTmp.Filtered:=false;
|
||
ADOQueryTmp.EnableControls;
|
||
exit;
|
||
end;
|
||
filterStr:=trim(Copy(filterStr,5,length(filterStr)-4));
|
||
with ADOQueryTmp do
|
||
begin
|
||
filtered:=false;
|
||
filter:=filterStr;
|
||
filtered:=true;
|
||
end;
|
||
finally
|
||
ADOQueryTmp.EnableControls;
|
||
end;
|
||
end;
|
||
procedure TfrmCP_CRC.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmCP_CRC:=nil;
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
writeCxBandedGrid(self.Caption+tv1.Name,tv1,'<27>ۺϲ<DBBA>ѯ');
|
||
action:=cafree;
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.TqryClick(Sender: TObject);
|
||
begin
|
||
DoQuery();
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.TxlsClick(Sender: TObject);
|
||
begin
|
||
if adoquerytmp.IsEmpty then exit;
|
||
TcxGridToExcel(self.Caption,cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.tcloseClick(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.FormCreate(Sender: TObject);
|
||
begin
|
||
cxgrid1.Align:=alClient;
|
||
enddate.Date:=date();
|
||
begdate.Date:=date();
|
||
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.FormShow(Sender: TObject);
|
||
begin
|
||
writeCxBandedGrid(self.Caption+tv1.Name,tv1,'<27>ۺϲ<DBBA>ѯ');
|
||
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.TprintClick(Sender: TObject);
|
||
var
|
||
filepath:string;
|
||
mBegdate,mEnddate:string;
|
||
begin
|
||
mbegdate:=FormatDateTime('yyyy-MM-dd',begdate.Date)+' '+FormatDateTime('HH:nn',begTime.Time);
|
||
menddate:=FormatDateTime('yyyy-MM-dd',enddate.Date)+' '+FormatDateTime('HH:nn',endTime.Time);
|
||
if ADOQueryTmp.IsEmpty then exit;
|
||
try
|
||
filepath:=ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><DEB9><EFBFBD><EFBFBD>˱<EFBFBD>.rmf';
|
||
if not FileExists(Pchar(filepath)) then
|
||
begin
|
||
application.MessageBox(pchar('<27>ļ<EFBFBD>['+filepath+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
|
||
exit;
|
||
end;
|
||
RMVariables.Clear;
|
||
RMVariables['dtxz'] :=FormatDateTime('yyyy-mm-dd',DServerDate);
|
||
RmVariables['begDate'] :=FormatDateTime('yyyy-mm-dd',begDate.Date);
|
||
RmVariables['enddate'] :=FormatDateTime('yyyy-mm-dd',enddate.Date);
|
||
RMVariables['zdr'] :=trim(DName);
|
||
RMVariables['fstr1'] :=trim(fstr1);
|
||
RMVariables['fstr2'] :=trim(fstr2);
|
||
RmVariables['begDate'] :=mbegdate+' - '+menddate;
|
||
RmVariables['Title'] :=trim(dept.Text);
|
||
RMGridReport1.LoadFromFile(filepath);
|
||
// RMGridReport1.PrintReport;
|
||
RMGridReport1.ShowReport;
|
||
|
||
finally
|
||
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmCP_CRC.userIDChange(Sender: TObject);
|
||
begin
|
||
FilterData();
|
||
end;
|
||
|
||
end.
|