Foxtable(狐表)用户栏目专家坐堂 → 计算代码有问题


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

主题:计算代码有问题

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


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/3/7 18:29:00 [显示全部帖子]

逻辑问题,例如这一段:

 

Select Case e.DataCol.name
    Case "入职日期","离职日期"
        If e.DataRow.IsNull("入职日期") Then
            e.DataRow("服务天数") = Nothing
        Else If e.DataRow.IsNull("出生日期") = False Then
            Dim tl As TimeSpan = Date.today - CDate(e.DataRow("出生日期"))
            e.DataRow("年龄") =  (Math.Round(tl.TotalDays)/365)
            If e.DataRow.Isnull("离职日期") Then
                Dim tp As TimeSpan = Date.today - CDate(e.DataRow("入职日期"))
                e.DataRow("服务天数") =  Math.Round(tp.TotalDays)
            Else
                Dim tt As TimeSpan = cdate(e.DataRow("离职日期")) - cdate(e.DataRow("入职日期"))
                e.DataRow("服务天数") = math.round(tt.Totaldays)
            End If
        End If
End Select

 

应该改为:

 

Select Case e.DataCol.name
    Case "入职日期","离职日期"
        If e.DataRow.IsNull("入职日期") Then
            e.DataRow("服务天数") = Nothing
        Else
            If e.DataRow.Isnull("离职日期") Then
                Dim tp As TimeSpan = Date.today - CDate(e.DataRow("入职日期"))
                e.DataRow("服务天数") =  Math.Round(tp.TotalDays)
            Else
                Dim tt As TimeSpan = cdate(e.DataRow("离职日期")) - cdate(e.DataRow("入职日期"))
                e.DataRow("服务天数") = math.round(tt.Totaldays)
            End If
        End If
        If e.DataRow.IsNull("出生日期") = False Then
            Dim tl As TimeSpan = Date.today - CDate(e.DataRow("出生日期"))
            e.DataRow("年龄") =  (Math.Round(tl.TotalDays)/365)
        End If
End Select


 回到顶部