Foxtable(狐表)用户栏目专家坐堂 → 【求助跨年计算】想实现在2018年1月份来计算2017年12月数据,总是报错,求解!


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

主题:【求助跨年计算】想实现在2018年1月份来计算2017年12月数据,总是报错,求解!

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


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

请用 addmonths(-1) 得到上一个月

 

Dim d=Date.Today

d = d.addmonths(-1)

msgbox(d.year)

msgbox(d.month)


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


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

Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month -1
 
改成
 

Dim d=Date.Today

d = d.addmonths(-1)

Dim y As Integer = d.Year

Dim m As Integer = d.Month

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


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

Select  e.DataCol.Name
    Case  "姓名"
       
        e.DataRow("发放状态")="未发放"
        Dim filter As String = "(员工 = '"  & e.DataRow("姓名") & "')"
        Dim d=Date.Today
d = d.addmonths(-1)
Dim y As Integer = d.Year
Dim m As Integer = d.Month
        'MessageBox.Show(m)
        Dim dt1 As New Date(y, m, 1)
        Dim dt2 As New Date(y, m, Date.DaysInMonth(y,m)) '获取该月的最后一天
        Dim Filterdate As String
        Filterdate = "考勤日期 >= #" & dt1 & "# And 考勤日期 <= #" & dt2 & "#"
       
        Dim dr As DataRow
        dr = DataTables("员工表").Find("姓名 = '"  & e.DataRow("姓名") & "'")
        If dr IsNot Nothing '如果找到, 则设置各列内容
            e.DataRow("部门")=dr("所属门店")
        End If
        e.DataRow("日期")=Date.Today
        e.DataRow("年")=d.year
        e.DataRow("月")=d.month
       
       
       
        Dim dr2 As DataRow
        dr2 = DataTables("词典表").Find("类别 = '迟到标准'")
        If dr2 IsNot Nothing '如果找到, 则设置各列内容
            e.DataRow("扣款_迟扣标准")=dr2("内容")
        End If
       
        Dim dr3 As DataRow
        dr3 = DataTables("词典表").Find("类别 = '旷工标准'")
        If dr3 IsNot Nothing '如果找到, 则设置各列内容
            e.DataRow("扣款_旷扣标准")=dr3("内容")
        End If
       
        Dim dr4 As DataRow
        dr4 = DataTables("词典表").Find("类别 = '请假标准'")
        If dr4 IsNot Nothing '如果找到, 则设置各列内容
            e.DataRow("扣款_请假标准")=dr4("内容")
        End If
       
       
       
        Dim dr1 As DataRow
        dr1 = DataTables("基础薪资").Find("姓名 = '"  & e.DataRow("姓名") & "'")
        If dr1 IsNot Nothing '如果找到, 则设置各列内容
            e.DataRow("基础工资")=dr1("基础工资")
            e.DataRow("话费补贴")=dr1("话费补贴")
            e.DataRow("交通补贴")=dr1("交通补贴")
            e.DataRow("工龄补贴")=dr1("工龄补贴")
            e.DataRow("其他补贴")=dr1("其他补贴")
           
        End If
        Dim filter1 As String = "(考勤人员 = '"  & e.DataRow("姓名") & "' and 考勤类别 = '迟到登记' )"
        e.DataRow("扣款_迟到次数") = DataTables("员工考勤").compute("count(考勤编号)", filter1  & " and 考勤日期 >= #" & dt1 & "# And 考勤日期 <= #" & dt2 & "#")
        If e.DataRow("扣款_迟到次数") >=1  Then
            e.DataRow("奖金_满勤奖")=0
            e.DataRow("扣款_迟到扣款")=e.DataRow("扣款_迟到次数") *e.DataRow("扣款_迟扣标准")
        Else
            e.DataRow("奖金_满勤奖")=dr1("满勤奖")
        End If
       
        Dim filter11 As String = "(考勤人员 = '"  & e.DataRow("姓名") & "' and 考勤类别 = '旷工登记' )"
        e.DataRow("扣款_旷工次数") = DataTables("员工考勤").compute("count(考勤编号)", filter11  & " and 考勤日期 >= #" & dt1 & "# And 考勤日期 <= #" & dt2 & "#")
        If e.DataRow("扣款_旷工次数") >=1  Then
            e.DataRow("奖金_满勤奖")=0
            e.DataRow("扣款_旷工扣款")=e.DataRow("扣款_旷工次数") *e.DataRow("扣款_旷扣标准")
        Else
            e.DataRow("奖金_满勤奖")=dr1("满勤奖")
        End If
       
        Dim filter111 As String = "(考勤人员 = '"  & e.DataRow("姓名") & "' and 考勤类别 = '请假登记' )"
        e.DataRow("扣款_请假次数") = DataTables("员工考勤").compute("count(考勤编号)", filter111 & " and 考勤日期 >= #" & dt1 & "# And 考勤日期 <= #" & dt2 & "#")
        If e.DataRow("扣款_请假次数") >=1  Then
            e.DataRow("奖金_满勤奖")=0
            e.DataRow("扣款_请假扣款")=e.DataRow("扣款_请假次数") *e.DataRow("扣款_请假标准")
        Else
            e.DataRow("奖金_满勤奖")=dr1("满勤奖")
        End If
        e.DataRow("扣款_任务额度") = DataTables("订单主表").compute("sum(订单总额)", filter  & " And 订单日期 >= #" & dt1 & "# And 订单日期 <= #" & dt2 & "#")
        e.DataRow("实发工资")=(e.DataRow("基础工资")+e.DataRow("话费补贴")+e.DataRow("交通补贴")+e.DataRow("工龄补贴")+e.DataRow("其他补贴")+e.DataRow("奖金_满勤奖")+e.DataRow("奖金_超量奖")+e.DataRow("奖金_超额奖"))-(e.DataRow("扣款_迟到扣款")+e.DataRow("扣款_旷工扣款")+e.DataRow("扣款_请假扣款")+e.DataRow("扣款_未完单扣")+e.DataRow("扣款_未达额扣")+e.DataRow("代扣_伙食")+e.DataRow("代扣_其它"))
       
    Case "代扣_伙食","代扣_其它"
        e.DataRow("实发工资")=(e.DataRow("基础工资")+e.DataRow("话费补贴")+e.DataRow("交通补贴")+e.DataRow("工龄补贴")+e.DataRow("其他补贴")+e.DataRow("奖金_满勤奖")+e.DataRow("奖金_超量奖")+e.DataRow("奖金_超额奖"))-(e.DataRow("扣款_迟到扣款")+e.DataRow("扣款_旷工扣款")+e.DataRow("扣款_请假扣款")+e.DataRow("扣款_未完单扣")+e.DataRow("扣款_未达额扣")+e.DataRow("代扣_伙食")+e.DataRow("代扣_其它"))
       
       
       
       
        'Dim dr As Row=Tables("员工薪资").Current
        'Dim ndr As DataRow = DataTables("收支明细").find("日期 = '" & e.DataRow("日期") & "' and 支出去向 = '" & e.DataRow("姓名") & "'")
        'If ndr Is Nothing Then
        'ndr = DataTables("收支明细").AddNew
        'End If
        'ndr("日期") = Date.Now
        'ndr("支出") = dr("实发工资")()
        'ndr("支出类型") = "员工工资"
        'ndr("支出去向") = dr("姓名")()
        'ndr("支出日期") = Date.Now
        'ndr("支出说明") = ndr("支出日期") & ndr("支出类型") & ndr("支出去向")
        '
End Select

 回到顶部