Foxtable(狐表)用户栏目专家坐堂 → 日期统计


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

主题:日期统计

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


加好友 发短信
等级:婴狐 帖子:74 积分:629 威望:0 精华:0 注册:2013/5/13 4:03:00
日期统计  发帖心情 Post By:2014/8/19 5:33:00 [只看该作者]

老师我原来的统计是这样的,不知道这么变成这样的了呢请看看 ,原来是点击十字的时候,就到打开了内容,现在只有姓名不能打开内容


原来的样式 

图片点击可在新窗口打开查看此主题相关图片如下:111.gif
图片点击可在新窗口打开查看

变了样式

图片点击可在新窗口打开查看此主题相关图片如下:222.gif
图片点击可在新窗口打开查看


 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:查看.table







代码:::

Dim cmd As new SQLCommand
cmd.CommandText = "Select Masseur_Name As 姓名,Date①_Date As 日期, year(Date①_Date) As 年, month(Date①_Date) As 月, day(Date①_Date) As 日, 1 As 开单 from {Information} where Masseur_Name Is not null " _
& " union Select Masseur_Name,Date②_Date, year(Date②_Date), month(Date②_Date) As 月, day(Date②_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date③_Date, year(Date③_Date), month(Date③_Date) As 月, day(Date③_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date④_Date, year(Date④_Date), month(Date④_Date) As 月, day(Date④_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑤_Date, year(Date⑤_Date), month(Date⑤_Date) As 月, day(Date⑤_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑥_Date, year(Date⑥_Date), month(Date⑥_Date) As 月, day(Date⑥_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑦_Date, year(Date⑦_Date), month(Date⑦_Date) As 月, day(Date⑦_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑧_Date, year(Date⑧_Date), month(Date⑧_Date) As 月, day(Date⑧_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑨_Date, year(Date⑨_Date), month(Date⑨_Date) As 月, day(Date⑨_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑩_Date, year(Date⑩_Date), month(Date⑩_Date) As 月, day(Date⑩_Date), 1 from {Information} where Masseur_Name Is not null"
Dim dt As DataTable = cmd.ExecuteReader
For Each ary As String() In dt.GetValues("姓名|年", "年 is not null")
    For i As Integer = 1 To 12
        For j As Integer = 1 To Date.DaysInMonth(ary(1),i)
            Dim d As Date = new Date(ary(1), i, j)
            Dim fdr As DataRow = dt.Find("姓名 = '" & ary(0) & "' and 日期 = #" & d & "#")
            If fdr Is Nothing Then
                fdr = dt.AddNew
                fdr("姓名") = ary(0)
                fdr("日期") = d
                fdr("年") = ary(1)
                fdr("月") = i
                fdr("日") = j
                fdr("开单") = 0
            End If
        Next
    Next
Next
Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
tv.BuildTree(dt, "姓名|年|月|日")
For Each nd As WinForm.TreeNode In tv.AllNodes
    Select Case nd.Level
        Case 0
            nd.Text = nd.Text & "(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1") & "张)"
        Case 1
            nd.Text = nd.Text & "年(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "'") & "张)"
        Case 2
            nd.Text = nd.Text & "月(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "'") & "张)"
        Case 3
            nd.Text = nd.DataRow("月") & "月" & nd.Text & "日(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "' and 日 = '" & nd.DataRow("日") & "'") & "张)"
    End Select
Next





[此贴子已经被作者于2014-8-19 9:48:36编辑过]

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


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2014/8/19 8:40:00 [只看该作者]

请上例子.

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/19 9:07:00 [只看该作者]

 是不是你的数据不对啊?例子发上来看看。

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


加好友 发短信
等级:婴狐 帖子:74 积分:629 威望:0 精华:0 注册:2013/5/13 4:03:00
  发帖心情 Post By:2014/8/19 9:49:00 [只看该作者]

上传附件 老师请看

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/19 9:55:00 [只看该作者]

