123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmAttendanceReport">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="考勤报告";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- ChangeMode("Search");
- ]]>
- </Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search"/>
- </Search>
- </Mode>
- <Controls>
- <IKDateTimePicker name="dtStart" DataSource="UI.StartDate">
- <Events>
- <ValueChanged>
- dtEnd.CValue = dtStart.CValue;
- </ValueChanged>
- </Events>
- </IKDateTimePicker>
- <IKDateTimePicker name="dtEnd" DataSource="UI.EndDate"/>
-
- <IKTextButton name="tbEmployee1" DataSource="UI.StartNo_Employee">
- <Events>
- <Click>
- <![CDATA[
- @temp = ShowSearchBox("EmployeeSearch","INFOMATION",tbEmployee1.CValue);
- if( @temp == "" )
- return;
- tbEmployee1.CValue = @temp;
- ]]>
- </Click>
- <TextBoxButtonTextChanged>
- tbEmployee2.CValue = tbEmployee1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbEmployee2" DataSource="UI.EndNo_Employee" >
- <Events>
- <Click>
- <![CDATA[
- @temp = ShowSearchBox("EmployeeSearch","INFOMATION",tbEmployee2.CValue);
- if( @temp == "" )
- return;
- tbEmployee2.CValue = @temp;
- ]]>
- </Click>
- </Events>
- </IKTextButton>
- <IKButton name="btnView">
- <Events>
- <Click>
- @ClickType="View";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnExcel">
- <Events>
- <Click>
- @ClickType="Excel";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- @ClickType="Word";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- @ClickType="PrintToPrinter";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- </Controls>
- <ChildForms>
- <ChildForm name="EmployeeSearch" DataSource="Employee" SearchFunction="SearchAllEmployee" SearchFunctionByNo="" MappingName="员工" >
- <DataColumn Index="0" MappingName="#Employee.No_Employee" HeaderText="员工编号" Width="90" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="1" MappingName="#Employee.Name_Employee" HeaderText="员工名称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- </ChildForm>
- </ChildForms>
- </Client>
- <Server>
- <Tables>
- <Table name="UI" Type="Parent">
- <GetSchema CmdType="Text" CmdText="SELECT TOP 0 convert(datetime,0) As StartDate,convert(datetime,0) As EndDate,Convert(nvarchar(64),'') As StartNo_Employee,Convert(nvarchar(64),'') As EndNo_Employee
- ,convert(nvarchar(64),'') As Name_Creator,convert(datetime,0) As CreateDate, Convert(bit,1) As Combine"/>
- </Table>
- </Tables>
- <Search>
- <SearchAttendanceReport CmdType="Text" CmdText="
-
- --CREATE FUNCTION dbo.TimeDiff(@date1 as datetime, @date2 as datetime)
- --RETURNS int
- --BEGIN
- -- return (DatePart(hour,@date2)-DatePart(hour,@date1))*60.0+DatePart(minute,@date2)-DatePart(minute,@date1)
- --end
-
- -- CREATE FUNCTION dbo.GetAttendanceHour
- --(@OnStuffOne as datetime
- --,@OffStuffOne as datetime
- --,@OnStuffTwo as datetime
- --,@OffStuffTwo as datetime
- --,@OnAttendance as datetime
- --,@OffAttendance as datetime
- --)
- --RETURNS decimal(14,1)
- --BEGIN
- -- Declare @AttendanceHour decimal(14,1)
- -- IF(dbo.TimeDiff(@OnAttendance,@OnStuffOne)>0)
- -- BEGIN
- -- IF(dbo.TimeDiff(@OffAttendance,@OnStuffOne)>0)
- -- Set @AttendanceHour=0
- -- Else IF (dbo.TimeDiff(@OffAttendance,@OffStuffOne)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffOne,@OffAttendance)/60.0)
- -- Else if (dbo.TimeDiff(@OffAttendance,@OnStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffOne,@OffStuffOne))
- -- else if(dbo.TimeDiff(@OffAttendance,@OffStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffAttendance))/60.0)
- -- else
- -- Set @AttendanceHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- -- END
- -- Else IF(dbo.TimeDiff(@OnAttendance,@OffStuffOne)>0)
- -- BEGIN
- -- IF (dbo.TimeDiff(@OffAttendance,@OffStuffOne)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnAttendance,@OffAttendance)/60.0)
- -- Else if (dbo.TimeDiff(@OffAttendance,@OnStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnAttendance,@OffStuffOne)/60.0)
- -- else if(dbo.TimeDiff(@OffAttendance,@OffStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnAttendance,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffAttendance))/60.0)
- -- else
- -- Set @AttendanceHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnAttendance,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- -- END
- -- else if(dbo.TimeDiff(@OnAttendance,@OnStuffTwo)>0)
- -- BEGIN
- -- IF (dbo.TimeDiff(@OffAttendance,@OnStuffTwo)>0)
- -- Set @AttendanceHour=0
- -- Else if (dbo.TimeDiff(@OffAttendance,@OffStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffTwo,@OffAttendance)/60.0)
- -- else
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo)/60.0)
- -- END
- -- else if(dbo.TimeDiff(@OnAttendance,@OffStuffTwo)>0)
- -- BEGIN
- -- IF (dbo.TimeDiff(@OffAttendance,@OffStuffTwo)>0)
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnAttendance,@OffAttendance)/60.0)
- -- else
- -- Set @AttendanceHour=Convert(decimal(14,1),dbo.TimeDiff(@OnAttendance,@OffStuffTwo)/60.0)
- -- END
- -- else
- -- Set @AttendanceHour=0
- -- return @AttendanceHour
- --end
- --Declare @StartDate datetime
- --Declare @EndDate datetime
- --Declare @StartNo_Employee nvarchar(64)
- --Declare @EndNo_Employee nvarchar(64)
- Declare @ID_Applicant uniqueidentifier
- Declare @No_ApplicationBill nvarchar(64)
- Declare @Item_ApplicationBill nvarchar(64)
- Declare @StartDate_ApplicationBill datetime
- Declare @EndDate_ApplicationBill datetime
- Declare @OnStuffOne datetime
- Declare @OffStuffOne datetime
- Declare @OnStuffTwo datetime
- Declare @OffStuffTwo datetime
- Declare @AppHour decimal(14,1)
- Declare @LoopDate datetime
- IF Exists (Select * From tempdb.dbo.sysobjects Where id=Object_ID(N'tempdb.dbo.#TempApp'))
- DROP TABLE #TempApp
- Create Table #TempApp
- (
- ID_Applicant uniqueidentifier,
- Date varchar(10),
- OvertimeHour decimal(14,1),
- BusinessHour decimal(14,1),
- CompassionateHour decimal(14,1),
- SickHour decimal(14,1),
- SalaryHour decimal(14,1),
- exception bit,
- Comment nvarchar(256)
- )
- Declare cur cursor
- for
- Select ApplicationBillEmployee.ID_Employee As ID_Applicant,No_ApplicationBill,Item_ApplicationBill,StartDate_ApplicationBill,EndDate_ApplicationBill
- ,OnStuffOne,OffStuffOne,OnStuffTwo,OffStuffTwo
- From dbo.ApplicationBill
- Join dbo.ApplicationBillEmployee On ApplicationBillEmployee.ID_ApplicationBill=ApplicationBill.ID_ApplicationBill
- Join dbo.AttendanceRuleEmployee On ApplicationBillEmployee.ID_Employee=dbo.AttendanceRuleEmployee.ID_Employee
- Join dbo.AttendanceRule On AttendanceRuleEmployee.ID_AttendanceRule=AttendanceRule.ID_AttendanceRule
- Join Employee ON Employee.ID_Employee=dbo.AttendanceRuleEmployee.ID_Employee
- Where ApplicationBill.ID_Assessor Is Not Null
- And No_Employee Between IsNull(@StartNo_Employee,No_Employee) And IsNull(@EndNo_Employee,No_Employee)
- And DateDiff(day,@StartDate,EndDate_ApplicationBill)>=0 And DateDiff(day,@EndDate,StartDate_ApplicationBill)<=0
- Open cur
- Fetch Next From cur Into @ID_Applicant,@No_ApplicationBill,@Item_ApplicationBill,@StartDate_ApplicationBill,@EndDate_ApplicationBill
- ,@OnStuffOne,@OffStuffOne,@OnStuffTwo,@OffStuffTwo
- while @@fetch_status=0
- BEGIN
- Set @LoopDate=@StartDate_ApplicationBill
- while(DateDiff(day,@LoopDate,@EndDate_ApplicationBill)>=0)
- BEGIN
- IF(DateDiff(day,@StartDate,@LoopDate)>=0 and DateDiff(day,@EndDate,@LoopDate)<=0)
- BEGIN
- IF(DateDiff(day,@StartDate_ApplicationBill,@LoopDate)>0 and DateDiff(day,@EndDate_ApplicationBill,@LoopDate)<0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- Else IF(DateDiff(day,@StartDate_ApplicationBill,@LoopDate)=0)
- BEGIN
- IF(DateDiff(day,@EndDate_ApplicationBill,@LoopDate)<0)
- BEGIN
- IF(dbo.TimeDiff(@LoopDate,@OnStuffOne)>0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- Else IF(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)>0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- else if(dbo.TimeDiff(@StartDate_ApplicationBill,@OnStuffTwo)>0)
- Set @AppHour=dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo)
- else if(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffTwo)/60.0
- else
- Set @AppHour=0
- END
- Else
- BEGIN
- IF(dbo.TimeDiff(@StartDate_ApplicationBill,@OnStuffOne)>0)
- BEGIN
- IF(dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffOne)>0)
- Set @AppHour=0
- Else IF (dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffOne)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffOne,@EndDate_ApplicationBill)/60.0)
- Else if (dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffOne,@OffStuffOne))
- else if(dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@EndDate_ApplicationBill))/60.0)
- else
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- END
- Else IF(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)>0)
- BEGIN
- IF (dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffOne)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@StartDate_ApplicationBill,@EndDate_ApplicationBill)/60.0)
- Else if (dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)/60.0)
- else if(dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@EndDate_ApplicationBill))/60.0)
- else
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- END
- else if(dbo.TimeDiff(@StartDate_ApplicationBill,@OnStuffTwo)>0)
- BEGIN
- IF (dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffTwo)>0)
- Set @AppHour=0
- Else if (dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffTwo,@EndDate_ApplicationBill)/60.0)
- else
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo)/60.0)
- END
- else if(dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffTwo)>0)
- BEGIN
- IF (dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@StartDate_ApplicationBill,@EndDate_ApplicationBill)/60.0)
- else
- Set @AppHour=Convert(decimal(14,1),dbo.TimeDiff(@StartDate_ApplicationBill,@OffStuffTwo)/60.0)
- END
- else
- Set @AppHour=0
- END
- END
- ELSE
- BEGIN
- IF(dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffOne)>0)
- Set @AppHour=0
- Else IF(dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffOne)>0)
- Set @AppHour=dbo.TimeDiff(@OnStuffOne,@EndDate_ApplicationBill)/60.0
- else if(dbo.TimeDiff(@EndDate_ApplicationBill,@OnStuffTwo)>0)
- Set @AppHour=dbo.TimeDiff(@OnStuffOne,@OffStuffOne)/60.0
- else if(dbo.TimeDiff(@EndDate_ApplicationBill,@OffStuffTwo)>0)
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@EndDate_ApplicationBill))/60.0)
- else
- Set @AppHour=Convert(decimal(14,1),(dbo.TimeDiff(@OnStuffOne,@OffStuffOne)+dbo.TimeDiff(@OnStuffTwo,@OffStuffTwo))/60.0)
- END
-
- IF(Not Exists (Select * From #TempApp Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)))
- BEGIN
- IF(@Item_ApplicationBill='加班')
- Insert Into #TempApp(ID_Applicant,Date,OvertimeHour,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),@AppHour,'加班:'+@No_ApplicationBill)
- else if(@Item_ApplicationBill='出差')
- Insert Into #TempApp(ID_Applicant,Date,BusinessHour,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),@AppHour,'出差:'+@No_ApplicationBill)
- else if(@Item_ApplicationBill='事假')
- Insert Into #TempApp(ID_Applicant,Date,CompassionateHour,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),@AppHour,'事假:'+@No_ApplicationBill)
- else if(@Item_ApplicationBill='病假')
- Insert Into #TempApp(ID_Applicant,Date,SickHour,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),@AppHour,'病假:'+@No_ApplicationBill)
- else if(@Item_ApplicationBill='带薪假')
- Insert Into #TempApp(ID_Applicant,Date,SalaryHour,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),@AppHour,'带薪假:'+@No_ApplicationBill)
- else if(@Item_ApplicationBill='打卡异常')
- Insert Into #TempApp(ID_Applicant,Date,exception,Comment)
- Values(@ID_Applicant,convert(varchar(10),@LoopDate,120),1,'打卡异常:'+@No_ApplicationBill)
- END
- else
- Begin
- IF(@Item_ApplicationBill='加班')
- Update #TempApp Set OvertimeHour=IsNull(OvertimeHour,0)+@AppHour,Comment=Comment+' 加班:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- else if(@Item_ApplicationBill='出差')
- Update #TempApp Set BusinessHour=IsNull(BusinessHour,0)+@AppHour,Comment=Comment+' 出差:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- else if(@Item_ApplicationBill='事假')
- Update #TempApp Set CompassionateHour=IsNull(CompassionateHour,0)+@AppHour,Comment=Comment+' 事假:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- else if(@Item_ApplicationBill='病假')
- Update #TempApp Set SickHour=IsNull(SickHour,0)+@AppHour,Comment=Comment+' 病假:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- else if(@Item_ApplicationBill='带薪假')
- Update #TempApp Set SalaryHour=IsNull(SalaryHour,0)+@AppHour,Comment=Comment+' 带薪假:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- else if(@Item_ApplicationBill='打卡异常')
- Update #TempApp Set exception=1,Comment=Comment+' 打卡异常:'+@No_ApplicationBill Where ID_Applicant=@ID_Applicant And Date=convert(varchar(10),@LoopDate,120)
- End
-
- END
- Set @LoopDate=DateAdd(day,1,@LoopDate)
- END
- Fetch Next From cur Into @ID_Applicant,@No_ApplicationBill,@Item_ApplicationBill,@StartDate_ApplicationBill,@EndDate_ApplicationBill
- ,@OnStuffOne,@OffStuffOne,@OnStuffTwo,@OffStuffTwo
- END
- Close cur
- Deallocate cur
- ---------------------------------------------------------------------------------------------------
- Select No_Employee,Name_Employee,Name_Department,EmployeeInfo.Date,case WeekDay_HolidaySetting when 1 then '日' when 2 then '一' when 3 then '二' when 4 then '三' when 5 then '四' when 6 then '五' else '六' end As WeekDay,Type_HolidaySetting,Name_AttendanceRule,StuffHour
- ,OnAttendance,OffAttendance
- --,OnAttendanceTwo,OffAttendanceTwo
- ,case Type_HolidaySetting when '工作日' then
- case when exception=1 then StuffHour
- else AttendanceHour end
- else null end As AttendanceHour
- ,case when #TempApp.OvertimeHour>StuffHour then StuffHour
- else #TempApp.OvertimeHour end As OvertimeHour
- ,case when #TempApp.BusinessHour>StuffHour then StuffHour
- else #TempApp.BusinessHour end As BusinessHour
- ,case when Type_HolidaySetting='工作日' then
- case when #TempApp.CompassionateHour>StuffHour then StuffHour
- else #TempApp.CompassionateHour end
- else null end As CompassionateHour
- ,case when Type_HolidaySetting='工作日' then
- case when #TempApp.SickHour>StuffHour then StuffHour
- else #TempApp.SickHour end
- else null end As SickHour
- ,case when Type_HolidaySetting='工作日' then
- case when #TempApp.SalaryHour>StuffHour then StuffHour
- else #TempApp.SalaryHour end
- else null end As SalaryHour
- ,case when Type_HolidaySetting='工作日' then
- case when exception=1 then null
- else
- case when (StuffHour-IsNull(AttendanceHour,0)-IsNull(BusinessHour,0)-IsNull(CompassionateHour,0)-IsNull(SickHour,0)-IsNull(SalaryHour,0)
- -case when dbo.TimeDiff(OnStuffOne,OnAttendance) <=30 and dbo.TimeDiff(OnStuffOne,OnAttendance)>0 then dbo.TimeDiff(OnStuffOne,OnAttendance) else 0 end
- -case when dbo.TimeDiff(OffAttendance,OffStuffTwo)<30 and dbo.TimeDiff(OffAttendance,OffStuffTwo)>0 then dbo.TimeDiff(OffAttendance,OffStuffTwo) else 0 end ) >0 then
- (StuffHour-IsNull(AttendanceHour,0)-IsNull(BusinessHour,0)-IsNull(CompassionateHour,0)-IsNull(SickHour,0)-IsNull(SalaryHour,0)
- -case when dbo.TimeDiff(OnStuffOne,OnAttendance) <=30 and dbo.TimeDiff(OnStuffOne,OnAttendance)>0 then dbo.TimeDiff(OnStuffOne,OnAttendance) else 0 end
- -case when dbo.TimeDiff(OffAttendance,OffStuffTwo)<30 and dbo.TimeDiff(OffAttendance,OffStuffTwo)>0 then dbo.TimeDiff(OffAttendance,OffStuffTwo) else 0 end )
- else null end
- end
- else null end As AbsentHour
- ,case when Type_HolidaySetting='工作日' And OnAttendance Is Not Null then
- case when exception=1 then null
- else
- case when dbo.TimeDiff(OnStuffOne,OnAttendance)<=ArriveLate_AttendanceRule or dbo.TimeDiff(OnStuffOne,OnAttendance)>30 then null
- else (dbo.TimeDiff(OnStuffOne,OnAttendance)-ArriveLate_AttendanceRule) end
- end
- else null end As ArriveLateMinute
- ,case when Type_HolidaySetting='工作日' And OnAttendance Is Not Null then
- case when exception=1 then null
- else
- case when dbo.TimeDiff(OffAttendance,OffStuffTwo)<=LeaveEarly_AttendanceRule or dbo.TimeDiff(OffAttendance,OffStuffTwo)>30 then null
- else dbo.TimeDiff(OffAttendance,OffStuffTwo)-LeaveEarly_AttendanceRule end
- end
- else null end As LeaveEarlyMinute
- ,Comment
- From
- (
- Select a.*,dbo.GetAttendanceHour(OnStuffOne,OffStuffOne,OnStuffTwo,OffStuffTwo,OnAttendance,OffAttendance) As AttendanceHour
- From
- (
- Select EmployeeCalendar.ID_Employee,No_Employee,Name_Employee,Name_Department,convert(varchar(10),Date_HolidaySetting,120) As Date,WeekDay_HolidaySetting,Type_HolidaySetting,Name_AttendanceRule
- ,(Select Top 1 Date_AttendanceRecord From dbo.AttendanceRecord Join Employee On Employee.CardNo_Employee=AttendanceRecord.No_Card Where Employee.ID_Employee=EmployeeCalendar.ID_Employee And DateDiff(day,Date_AttendanceRecord,EmployeeCalendar.Date_HolidaySetting)=0 Order By Date_AttendanceRecord) As OnAttendance
- ,(Select Top 1 Date_AttendanceRecord From dbo.AttendanceRecord Join Employee On Employee.CardNo_Employee=AttendanceRecord.No_Card Where Employee.ID_Employee=EmployeeCalendar.ID_Employee And DateDiff(day,Date_AttendanceRecord,EmployeeCalendar.Date_HolidaySetting)=0 Order By Date_AttendanceRecord desc) As OffAttendance
- ,OnStuffOne,OffStuffOne,OnStuffTwo,OffStuffTwo,ArriveLate_AttendanceRule,LeaveEarly_AttendanceRule,TakeOff_AttendanceRule
- ,Convert(decimal(14,1),(dbo.TimeDiff(OnStuffOne,OffStuffOne)+dbo.TimeDiff(OnStuffTwo,OffStuffTwo))/60.0) As StuffHour
- From
- (
- Select *
- From Employee,HolidaySetting
- Where No_Employee Between IsNull(@StartNo_Employee,No_Employee) And IsNull(@EndNo_Employee,No_Employee)
- And DateDiff(day,@StartDate,Date_HolidaySetting)>=0 And DateDiff(day,@EndDate,Date_HolidaySetting)<=0
- )EmployeeCalendar
- Left Join Department On Department.ID_Department=EmployeeCalendar.ID_Department
- Join dbo.AttendanceRuleEmployee On AttendanceRuleEmployee.ID_Employee=EmployeeCalendar.ID_Employee
- Left Join dbo.AttendanceRule On AttendanceRule.ID_AttendanceRule=dbo.AttendanceRuleEmployee.ID_AttendanceRule
- )a
- )EmployeeInfo
- Left Join #TempApp On #TempApp.ID_Applicant=EmployeeInfo.ID_Employee And #TempApp.Date=EmployeeInfo.Date
- Order By No_Employee,EmployeeInfo.Date
- ">
- <Params>
- <Param name="@StartDate" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@StartNo_Employee" type="Product.No_Product" Index="2" />
- <Param name="@EndNo_Employee" type="Product.No_Product" Index="3" />
- </Params>
- <Tables>
- <Table name="AttendanceReport"/>
- </Tables>
- </SearchAttendanceReport>
- <SearchAllEmployee CmdType="Text" CmdText="SELECT Employee.No_Employee,Employee.Name_Employee FROM Employee ">
- <Tables>
- <Table name="AllEmployee" />
- </Tables>
- </SearchAllEmployee>
- </Search>
- </Server>
- <Lables>
- <Search>
- Empty();
- NewInstance();
- </Search>
- <Action>
- <![CDATA[
- UpdateForm(false,"");
- #UI.Name_Creator = GetCurrentUser();
- #UI.CreateDate = GetCurrentTime();
- #UI.Combine=ckCombine.Checked;
- @StartNo_Employee=tbEmployee1.CValue==""?DBNull():tbEmployee1.CValue;
- @EndNo_Employee=tbEmployee2.CValue==""?DBNull():tbEmployee2.CValue;
- Search("SearchAttendanceReport",dtStart.Value,dtEnd.Value,@StartNo_Employee,@EndNo_Employee);
- if(RowCount("#AttendanceReport")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- switch(@ClickType)
- {
- case "View":
- PrintReport("UIFrmAttendanceReport","UI","AttendanceReport");
- break;
- default:
- ExportReport(@ClickType,"UIFrmAttendanceReport","UI","AttendanceReport");
- break;
- }
- }
- ]]>
- </Action>
- </Lables>
- </Form>
- </Forms>
|