unit u_info_kaoqin_report; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ComCtrls, bsSkinTabs, StdCtrls, wwdbdatetimepicker, RxLookup, DB, RxMemDS, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ADODB, dxDBTLCl, dxGrClms; type Tfrm_info_kaoqin_report = class(TForm) bsSkinPanel1: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; Label10: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label5: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; bsSkinButton1: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton5: TbsSkinButton; Label13: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; t_sum: TRxMemoryData; t_sum1: TDataSource; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column17: TdxDBGridMaskColumn; p_detail: TADOStoredProc; p_client1: TDataSource; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid2Column3: TdxDBGridDateColumn; dxDBGrid2Column4: TdxDBGridMaskColumn; dxDBGrid2Column5: TdxDBGridMaskColumn; dxDBGrid2Column6: TdxDBGridMaskColumn; dxDBGrid2Column7: TdxDBGridMaskColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_info_kaoqin_report: Tfrm_info_kaoqin_report; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_info_kaoqin_report.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_info_kaoqin_report.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_info_kaoqin_report.Hide; frm_info_kaoqin_report.ManualFloat(frm_info_kaoqin_report.BoundsRect ); frm_main.freeTabs('frm_info_kaoqin_report'); action:=cafree; frm_info_kaoqin_report:=nil; end; procedure Tfrm_info_kaoqin_report.bsSkinButton10Click(Sender: TObject); begin wwDBDateTimePicker1.text:=''; wwDBDateTimePicker2.text:=''; RxDBLookupCombo5.clearvalue; end; procedure Tfrm_info_kaoqin_report.bsSkinButton1Click(Sender: TObject); VAR STR:widestring; j,i:integer; Year, Month, Day: word; begin if (wwDBDateTimePicker1.text='')or(wwDBDateTimePicker2.text='')then begin showmessage('请输入开始结束日期!!'); exit; end; if wwDBDateTimePicker1.Date>wwDBDateTimePicker2.Date then begin showmessage('开始日期不能大于结束日期!!'); exit; end; DecodeDate(wwDBDateTimePicker1.date, Year, Month, Day); str:='where (DATEPART(Year,日期)*10000+DATEPART(month,日期)*100+DATEPART(day,日期))>=' +inttostr(Year*10000+month*100+day); DecodeDate(wwDBDateTimePicker2.date, Year, Month, Day); str:=str+' and (DATEPART(Year,日期)*10000+DATEPART(month,日期)*100+DATEPART(day,日期))<=' +inttostr(Year*10000+month*100+day); if RxDBLookupCombo5.DisplayValue<>''then str:=str+' and 职员='+''''+RxDBLookupCombo5.DisplayValue+''''; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'SELECT KQ_ID,职员,计算机, 类型, 日期,授权,授权人,' +'(case 授权 when '+''''+'是'+''''+' then null else ' +'(CASE 类型 WHEN '+''''+'上午签到'+''''+' THEN ' +'(CASE WHEN ((DATEPART(Hour, 日期))' +'* 100 + (DATEPART(minute, 日期)) >' +get_parameters_value(8,'830') +') THEN '+''''+'迟到'+''''+' ELSE null END) ' +'ELSE ' +'(CASE 类型 WHEN '+''''+'上午签退'+''''+' THEN (CASE WHEN ((DATEPART(Hour, 日期))' +'* 100 + (DATEPART(minute, 日期)) <' +get_parameters_value(24,'1200') +') THEN '+''''+'早退'+''''+' ELSE null END) ' +'ELSE ' +'(CASE 类型 WHEN '+''''+'下午签到'+''''+' THEN (CASE WHEN ((DATEPART(Hour, 日期))' +'* 100 + (DATEPART(minute, 日期)) >' +get_parameters_value(25,'1330') +') THEN '+''''+'迟到'+''''+' ELSE null END) ' +'ELSE ' +'(CASE 类型 WHEN '+''''+'下午签退'+''''+' THEN (CASE WHEN ((DATEPART(Hour, 日期))' +'* 100 + (DATEPART(minute, 日期)) <' +get_parameters_value(26,'1730') +') THEN '+''''+'早退'+''''+' ELSE null END) ' +'ELSE null END)END)END)END)end) AS 违规,' +'(ltrim(str(DATEPART(Year,日期)*10000+DATEPART(month,日期)*100+DATEPART(day,日期)))+类型+职员) as 标准 ' +'FROM t_info_kaoqin ' +str +' order by 日期,职员 desc'; p_detail.open; t_sum.close; t_sum.open; if p_detail.IsEmpty then exit; i:=Round(wwDBDateTimePicker2.date-wwDBDateTimePicker1.date); for j:=0 to i do begin DecodeDate(wwDBDateTimePicker1.date+j, Year, Month, Day); if RxDBLookupCombo5.DisplayValue=''then begin frm_data_share.t_sys_employee.first; while not frm_data_share.t_sys_employee.eof do begin if not t_sum.Locate('职员',frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin t_sum.insert; t_sum['职员']:=frm_data_share.t_sys_employee.fieldbyname('姓名').asstring; t_sum['上午签到迟到']:=0; t_sum['上午签到没签']:=0; t_sum['上午签到授权']:=0; t_sum['上午签退早退']:=0; t_sum['上午签退没签']:=0; t_sum['上午签退授权']:=0; t_sum['下午签到迟到']:=0; t_sum['下午签到没签']:=0; t_sum['下午签到授权']:=0; t_sum['下午签退早退']:=0; t_sum['下午签退没签']:=0; t_sum['下午签退授权']:=0; t_sum['合计迟到']:=0; t_sum['合计早退']:=0; t_sum['合计没签']:=0; t_sum['合计授权']:=0; t_sum.Post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签到'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['上午签到授权']:=t_sum['上午签到授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='迟到'then begin t_sum.edit; t_sum['上午签到迟到']:=t_sum['上午签到迟到']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['上午签到没签']:=t_sum['上午签到没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签退'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['上午签退授权']:=t_sum['上午签退授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='早退'then begin t_sum.edit; t_sum['上午签退早退']:=t_sum['上午签退早退']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['上午签退没签']:=t_sum['上午签退没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'下午签到'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['下午签到授权']:=t_sum['下午签到授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='迟到'then begin t_sum.edit; t_sum['下午签到迟到']:=t_sum['下午签到迟到']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['下午签到没签']:=t_sum['下午签到没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签退'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['下午签退授权']:=t_sum['下午签退授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='早退'then begin t_sum.edit; t_sum['下午签退早退']:=t_sum['下午签退早退']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['下午签退没签']:=t_sum['下午签退没签']+1; t_sum.post; end; frm_data_share.t_sys_employee.next; end; end else begin if frm_data_share.t_sys_employee.Locate('姓名',RxDBLookupCombo5.DisplayValue,[])then begin if not t_sum.Locate('职员',frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin t_sum.insert; t_sum['职员']:=frm_data_share.t_sys_employee.fieldbyname('姓名').asstring; t_sum['上午签到迟到']:=0; t_sum['上午签到没签']:=0; t_sum['上午签到授权']:=0; t_sum['上午签退早退']:=0; t_sum['上午签退没签']:=0; t_sum['上午签退授权']:=0; t_sum['下午签到迟到']:=0; t_sum['下午签到没签']:=0; t_sum['下午签到授权']:=0; t_sum['下午签退早退']:=0; t_sum['下午签退没签']:=0; t_sum['下午签退授权']:=0; t_sum['合计迟到']:=0; t_sum['合计早退']:=0; t_sum['合计没签']:=0; t_sum['合计授权']:=0; t_sum.Post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签到'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['上午签到授权']:=t_sum['上午签到授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='迟到'then begin t_sum.edit; t_sum['上午签到迟到']:=t_sum['上午签到迟到']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['上午签到没签']:=t_sum['上午签到没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签退'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['上午签退授权']:=t_sum['上午签退授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='早退'then begin t_sum.edit; t_sum['上午签退早退']:=t_sum['上午签退早退']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['上午签退没签']:=t_sum['上午签退没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'下午签到'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['下午签到授权']:=t_sum['下午签到授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='迟到'then begin t_sum.edit; t_sum['下午签到迟到']:=t_sum['下午签到迟到']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['下午签到没签']:=t_sum['下午签到没签']+1; t_sum.post; end; if p_detail.Locate('标准',inttostr(Year*10000+month*100+day)+'上午签退'+frm_data_share.t_sys_employee.fieldbyname('姓名').asstring,[])then begin if p_detail.FieldByName('授权').asstring='是'then begin t_sum.edit; t_sum['下午签退授权']:=t_sum['下午签退授权']+1; t_sum.post; end else begin if p_detail.FieldByName('违规').asstring='早退'then begin t_sum.edit; t_sum['下午签退早退']:=t_sum['下午签退早退']+1; t_sum.post; end; end; end else begin t_sum.edit; t_sum['下午签退没签']:=t_sum['下午签退没签']+1; t_sum.post; end; end; end; end; t_sum.first; while not t_sum.eof do begin t_sum.edit; t_sum['合计迟到']:=t_sum['上午签到迟到']+t_sum['下午签到迟到']; t_sum['合计早退']:=t_sum['上午签退早退']+t_sum['下午签退早退']; t_sum['合计没签']:=t_sum['上午签到没签']+t_sum['上午签退没签']+t_sum['下午签到没签']+t_sum['下午签退没签']; t_sum['合计授权']:=t_sum['上午签到授权']+t_sum['上午签退授权']+t_sum['下午签到授权']+t_sum['下午签退授权']; t_sum.post; t_sum.next; end; end; end.