Dim cmd As new SQLCommand
cmd.CommandText = "Select Masseur_Name As 姓名,Date①_Date As 日期, year(Date①_Date) As 年, month(Date①_Date) As 月, day(Date①_Date) As 日, 1 As 开单 from {Information} where Masseur_Name Is not null and Date①_Date is not null" _
& " union Select Masseur_Name,Date②_Date, year(Date②_Date), month(Date②_Date) As 月, day(Date②_Date), 1 from {Information} where Masseur_Name Is not null and Date②_Date is not null" _
& " union Select Masseur_Name,Date③_Date, year(Date③_Date), month(Date③_Date) As 月, day(Date③_Date), 1 from {Information} where Masseur_Name Is not null and Date③_Date is not null" _
& " union Select Masseur_Name,Date④_Date, year(Date④_Date), month(Date④_Date) As 月, day(Date④_Date), 1 from {Information} where Masseur_Name Is not null and Date④_Date is not null" _
& " union Select Masseur_Name,Date⑤_Date, year(Date⑤_Date), month(Date⑤_Date) As 月, day(Date⑤_Date), 1 from {Information} where Masseur_Name Is not null and Date⑤_Date is not null" _
& " union Select Masseur_Name,Date⑥_Date, year(Date⑥_Date), month(Date⑥_Date) As 月, day(Date⑥_Date), 1 from {Information} where Masseur_Name Is not null and Date⑥_Date is not null" _
& " union Select Masseur_Name,Date⑦_Date, year(Date⑦_Date), month(Date⑦_Date) As 月, day(Date⑦_Date), 1 from {Information} where Masseur_Name Is not null and Date⑦_Date is not null" _
& " union Select Masseur_Name,Date⑧_Date, year(Date⑧_Date), month(Date⑧_Date) As 月, day(Date⑧_Date), 1 from {Information} where Masseur_Name Is not null and Date①_Date is not null" _
& " union Select Masseur_Name,Date⑨_Date, year(Date⑨_Date), month(Date⑨_Date) As 月, day(Date⑨_Date), 1 from {Information} where Masseur_Name Is not null and Date⑨_Date is not null" _
& " union Select Masseur_Name,Date⑩_Date, year(Date⑩_Date), month(Date⑩_Date) As 月, day(Date⑩_Date), 1 from {Information} where Masseur_Name Is not null and Date⑩_Date is not null"
Dim dt As DataTable = cmd.ExecuteReader
For Each ary As String() In dt.GetValues("姓名|年", "年 is not null")
    For i As Integer = 1 To 12
        For j As Integer = 1 To Date.DaysInMonth(ary(1),i)
            Dim d As Date = new Date(ary(1), i, j)
            Dim fdr As DataRow = dt.Find("姓名 = '" & ary(0) & "' and 日期 = #" & d & "#")
            If fdr Is Nothing Then
                fdr = dt.AddNew
                fdr("姓名") = ary(0)
                fdr("日期") = d
                fdr("年") = ary(1)
                fdr("月") = i
                fdr("日") = j
                fdr("开单") = 0
            End If
        Next
    Next
Next
Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
tv.BuildTree(dt, "姓名|年|月|日")
For Each nd As WinForm.TreeNode In tv.AllNodes
    Select Case nd.Level
        Case 0
            nd.Text = nd.Text & "(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1") & "张)"
        Case 1
            nd.Text = nd.Text & "年(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "'") & "张)"
        Case 2
            nd.Text = nd.Text & "月(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "'") & "张)"
        Case 3
            nd.Text = nd.DataRow("月") & "月" & nd.Text & "日(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "' and 日 = '" & nd.DataRow("日") & "'") & "张)"
    End Select
Next

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


加好友 发短信
等级:婴狐 帖子:74 积分:629 威望:0 精华:0 注册:2013/5/13 4:03:00
  发帖心情 Post By:2014/8/19 9:59:00 [只看该作者]

老师这样修改了只能显示一个人的名字了,而不能显示其他人的名字呢


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/19 10:04:00 [只看该作者]

 其他人本来就是没有啊

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


