我想做个值班表,要求如下:
日期 星期 1组 2组 3组 4组
2008年4月7日 星期一 a1 b1 c1 d1
2008年4月8日 星期二 a1 b2 c2 d2
2008年4月9日 星期三 a2 b3 c3 d3
2008年4月10日 星期四 a2 b1 c4 d4
2008年4月11日 星期五 a3 b2 c5 d5
2008年4月12日 星期六 a3 b3 c6 d6
2008年4月13日 星期日 a1 b1 c1 d1
就这样,
1组中有三个人,一人两天轮流值班
2组中有三个人,一人一天轮流值班
3组中有六个人,一人一天轮流值班
4组中有六个人,一人一天轮流值班
大家帮我想个思路
用ASP怎么做出这个值班表来呀,。
我的思路:
值班数据库 ,zdate(值班时间),person(值班人),sign(标志,如果为2,a组换人)
1。先读出上一条值班的数据:
dim person,sign
dim p,n,pp,maxp,newp
rs。
open "select top 1 * from zhiban order by id desc",conn,1,1
if rs。 eof then
person="a1,b1,c1,d1,"
sign=1
n=1
else
person=rs("person")
sign=rs("sign")
end if
ose
p=split(person,",")
n=int(replace(p(i),pp)))+1
for i=0 to ubound(p)
pp=left(p(i),1)
if pp="a" then
if sign=1 then
n=n-1
sign=sign+1
else
sign=1
end if
maxp=3
end if
if pp="b" then maxp=3
if pp="c" then maxp=6
if pp="d" then maxp=6
if n>maxp or n="" then n=1
newp=newp&pp&n&","
next
'数据处理完存进数据库
rs。
open "select * from zhiban where id is null",conn,1,3
dnew
rs("person")=newp
rs("zdate")=now() '或其他时间
rs。
update
ose
>>>数据处理好了,建个表把a1-d6对应每个人的名字,调出来就好了
>>>人在外面,代码在记事本上随手打的,没调试,不过按这个思路应该没问题的
>>>当然感觉这不是最好的方法,应该还有更好的。
。