一个简单的考勤系统[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 txlicenhe 的 blog

 [name] varchar(10),
 calendarflag int check(calendarflag in (1,2,3) ),   -- 1,2,3分别表示工作日历中的标志1,标志2,标志3
 worktimeid int       -- 排班表中的班制
)
go
exec sp_addextendedproperty n'ms_description', n'工号', n'user', n'dbo', n'table', n'employee', n'column', n'workno'
exec sp_addextendedproperty n'ms_description', n'姓名', n'user', n'dbo', n'table', n'employee', n'column', n'name'
exec sp_addextendedproperty n'ms_description', n'工作日历方式', n'user', n'dbo', n'table', n'employee', n'column', n'calendarflag'
exec sp_addextendedproperty n'ms_description', n'班制', n'user', n'dbo', n'table', n'employee', n'column', n'worktimeid'

/*
calendarflag  1,2,3分别表示工作日历中的标志1,标志2,标志3
worktimeid   对应排班表中的班制
*/


--4:异常类别表abnormity
create table abnormity(
 abnormityno int primary key clustered,
 [description] varchar(10)
)
go
exec sp_addextendedproperty n'ms_description', n'异常类别', n'user', n'dbo', n'table', n'abnormity', n'column', n'abnormityno'
exec sp_addextendedproperty n'ms_description', n'异常说明', n'user', n'dbo', n'table', n'abnormity', n'column', n'description'

/**************
异常包括:迟到(还可细分成迟到的时间段),早退,无刷卡...
当然可能还有扣薪方式之类的,此处不予考虑。
*****************/

 

 

5:考勤记录表timecard
create table timecard(
 workno char(6),
 [date] datetime,
 constraint [pk_timecard] primary key clustered
 (
  workno,
  [date]
 )  on [primary]
)
go
exec sp_addextendedproperty n'ms_description', n'工号', n'user', n'dbo', n'table', n'timecard', n'column', n'workno'
exec sp_addextendedproperty n'ms_description', n'打卡时间', n'user', n'dbo', n'table', n'timecard', n'column', n'date'

/*******
其实我实际中是按卡号(对应工号),日期,时间,卡钟号  四个字段来存的。
*******/

 


/****************如下处理得到 考勤明细表1:**********/
--1.创建一个合并的函数
create  function f_kqlist(@workno char(6),@date char(8))
returns varchar(400)
as
begin
declare @str varchar(1000)
set @str=''
select @str=@str+'/'+ convert(char(8),[date],108) from timecard
 where workno = @workno and datediff(day,[date], @date) = 0
set @str=right(@str,len(@str)-1)
return(@str)
end

/*   usage:  
    select distinct workno,date,dbo.f_kqlist(workno,[date])
        from timecard
 where workno = '102337' and convert(char(8),[date],112) = '20030814'
*/

剩下的留给大家吧。其实也不难,就看谁的效率比较高一些罢了。  :d
(我的做法:  异常处理   :   用存储过程,用游标做的,懒得去优化了

本文关键:考勤
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top