加好友 发短信
等级:婴狐 帖子:74 积分:629 威望:0 精华:0 注册:2013/5/13 4:03:00
  发帖心情 Post By:2014/8/19 10:11:00 [只看该作者]

我填了其他人,结果也显示第一个,其他人不显示
例如我填入了小三,小四,王五,结果他只显示了小三,尔其他两个则没有显示[
upload=gif,333.gif]UploadFile/2014-8/201481910105792537.gif[/upload]
图片点击可在新窗口打开查看此主题相关图片如下:444.gif
图片点击可在新窗口打开查看


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


加好友 发短信
等级:婴狐 帖子:74 积分:629 威望:0 精华:0 注册:2013/5/13 4:03:00
  发帖心情 Post By:2014/8/19 10:12:00 [只看该作者]

我想要的效果是

图片点击可在新窗口打开查看此主题相关图片如下:111.gif
图片点击可在新窗口打开查看





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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/19 10:18:00 [只看该作者]

Dim cmd As new SQLCommand
cmd.CommandText = "Select Masseur_Name As 姓名,Date①_Date As 日期, year(Date①_Date) As 年, month(Date①_Date) As 月, day(Date①_Date) As 日, 1 As 开单 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date②_Date, year(Date②_Date), month(Date②_Date) As 月, day(Date②_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date③_Date, year(Date③_Date), month(Date③_Date) As 月, day(Date③_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date④_Date, year(Date④_Date), month(Date④_Date) As 月, day(Date④_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑤_Date, year(Date⑤_Date), month(Date⑤_Date) As 月, day(Date⑤_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑥_Date, year(Date⑥_Date), month(Date⑥_Date) As 月, day(Date⑥_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑦_Date, year(Date⑦_Date), month(Date⑦_Date) As 月, day(Date⑦_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑧_Date, year(Date⑧_Date), month(Date⑧_Date) As 月, day(Date⑧_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑨_Date, year(Date⑨_Date), month(Date⑨_Date) As 月, day(Date⑨_Date), 1 from {Information} where Masseur_Name Is not null" _
& " union Select Masseur_Name,Date⑩_Date, year(Date⑩_Date), month(Date⑩_Date) As 月, day(Date⑩_Date), 1 from {Information} where Masseur_Name Is not null"
Dim dt As DataTable = cmd.ExecuteReader
dt.ReplaceFor("开单", 0, "日期 is null")
For Each ary As String() In dt.GetValues("姓名|年", "年 is not null")
    For i As Integer = 1 To 12
        For j As Integer = 1 To Date.DaysInMonth(ary(1),i)
            Dim d As Date = new Date(ary(1), i, j)
            Dim fdr As DataRow = dt.Find("姓名 = '" & ary(0) & "' and 日期 = #" & d & "#")
            If fdr Is Nothing Then
                fdr = dt.AddNew
                fdr("姓名") = ary(0)
                fdr("日期") = d
                fdr("年") = ary(1)
                fdr("月") = i
                fdr("日") = j
                fdr("开单") = 0
            End If
        Next
    Next
Next
Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
tv.BuildTree(dt, "姓名|年|月|日")
For Each nd As WinForm.TreeNode In tv.AllNodes
    Select Case nd.Level
        Case 0
            nd.Text = nd.Text & "(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1") & "张)"
        Case 1
            nd.Text = nd.Text & "年(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "'") & "张)"
        Case 2
            nd.Text = nd.Text & "月(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "'") & "张)"
        Case 3
            nd.Text = nd.DataRow("月") & "月" & nd.Text & "日(" & dt.Compute("count(姓名)", "姓名 = '" & nd.DataRow("姓名") & "' and 开单 = 1 and 年 = '" & nd.DataRow("年") & "' and 月 = '" & nd.DataRow("月") & "' and 日 = '" & nd.DataRow("日") & "'") & "张)"
    End Select
Next

 


 回到顶部
总数 12 1 2 下一页