以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 自动编号 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130404) |
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 12:37:00 -- 自动编号 老师您好,根据日期自动编号,部分日期可以出编号,部分出不来。有一个表完全出不来,删除原来编号时出现如下问题反馈。谢谢! ![]() ![]() ![]() ![]() |
||||
-- 作者:有点甜 -- 发布时间:2019/1/21 14:58:00 -- 贴出所写的代码。
|
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 15:43:00 -- If e.DataCol.Name = "开始日期" Then If e.DataRow.IsNull("开始日期") Then e.DataRow("合同编号") = Nothing Else Dim d As Date = e.DataRow("开始日期") Dim y As Integer = d.Year Dim m As Integer = d.Month Dim Days As Integer = Date.DaysInMonth(y,m) Dim fd As Date = New Date(y,m,1) Dim ld As Date = New Date(y,m,Days) Dim bh As String = Format(d,"yyyyMM") If e.DataRow("合同编号").StartsWith(bh) = False Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(合同编号)","开始日期 >= #" & fd & "# And 开始日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) If max > "" Then idx = CInt(max.Substring(7,3)) + 1 Else idx = 1 End If e.DataRow("合同编号") = bh & "-" & Format(idx,"00") End If End If End If |
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 15:47:00 -- If e.DataCol.Name = "开始日期" Then If e.DataRow.IsNull("开始日期") Then e.DataRow("合同编号") = Nothing Else Dim d As Date = e.DataRow("开始日期") Dim y As Integer = d.Year Dim m As Integer = d.Month Dim Days As Integer = Date.DaysInMonth(y,m) Dim fd As Date = New Date(y,m,1) Dim ld As Date = New Date(y,m,Days) Dim bh As String = Format(d,"yyyyMM") If e.DataRow("合同编号").StartsWith(bh) = False Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(合同编号)","开始日期 >= #" & fd & "# And 开始日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) If max > "" Then idx = CInt(max.Substring(7,3)) + 1 Else idx = 1 End If e.DataRow("合同编号") = bh & "-" & Format(idx,"00") End If End If End If |
||||
-- 作者:有点蓝 -- 发布时间:2019/1/21 16:44:00 -- 不要在代码模式里发表问题,请重新排版后发上来 |
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 17:15:00 -- 另外一个按照类别编号的在第二行就开始出现下面的问题,谢谢! ![]() ![]() |
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 17:17:00 -- 代码见附件,不知怎么在帖子里排版
[此贴子已经被作者于2019/1/21 17:23:30编辑过]
|
||||
-- 作者:qqhealth -- 发布时间:2019/1/21 17:26:00 -- 老师这样可以吗?谢谢! ![]() ![]() |
||||
-- 作者:有点蓝 -- 发布时间:2019/1/21 17:41:00 -- Select e.DataCol.Name Case "医疗机构代码" If e.DataRow.IsNull("医疗机构代码") Then e.DataRow("采购编号") = Nothing Else Dim lb As String = e.DataRow("医疗机构代码") If e.DataRow("采购编号").StartsWith(lb) = False \'如果单据编号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(采购编号)","医疗机构代码 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(max.Length - 3,3)) + 1 \'获得最大编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("采购编号") = lb & Format(idx,"000") End If End If End Select
|
||||
-- 作者:qqhealth -- 发布时间:2019/1/22 8:39:00 -- 老师您好,按照类别自动变号的问题解决了,谢谢!按照日期自动编号的问题在其他表也出现了类似的问题,日期我按照辅助输入工具输入的,错误反馈如下,代码见附件。 ![]() ![]()
|