Foxtable(狐表)用户栏目专家坐堂 → [求助]制作值班表?代码应该怎么写?


  共有2775人关注过本帖树形打印复制链接

主题:[求助]制作值班表?代码应该怎么写?

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/16 11:16:00 [显示全部帖子]

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/16 14:19:00 [显示全部帖子]

比如,可以动态生成。

 

Dim sd As Date = Date.Today
Dim ed As Date = Date.today.Adddays(10)
Dim ary() As String = {"张三", "李四", "王五"}
dim sidx as integer = 1 '从李四开始
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 3)
    d = d.AddDays(1)
Loop


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/16 19:02: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 & "#")
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


 回到顶部