📄 atdreport.pas
字号:
unit atdreport;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, ADODB, ppDB, ppBands, ppClass, ppCtrls, ppVar, ppPrnabl,
ppCache, ppProd, ppReport, Db, ppComm, ppRelatv, ppDBPipe, ppDBBDE,
ExtCtrls, ppModule, raCodMod;
type
TFormatdreport = class(TForm)
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
ADODataSet1: TADODataSet;
ppBDEPipeline1: TppBDEPipeline;
DataSource1: TDataSource;
ppReport2: TppReport;
ppHeaderBand1: TppHeaderBand;
ppLine1: TppLine;
ppLabel2: TppLabel;
ppLabel3: TppLabel;
ppLabel12: TppLabel;
ppLabel13: TppLabel;
ppLabel1: TppLabel;
ppLabel14: TppLabel;
ppLabel4: TppLabel;
ppDBText3: TppDBText;
ppLabel6: TppLabel;
ppLine3: TppLine;
ppDetailBand1: TppDetailBand;
ppDBText1: TppDBText;
ppDBText2: TppDBText;
ppDBText5: TppDBText;
ppDBText6: TppDBText;
ppDBText7: TppDBText;
ppDBText8: TppDBText;
ppDBText9: TppDBText;
ppDBText10: TppDBText;
ppDBText11: TppDBText;
ppDBText12: TppDBText;
ppFooterBand1: TppFooterBand;
ppLine2: TppLine;
ppSystemVariable1: TppSystemVariable;
ppSystemVariable2: TppSystemVariable;
ppGroup1: TppGroup;
ppGroupHeaderBand1: TppGroupHeaderBand;
ppGroupFooterBand1: TppGroupFooterBand;
ppLabel7: TppLabel;
ppLabel8: TppLabel;
ppLabel9: TppLabel;
ppDBCalc1: TppDBCalc;
ppDBCalc2: TppDBCalc;
ppDBCalc3: TppDBCalc;
ADOQuery1: TADOQuery;
ppLine5: TppLine;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Label4: TLabel;
ppBDEPipeline2: TppBDEPipeline;
MaskEdit3: TMaskEdit;
ppLabel28: TppLabel;
ppLabel10: TppLabel;
ppLabel11: TppLabel;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
ADODataSet3: TADODataSet;
DataSource3: TDataSource;
ppBDEPipeline3: TppBDEPipeline;
ppReport4: TppReport;
ppTitleBand1: TppTitleBand;
ppHeaderBand4: TppHeaderBand;
ppLabel50: TppLabel;
ppLabel51: TppLabel;
ppLabel52: TppLabel;
ppLabel54: TppLabel;
ppLabel56: TppLabel;
ppLabel57: TppLabel;
ppLabel58: TppLabel;
ppLabel60: TppLabel;
ppLabel61: TppLabel;
ppLabel62: TppLabel;
ppLabel63: TppLabel;
ppLabel64: TppLabel;
ppLabel65: TppLabel;
ppLabel66: TppLabel;
ppLabel67: TppLabel;
ppLabel68: TppLabel;
ppLabel69: TppLabel;
ppLabel70: TppLabel;
ppLabel71: TppLabel;
ppSystemVariable7: TppSystemVariable;
ppLabel72: TppLabel;
ppSystemVariable8: TppSystemVariable;
ppLine8: TppLine;
ppDetailBand4: TppDetailBand;
ppDBText40: TppDBText;
ppDBText41: TppDBText;
ppDBText42: TppDBText;
ppDBText44: TppDBText;
ppDBText46: TppDBText;
ppDBText47: TppDBText;
ppDBText49: TppDBText;
ppDBText50: TppDBText;
ppDBText51: TppDBText;
ppDBText52: TppDBText;
ppDBText53: TppDBText;
ppDBText54: TppDBText;
ppFooterBand4: TppFooterBand;
Adoatdmonth: TADODataSet;
Adoatdmonthworkno: TStringField;
Adoatdmonthcardno: TStringField;
Adoatdmonthname: TStringField;
Adoatdmonthsexname: TStringField;
Adoatdmonthprof: TStringField;
Adoatdmonthdeptno: TStringField;
Adoatdmonthdept: TStringField;
Adoatdmonthmonthy: TStringField;
Adoatdmonthmusthours: TBCDField;
Adoatdmonthfacthours: TBCDField;
Adoatdmontheveninghours: TBCDField;
Adoatdmonthlate: TBCDField;
Adoatdmonthearly: TBCDField;
Adoatdmonthkuanggong: TBCDField;
Adoatdmonthothours: TBCDField;
Adoatdmonthleavehave: TBCDField;
Dsatdmonth: TDataSource;
ppLabel73: TppLabel;
ppDBText55: TppDBText;
Panel1: TPanel;
RadioGroup1: TRadioGroup;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
ppReport5: TppReport;
ppHeaderBand5: TppHeaderBand;
ppDetailBand5: TppDetailBand;
ppFooterBand5: TppFooterBand;
ppGroup4: TppGroup;
ppGroupHeaderBand4: TppGroupHeaderBand;
ppGroupFooterBand4: TppGroupFooterBand;
ppGroup5: TppGroup;
ppGroupHeaderBand5: TppGroupHeaderBand;
ppGroupFooterBand5: TppGroupFooterBand;
ppLabel74: TppLabel;
ppLabel75: TppLabel;
ppLine10: TppLine;
ppLabel76: TppLabel;
ppLabel77: TppLabel;
ppLabel78: TppLabel;
ppDBText56: TppDBText;
ppLabel79: TppLabel;
ppLine11: TppLine;
ppLabel80: TppLabel;
ppLabel81: TppLabel;
ppLabel82: TppLabel;
ppLabel83: TppLabel;
ppDBText57: TppDBText;
ppDBText58: TppDBText;
ppDBText59: TppDBText;
ppDBText60: TppDBText;
ppDBText61: TppDBText;
ppDBText62: TppDBText;
ppDBText63: TppDBText;
ppDBText64: TppDBText;
ppDBText65: TppDBText;
ppDBText66: TppDBText;
ppDBText67: TppDBText;
ppDBText68: TppDBText;
ppLabel84: TppLabel;
ppLabel85: TppLabel;
ppDBCalc4: TppDBCalc;
ppDBCalc5: TppDBCalc;
ppLabel86: TppLabel;
ppLine12: TppLine;
ppSystemVariable9: TppSystemVariable;
ppSystemVariable10: TppSystemVariable;
ppReport1: TppReport;
ppHeaderBand2: TppHeaderBand;
ppDetailBand2: TppDetailBand;
ppFooterBand2: TppFooterBand;
ppSystemVariable3: TppSystemVariable;
ppSystemVariable4: TppSystemVariable;
ppDBText4: TppDBText;
ppDBText13: TppDBText;
ppDBText14: TppDBText;
ppDBText15: TppDBText;
ppDBText16: TppDBText;
ppDBText17: TppDBText;
ppDBText18: TppDBText;
ppDBText20: TppDBText;
ppDBText21: TppDBText;
ppDBText22: TppDBText;
ppDBText23: TppDBText;
ppDBText24: TppDBText;
ppLine6: TppLine;
ppLabel5: TppLabel;
ppLabel17: TppLabel;
ppLabel18: TppLabel;
ppLabel19: TppLabel;
ppLabel20: TppLabel;
ppLabel21: TppLabel;
ppLabel23: TppLabel;
ppLabel24: TppLabel;
ppLabel25: TppLabel;
ppLabel26: TppLabel;
ppLabel49: TppLabel;
ppLabel87: TppLabel;
ppLabel88: TppLabel;
ppLabel89: TppLabel;
ppLabel90: TppLabel;
ppSystemVariable5: TppSystemVariable;
ppLabel94: TppLabel;
ppLabel93: TppLabel;
ppLabel92: TppLabel;
ppLabel91: TppLabel;
ppSystemVariable6: TppSystemVariable;
ppLine4: TppLine;
ppDBPipeline1: TppDBPipeline;
raCodeModule1: TraCodeModule;
Adoatdmonthlatetimes: TIntegerField;
Adoatdmonthearlytimes: TIntegerField;
Adoatdmonthkuanggongtimes: TIntegerField;
Adoatdmonthotjieri: TBCDField;
Adoatdmonthotjiari: TBCDField;
Adoatdmonthsalok: TBooleanField;
Adoatdmonthhave: TBCDField;
Adoatdmonthnohave: TBCDField;
ppLabel15: TppLabel;
ppLabel16: TppLabel;
ppDBText19: TppDBText;
ppDBText25: TppDBText;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ppReport2BeforePrint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure RadioButton1Click(Sender: TObject);
procedure ppReport1BeforePrint(Sender: TObject);
procedure ppDBCalc9GetText(Sender: TObject; var Text: String);
procedure ppReport4BeforePrint(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure ppDBCalc5GetText(Sender: TObject; var Text: String);
procedure ppReport5BeforePrint(Sender: TObject);
procedure ppReport5PreviewFormCreate(Sender: TObject);
procedure ppReport1AfterPrint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function printcondition:string;
end;
var
Formatdreport: TFormatdreport;
implementation
uses main,atddata,datamol,publicfunction;
{$R *.DFM}
procedure TFormatdreport.FormCreate(Sender: TObject);
begin
maskedit1.text:=formatdatetime('yyyy/mm/dd',now);
maskedit2.text:=maskedit1.text;
maskedit3.text:=formatdatetime('yyyy/mm',now);
with datamod do
begin
Query1.close;
Query1.sql.text:='Select dept from pub05010';
Query1.Open;
Combobox1.items.clear;
while not Query1.eof do
begin
combobox1.items.add(Query1.fieldbyname('dept').asstring);
Query1.next;
end;
Query1.close;
Query1.sql.text:='Select profname from per01010';
Query1.Open;
Combobox2.items.clear;
while not Query1.eof do
begin
combobox2.items.add(Query1.fieldbyname('profname').asstring);
Query1.next;
end;
Query1.close;
end;
end;
procedure TFormatdreport.Button2Click(Sender: TObject);
begin
close;
end;
procedure TFormatdreport.ppReport2BeforePrint(Sender: TObject);
begin
pplabel14.caption:=maskedit1.text+'…'+maskedit2.text;
end;
procedure TFormatdreport.Button1Click(Sender: TObject);
var s:string;
fmat1:string;
begin
if fmat='/' then
fmat1:=' / / ';
if fmat='-' then
fmat1:=' - - ';
s:=printcondition;
if radiobutton1.checked then //每日工时表
begin
panel1.visible:=true;
panel1.update;
adoquery1.Close;
adoquery1.sql.text:='exec sj_dayreport '''+maskedit1.text+''','''+maskedit2.text+''' ';
adoquery1.execsql;
adodataset1.close;
if s<>'' then
adodataset1.commandtext:='select * from report_day where '+s+' order by dept,workno,rq';
adodataset1.open;
ppreport2.DeviceType:='Screen';
ppreport2.print;
end else if radiobutton2.checked then //每月工时表
begin
panel1.visible:=true;
panel1.update;
adoquery1.close;
adoquery1.SQL.text:='exec sj_dayreport '''+maskedit3.text+'/01'+''','''+maskedit3.text+'/'+inttostr(Getdays(copy(maskedit3.text,6,2),copy(maskedit3.text,1,4)))+''' ';
adoquery1.execsql;
adodataset1.close;
if s<>'' then
adodataset1.commandtext:='select * from report_day where '+s+' order by dept,workno,rq';
adodataset1.open;
ppreport5.DeviceType:='Screen';
ppreport5.print;
end else if radiobutton3.checked then //
begin
if (maskedit1.text<>fmat1) and (maskedit2.text<>fmat1) then
begin
adodataset3.Close;
adodataset3.CommandText:='Select * from Vatd32010 where rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''')';
adodataset3.Open;
pplabel18.Caption:=maskedit1.text+'~~'+maskedit2.Text;
end;
ppReport1.devicetype:='Screen';
ppreport1.print;
end else if radiobutton4.checked then
begin
Adoatdmonth.Close;
Adoatdmonth.CommandText:='select * from vatd34010 where monthy='''+maskedit3.text+''' ';
Adoatdmonth.open;
ppReport4.devicetype:='Screen';
ppreport4.print;
end;
panel1.visible:=false;
end;
procedure TFormatdreport.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
selectnext(activecontrol,true,true);
end;
end;
procedure TFormatdreport.RadioButton1Click(Sender: TObject);
begin
if radiobutton1.Checked or radiobutton3.checked then
begin
label3.visible:=true;
maskedit1.visible:=true;
maskedit2.visible:=true;
maskedit3.visible:=false;
label1.caption:='请输入开始日期和结束日期';
label1.update;
label2.caption:='开始';
end else if radiobutton2.Checked or radiobutton4.checked then
begin
label1.Caption:='请输入欲列印的月份';
label1.update;
label2.caption:='月份';
label2.update;
maskedit3.visible:=true;
maskedit2.Visible:=false;
maskedit1.visible:=false;
label3.visible:=false;
end;
end;
procedure TFormatdreport.ppReport1BeforePrint(Sender: TObject);
begin
pplabel5.Caption:=companyname1;
pplabel94.Caption:=pubworkname;
end;
procedure TFormatdreport.ppDBCalc9GetText(Sender: TObject; var Text: String);
begin
pplabel86.caption:='出勤天数:'+floattostr(strtofloat(text)/8);
end;
procedure TFormatdreport.ppReport4BeforePrint(Sender: TObject);
begin
pplabel57.caption:=MaskEdit3.text;
pplabel65.Caption:=companyname1;
pplabel70.Caption:=pubworkname;
end;
procedure TFormatdreport.Edit1Exit(Sender: TObject);
begin
edit2.text:=edit1.text;
end;
function TFormatdreport.printcondition:string;
begin
case RadioGroup1.itemindex of
0:result:='';
1:if combobox1.items.indexof(combobox1.text)<>-1 then result:='dept='''+combobox1.text+''' ';
2:if combobox2.items.indexof(combobox2.text)<>-1 then result:='prof='''+combobox2.text+''' ';
3:if (trim(edit1.text)<>'') and (trim(edit2.text)<>'') then result:='workno between '''+edit1.text+''' and '''+edit2.text+''' ';
end;
end;
procedure TFormatdreport.ppDBCalc5GetText(Sender: TObject; var Text: String);
begin
pplabel86.caption:='出勤天数:'+floattostr(strtofloat(text)/8);
end;
procedure TFormatdreport.ppReport5BeforePrint(Sender: TObject);
begin
pplabel75.caption:='月份:'+maskedit3.text;
end;
procedure TFormatdreport.ppReport5PreviewFormCreate(Sender: TObject);
begin
tppReport(Sender).PreviewForm.WindowState:=wsMaximized;
end;
procedure TFormatdreport.ppReport1AfterPrint(Sender: TObject);
begin
adodataset1.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -