以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]制作值班表?代码应该怎么写? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96243) |
||||
-- 作者:fengwenliuyan -- 发布时间:2017/2/16 10:55:00 -- [求助]制作值班表?代码应该怎么写? 制作值班表? 按系统日期排序,8个人(张三、李四、王五、赵六、陈七、林八、方一、田二)轮流值班, 比如,设计状态栏显示“今天是(张三)值班,明天是(李四)值班”,然后,到了次日显示“今天是(李四)值班,明天是(王五)值班”,依次类推。。。 这样的代码应该怎么写?
|
||||
-- 作者:有点色 -- 发布时间:2017/2/16 11:16:00 -- Dim dt As DataTable = DataTables("表A") StatusBar.Message1 = str |
||||
-- 作者:fengwenliuyan -- 发布时间:2017/2/16 14:10:00 -- 可以用啊,但是怎么循环呀?8人一轮,依次类推,怎么改? 可以用啊,但是怎么循环呀?8人一轮,依次类推,怎么改? |
||||
-- 作者:有点色 -- 发布时间:2017/2/16 14:19:00 -- 比如,可以动态生成。
Dim sd As Date = Date.Today |
||||
-- 作者:fengwenliuyan -- 发布时间:2017/2/16 14:58:00 -- [求助]昨天是谁值班,怎么写???新的项目已上传!
Dim sd As Date = Date.Today Dim ed As Date = Date.today.Adddays(7) Dim ary() As String = {"张三", "李四", "王五","赵六","陈七","林八","方一","田二"} Dim sidx As Integer = 0 \'从张三开始 Dim d As Date = sd Do While d <= ed Dim nr As Row = Tables("表a").AddNew nr("日期") = d nr("姓名") = ary(((d-sd).Days+sidx) Mod 8) d = d.AddDays(1) Loop Dim dt As DataTable = DataTables("表A") Dim fdr As DataRow = dt.Find("日期 = #" & Date.today & "#") Dim str As String = "" If fdr IsNot Nothing Then str &= "今天:" & fdr("姓名") Else str &= "今天:没人" End If fdr = dt.Find("日期 = #" & Date.today.adddays(1) & "#") If fdr IsNot Nothing Then str &= ",明天:" & fdr("姓名") Else str &= ",明天:没人" End If fdr = dt.Find("日期 = #" & Date.today.adddays(2) & "#") If fdr IsNot Nothing Then str &= ",后天:" & fdr("姓名") Else str &= ",后天:没人" End If StatusBar.Message1 = str [此贴子已经被作者于2017/2/16 15:00:24编辑过]
|
||||
-- 作者:有点色 -- 发布时间:2017/2/16 19:02:00 -- Dim dr As DataRow = DataTables("表A").Find("", "日期 desc") Dim ed As Date = Date.today.Adddays(9) Dim d As Date = sd |
||||
-- 作者:fengwenliuyan -- 发布时间:2017/2/16 20:04:00 -- 不全了一下,把“昨天”的信息放上去了! Dim dr As DataRow = DataTables("表A").Find("", "日期 desc") Dim ary() As String = {"张三", "李四", "王五","赵六","陈七","林八","方一","田二"} Dim sidx As Integer = 0 Dim sd As Date If dr Is Nothing Then sidx = 0 sd = Date.Today Else sidx = array.Indexof(ary, dr("姓名")) sidx = iif(sidx = ary.Length-1, 0, sidx+1) sd = Cdate(dr("日期")).AddDays(1) End If Dim ed As Date = Date.today.Adddays(9) Dim d As Date = sd Do While d <= ed Dim nr As Row = Tables("表a").AddNew nr("日期") = d nr("姓名") = ary(((d-sd).Days+sidx) Mod 8) d = d.AddDays(1) Loop Dim dt As DataTable = DataTables("表A") Dim fdr As DataRow = dt.Find("日期 = #" & Date.today.adddays(-1) & "#") Dim str As String = "" If fdr IsNot Nothing Then str &= " 值班人员: 昨天:" & fdr("姓名") Else str &= " 值班人员: 昨天:没人" End If fdr = dt.Find("日期 = #" & Date.today & "#") If fdr IsNot Nothing Then str &= " , 今天:" & fdr("姓名") Else str &= " , 今天:没人" End If fdr = dt.Find("日期 = #" & Date.today.adddays(1) & "#") If fdr IsNot Nothing Then str &= " , 明天:" & fdr("姓名") Else str &= " , 明天:没人" End If fdr = dt.Find("日期 = #" & Date.today.adddays(2) & "#") If fdr IsNot Nothing Then str &= " , 后天:" & fdr("姓名") Else str &= " , 后天:没人" End If StatusBar.Message1 = str
|