Foxtable(狐表)用户栏目专家坐堂 → 请教使用怎么实现使用年限的问题


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

主题:请教使用怎么实现使用年限的问题

帅哥哟,离线,有人找我吗?
大红袍
  31楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/9 18:09:00 [只看该作者]

2、

Select e.DataCol.Name
    Case "购买日期", "生产日期"
       
        If e.DataRow.IsNull("购买日期") AndAlso e.DataRow.Isnull("生产日期") Then
            e.DataRow("使用年限") = Nothing
            e.DataRow("是否过保") = Nothing
        Else
            If e.DataRow.IsNull("购买日期")
                Dim sp As TimeSpan = Date.now - cdate(e.DataRow("生产日期"))
                e.DataRow("使用年限") = sp.TotalDays
            Else
                Dim sp As TimeSpan = Date.now - cdate(e.DataRow("购买日期"))
                e.DataRow("使用年限") = sp.TotalDays
            End If
        End If
    Case "保修日期"
        If e.DataRow.isnull("保修日期") = False AndAlso e.DataRow("保修日期") < Date.today Then
           
            e.DataRow("是否过保") = "过保"
        Else
            e.DataRow("是否过保") = "没过保"
        End If
       
End Select


 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  32楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/9 20:34:00 [只看该作者]

谢谢,我这个表基本上完工了。现在做第二大块就是把设备一览表的姓名,ip地址的数据自动同步到ip表的ip地址和使用人,我看了视频不知道用哪种实现。是用关联表?还是弄查询表实现。考勤和门禁也是。设备一览表的姓名,营销考勤,营销门禁,科研考勤,科研门禁自动同步到考勤与门禁表。

同时如果设备一览表有变更,ip表和门禁表自动更新

先自动生成192.168.1.1-192.168.1.255和192.168.2.1-192.168.2.255,ip表可以自己手工更新。如果设备一览表数据更新了ip表则更新,我自己手工更新的ip表则不受影响。

如果设备一览表离职员工。则ip表自动添加背景色。如果有空白没有使用的ip段可以隐藏。默认排序全部显示。我点击隐藏空白。空白的ip则隐藏。显示空白ip则显示出来。


考勤也是这样

可以自动生成192.168.*.*-192.168.*.*因为ip段前两位都一样。


以上功能作为新手有点困难了。怎么实现。

 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  33楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/10 8:33:00 [只看该作者]

 我添加了怎么离职、公共设施2G还是不加粗。

没过保,删除了,他自动出现了。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:南京徳亨文设备一览表.table


[此贴子已经被作者于2016/3/10 8:37:33编辑过]

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/10 9:52:00 [只看该作者]

 更新的问题,参考跨表引用

 

http://www.foxtable.com/help/topics/1451.htm

 


 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  35楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/10 9:59:00 [只看该作者]

 大红袍帮我看看添加离职,公共设施和没过保,添加不起作用

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/10 10:02:00 [只看该作者]

以下是引用冰淇淋小子在2016/3/10 8:33:00的发言:
 我添加了怎么离职、公共设施2G还是不加粗。

没过保,删除了,他自动出现了。

[此贴子已经被作者于2016/3/10 8:37:33编辑过]

 

条件是 离职、2G、生产日期2008-2010啊,满足条件就可以了啊。

 

再有,DataColChanged改成这样

 

If e.DataCol.Name = "IP地址" AndAlso Not String .IsNullOrEmpty( e.NewValue) Then
    Dim arrNo() As String  = e.NewValue.Split(".")
    If arrNo.Length = 4 Then 
    For i  As Integer = 0 To arrNo.Length - 1
    arrNo(i) = arrNo(i).PadLeft(3,"0")
    Next
    e.DataRow("IP地址") = Join(arrNo,".")
    End If
End If
Select e.DataCol.Name
    Case "购买日期", "生产日期"
      
        If e.DataRow.IsNull("购买日期") AndAlso e.DataRow.Isnull("生产日期") Then
            e.DataRow("使用年限") = Nothing
            e.DataRow("是否过保") = Nothing
        Else
            If e.DataRow.IsNull("购买日期")
                Dim sp As TimeSpan = Date.now - cdate(e.DataRow("生产日期"))
                e.DataRow("使用年限") = sp.TotalDays
            Else
                Dim sp As TimeSpan = Date.now - cdate(e.DataRow("购买日期"))
                e.DataRow("使用年限") = sp.TotalDays
            End If
        End If
    Case "保修日期"
        If e.DataRow.isnull("保修日期") = False AndAlso e.DataRow("保修日期") < Date.today Then
          
            e.DataRow("是否过保") = "过保"
        Else
            e.DataRow("是否过保") = "没过保"
        End If
      
End Select

 

再有,要跨表更新看34楼。自动生成ip地址,参考代码

 

Dim str As String = Nothing
For j As Integer = 1 To 2
    For i As Integer = 1 To 255
        If DataTables("南京徳亨文生物科技有限公司设备一览表").find("ip地址 = '192.168." & format(j, "000") & "." & Format(i, "000") & "'") Is Nothing Then
            str = "192.168." & j & "." & i
            Exit For
        End If
    Next
    If str > Nothing Then Exit For
Next
msgbox(str)


 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  37楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/10 10:30:00 [只看该作者]

