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


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

主题:按周统计

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/13 10:16:00 [显示全部帖子]

Dim dt1 As DataTable = DataTables("周结")
Dim dt2 As DataTable = DataTables("销售")
dt1.DataRows.Clear
Dim cs() As String = {"星期天","星期一","星期二","星期三","星期四","星期五","星期六"}
For Each dr As DataRow In dt2.Select("日期 is not null", "日期")
    Dim d As Date = dr("日期")
    Dim y As Integer = d.Year
    Dim w As Integer = d.DayOfWeek '算出今天是星期几
    Dim d1 As Date = d.AddDays(-w) '获取本周的第一天
    Dim d2 As Date = d.AddDays(6 - w) '获取本周的最后一天
    Dim fdr As DataRow = dt1.find("周一 = #" & d1 & "# and 周二 = #" & d2 & "#")
    If fdr Is Nothing Then
        fdr = dt1.addnew
        fdr("周一") = d1
        fdr("周二") = d2
    End If
    Dim i As Integer = d.DayOfWeek
    fdr(cs(i)) += dr("营业额")
    fdr("合计") += dr("营业额")
Next

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/13 11:54:00 [显示全部帖子]

Dim y As Integer = d.Year
Dim w As Integer = d.DayOfWeek '算出今天是星期几
If w = 0 Then w = 7
Dim d1 As Date = d.AddDays(-w+1) '获取本周的第一天
Dim d2 As Date = d.AddDays(6 - w + 1) '获取本周的最后一天


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/13 15:02:00 [显示全部帖子]

这个不能改

 

Dim cs() As String = {"星期天","星期一","星期二","星期三","星期四","星期五","星期六"}

 


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/13 18:57:00 [显示全部帖子]

Dim dt1 As DataTable = DataTables("周结")
Dim dt2 As DataTable = DataTables("销售")
dt1.DataRows.Clear
Dim cs() As String = {"星期天","星期一","星期二","星期三","星期四","星期五","星期六"}
For Each dr As DataRow In dt2.Select("日期 is not null", "日期")
    Dim d As Date = dr("日期")
    Dim y As Integer = d.Year
    Dim w As Integer = d.DayOfWeek '算出今天是星期几
    If w = 0 Then w = 7
    Dim d1 As Date = d.AddDays(-w+1) '获取本周的第一天
    Dim d2 As Date = d.AddDays(6 - w + 1) '获取本周的最后一天
   
    Dim fdr As DataRow = dt1.find("周一 = #" & d1 & "# and 周二 = #" & d2 & "#")
    If fdr Is Nothing Then
        fdr = dt1.addnew
        fdr("周一") = d1
        fdr("周二") = d2
    End If
    Dim i As Integer = d.DayOfWeek
    fdr(cs(i)) += dr("营业额")
    fdr("合计") += dr("营业额")
Next

 回到顶部