Foxtable(狐表)用户栏目专家坐堂 → [求助]自动编号


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

主题:[求助]自动编号

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


加好友 发短信
等级:婴狐 帖子:20 积分:256 威望:0 精华:0 注册:2015/4/7 13:05:00
[求助]自动编号  发帖心情 Post By:2017/10/1 17:29:00 [只看该作者]

以下代码是在datacolchanged事件中的,重置“企业名称”和“合同签订日期”中的数据后,“企业编号”列里面并没有自动生成编号,请问是什么原因啊?
if e.DataCol.Name = "企业名称" orelse e.DataCol.Name = "合同签订日期" then
    if e.DataRow.IsNull("企业名称") Then
       e.DataRow("企业编号") = Nothing
    else 
         Dim dr As DataRow 
         dr = e.DataTable.find("企业名称 = '" & e.datarow("企业名称") & "'")
         if dr IsNot Nothing Then
            e.datarow("企业编号") = dr("企业编号")
         else
              If e.DataRow.IsNull("合同签订日期") then 
                 e.DataRow("企业编号") = Nothing
              Else
                  Dim bh As String = Format(e.DataRow("合同签订日期"),"yyyyMMdd")
                  If e.DataRow("企业编号").StartsWith(bh) = False
                     Dim max As String
                     Dim idx As Integer
                     max = e.DataTable.Compute("Max(企业编号)","合同签订日期 = #" & e.DataRow("合同签订日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
                     If max > "" Then
                        idx = CInt(max.Substring(8,2)) + 1
                     Else
                        idx = 1
                     End If
                     e.DataRow("企业编号") = bh & Format(idx,"00")
                  End If
               End If
          End If
     end if
end if 
[此贴子已经被作者于2017/10/2 15:14:03编辑过]

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


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/10/4 9:25:00 [只看该作者]

max = e.DataTable.Compute("Max(企业编号)","企业编号 = '" & e.datarow("企业编号")  & "' and 合同签订日期 = #" & e.DataRow("合同签订日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))

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


加好友 发短信
等级:婴狐 帖子:20 积分:256 威望:0 精华:0 注册:2015/4/7 13:05:00
  发帖心情 Post By:2017/10/27 11:22:00 [只看该作者]

好的,非常感谢老师!

 回到顶部