我知道了,你帮我设置并列关系,那单独了,如果内存是2G,就红色加粗,如果生产日期是是2008/2009/2010就红色加粗
[此贴子已经被作者于2016/3/10 10:50:04编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  38楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/10 10:55:00 [只看该作者]

 If e.Col.Name = "内存" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name) = "2G" Then
            e.Style = "2G"
                End If
    End If
End If
If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2008 Then
            e.Style = "2008"
        End If
    End If
End If

If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2009 Then
            e.Style = "2009"
        End If
    End If
End If

If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2010 Then
            e.Style = "2010"
        End If
    End If
End If

If e.Col.Name = "使用年限" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        'Dim s() As String = e.Row(e.Col.Name).split("年")
        Dim d As Date
        Dim d2 As Date
        If e.Row.IsNull("购买日期") Then
            d2 = e.Row("生产日期")
        Else
            d2 = e.Row("购买日期")
        End If
        d = d2.AddDays(e.Row("使用年限"))
        Dim y,m,dd As Integer
        DateYMD(d,d2,y,m,dd)
        e.Text = y & "年" & m & "月"
 If y >= 5 Then
       If e.Row("部门") = "公共设施" Then

                e.Style = "使用年限2"
Else
            e.Style = "使用年限"
        End If
End If
    End If
End If

If e.Row("部门") = "离职" Then
    e.Style = "离职"
End If
If e.Row("部门") = "公共设施" Then
    e.Style = "公共设施"
End If

If e.Col.Name = "是否过保" Then
    If e.Row.isnull("保修日期") = False AndAlso e.Row("保修日期") < Date.today Then
        If e.Row(e.Col.Name) = "过保" Then
            If e.Row("部门") = "公共设施" Then
                e.Style = "是否过保2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "是否过保"
            End If
    End If    
    End If
End If

If e.Col.Name = "内存" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name) = "2G" Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                If e.Row.isnull("生产日期") = False
                    Select e.Row("生产日期").year
                        Case 2008,2009,2010
                            e.Style = "2G"
                    End Select
                End If
            End If
        End If
    End If
End If

这个是全部代码

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/10 11:07:00 [只看该作者]

你要看懂代码,基础知识不能少,至少先把帮助文档过一遍有个大概的概念。

 

If e.Col.Name = "内存" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name) = "2G" Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                e.Style = "2G"
            End If
        End If
    End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
冰淇淋小子
  40楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:182 积分:1306 威望:0 精华:0 注册:2012/3/27 11:54:00
  发帖心情 Post By:2016/3/10 12:27:00 [只看该作者]

我在If e.Col.Name = "内存" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name) = "2G" Then
            e.Style = "2G"
                End If
    End If
End If
If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2008 Then
            e.Style = "2008"
        End If
    End If
End If

If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2009 Then
            e.Style = "2009"
        End If
    End If
End If

If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2010 Then
            e.Style = "2010"
        End If
    End If
End If

If e.Col.Name = "使用年限" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        'Dim s() As String = e.Row(e.Col.Name).split("年")
        Dim d As Date
        Dim d2 As Date
        If e.Row.IsNull("购买日期") Then
            d2 = e.Row("生产日期")
        Else
            d2 = e.Row("购买日期")
        End If
        d = d2.AddDays(e.Row("使用年限"))
        Dim y,m,dd As Integer
        DateYMD(d,d2,y,m,dd)
        e.Text = y & "年" & m & "月"
 If y >= 5 Then
       If e.Row("部门") = "公共设施" Then

                e.Style = "使用年限2"
Else
            e.Style = "使用年限"
        End If
End If
    End If
End If

If e.Row("部门") = "离职" Then
    e.Style = "离职"
End If
If e.Row("部门") = "公共设施" Then
    e.Style = "公共设施"
End If

If e.Col.Name = "是否过保" Then
    If e.Row.isnull("保修日期") = False AndAlso e.Row("保修日期") < Date.today Then
        If e.Row(e.Col.Name) = "过保" Then
            If e.Row("部门") = "公共设施" Then
                e.Style = "是否过保2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "是否过保"
            End If
    End If    
    End If
End If

If e.Col.Name = "内存" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name) = "2G" Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                  If e.Row("部门") = "公共设施" Then
                e.Style = "公共设施2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "2G"
            End If
    End If    
    End If
End If
End If
If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2008 Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                  If e.Row("部门") = "公共设施" Then
                e.Style = "公共设施2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "2008"
            End If
    End If    
    End If
End If
End If
If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2009 Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                  If e.Row("部门") = "公共设施" Then
                e.Style = "公共设施2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "2009"
            End If
    End If    
    End If
End If
End If

If e.Col.Name = "生产日期" Then
    If e.Row.IsNull(e.Col.Name) = False Then
        If e.Row(e.Col.Name).Year = 2010 Then
            If e.Row("部门") = "离职" OrElse e.Row("部门") = "公共设施" Then
                  If e.Row("部门") = "公共设施" Then
                e.Style = "公共设施2"
            ElseIf e.Row("部门") = "离职" Then
                e.Style = "离职2"
            Else
                e.Style = "2010"
            End If
    End If    
    End If
End If
End If


这个DrawCell代码还能合并优化?



 回到顶部
总数 48 上一页 1 2 3 4 5 下一页