以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 自动编号 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=132002) |
-- 作者:13775189031 -- 发布时间:2019/3/11 15:44:00 -- 自动编号 Select e.DataCol.Name Case "送检_送检日期","代号" If e.DataRow.IsNull("送检_送检日期") OrElse 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 = e.DataRow("代号") & "-" & Format(d,"yyyyMM") & "-" If e.DataRow("送检_送检单编号").StartsWith(bh) = False \'如果报告单送检_送检单编号前缀不符 Dim max As String Dim idx As Integer Dim flt As String flt = "代号 = \'"& e.DataRow("代号") & "\' And 送检_送检日期 >= #" & fd & "# And 送检_送检日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.Compute("Max(送检_送检单编号)",flt) \'取得该月的相同部门代号的最大报告单送检_送检单编号 If max > "" Then \'如果存在最大报告单送检_送检单编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大报告单送检_送检单编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("送检_送检单编号") = bh & Format(idx,"0000") End If End If End Select 请教,想增加个条件判断,若判断“预算编号”相同同时“送检日期”也相同,则自动生成的“送检单编号”则相同,若判断“预算编号”与“送检日期”有一个不同,则按流水号自动顺延增加编号 要怎么修改?
|
-- 作者:有点甜 -- 发布时间:2019/3/11 15:58:00 -- Select e.DataCol.Name Case "送检_送检日期","代号" If e.DataRow.IsNull("送检_送检日期") OrElse 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 = e.DataRow("代号") & "-" & Format(d,"yyyyMM") & "-" If e.DataRow("送检_送检单编号").StartsWith(bh) = False \'如果报告单送检_送检单编号前缀不符 Dim max As String Dim idx As Integer Dim flt As String flt = "代号 = \'"& e.DataRow("代号") & "\' And 送检_送检日期 >= #" & fd & "# And 送检_送检日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") Dim fdr As DataRow = e.DataTable.find(flt & " and 送检_送检单编号 is not nothing and 送检_送检日期 = #" & d & "#") If fdr Is Nothing Then max = e.DataTable.Compute("Max(送检_送检单编号)",flt) \'取得该月的相同部门代号的最大报告单送检_送检单编号 If max > "" Then \'如果存在最大报告单送检_送检单编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大报告单送检_送检单编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("送检_送检单编号") = bh & Format(idx,"0000") Else e.DataRow("送检_送检单编号") = fdr("送检_送检单编号") End If End If End If End Select |
-- 作者:13775189031 -- 发布时间:2019/3/12 8:42:00 -- 显示错误: .NET Framework 版本:2.0.50727.8937 Foxtable 版本:2018.10.9.1 错误所在事件:表,物资检验详单,DataColChanged 详细错误信息: 调用的目标发生了异常。 未找到列 [nothing]。 |
-- 作者:有点甜 -- 发布时间:2019/3/12 9:10:00 -- Dim fdr As DataRow = e.DataTable.find(flt & " and 送检_送检单编号 is not nothing and 送检_送检日期 = #" & d & "#")
改成
Dim fdr As DataRow = e.DataTable.find(flt & " and 送检_送检单编号 is not null and 送检_送检日期 = #" & d & "#") |
-- 作者:13775189031 -- 发布时间:2019/3/12 12:22:00 -- “预算编号” “送检日期” “送检单编号” 001 20190201 B-2019020001 001 20190201 B-2019020001 001 20190205 B-2019020002 002 20190302 B-2019030001 生成以上效果,“预算编号”相同,“送检日期”相同,则“送检单编号”相同 “预算编号”相同,“送检日期”不相同,则“送检单编号”不相同 “预算编号”不相同,“送检日期”不相同,则“送检单编号”不相同 编号顺延 按以上面的代码,现在“送检日期”相同的编号全部相同,没有区分“预算编号” |
-- 作者:有点甜 -- 发布时间:2019/3/12 12:27:00 -- 参考
http://foxtable.com/bbs/dispbbs.asp?boardid=2&Id=131944
|
-- 作者:13775189031 -- 发布时间:2019/3/12 15:01:00 -- Select e.DataCol.Name Case "送检_送检日期","代号","预算编号" If e.DataRow.IsNull("送检_送检日期") OrElse e.DataRow.IsNull("代号") OrElse 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 = e.DataRow("代号") & "-" & Format(d,"yyyyMM") & "-" If e.DataRow("预算编号") = " & e.newValue & " Dim max As String Dim idx As Integer Dim flt As String flt = "代号 = \'"& e.DataRow("代号") & "\' And 送检_送检日期 >= #" & fd & "# And 送检_送检日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") Dim fdr As DataRow = e.DataTable.find(flt & " and 送检_送检单编号 is not null and 送检_送检日期 = #" & d & "#") If fdr Is Nothing Then max = e.DataTable.Compute("Max(送检_送检单编号)",flt) \'取得该月的相同部门代号的最大报告单送检_送检单编号 If max > "" Then \'如果存在最大报告单送检_送检单编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大报告单送检_送检单编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("送检_送检单编号") = bh & Format(idx,"0000") Else e.DataRow("送检_送检单编号") = fdr("送检_送检单编号") End If End If End If End Select 请教老师,要怎么改一下?代号跟预算编号没关系,只要对预算编号进行个判断! [此贴子已经被作者于2019/3/12 15:01:27编辑过]
|
-- 作者:有点甜 -- 发布时间:2019/3/12 15:04:00 -- 改成
flt = "预算编号 = \'"& e.DataRow("预算编号") & "\' And 送检_送检日期 >= #" & fd & "# And 送检_送检日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") |
-- 作者:13775189031 -- 发布时间:2019/3/12 15:20:00 -- 不行!编号不显示! Select e.DataCol.Name Case "送检_送检日期","代号","预算编号" If e.DataRow.IsNull("送检_送检日期") OrElse e.DataRow.IsNull("代号") OrElse 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 = e.DataRow("代号") & "-" & Format(d,"yyyyMM") & "-" If e.DataRow("预算编号") = " & e.newValue & " Dim max As String Dim idx As Integer Dim flt As String flt = "预算编号 = \'"& e.DataRow("预算编号") & "\' And 送检_送检日期 >= #" & fd & "# And 送检_送检日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") Dim fdr As DataRow = e.DataTable.find(flt & " and 送检_送检单编号 is not null and 送检_送检日期 = #" & d & "#") If fdr Is Nothing Then max = e.DataTable.Compute("Max(送检_送检单编号)",flt) \'取得该月的相同部门代号的最大报告单送检_送检单编号 If max > "" Then \'如果存在最大报告单送检_送检单编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大报告单送检_送检单编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("送检_送检单编号") = bh & Format(idx,"0000") Else e.DataRow("送检_送检单编号") = fdr("送检_送检单编号") End If End If End If End Select
|
-- 作者:有点甜 -- 发布时间:2019/3/12 15:21:00 --
具体实例发上来测试,不然,请看6楼
[此贴子已经被作者于2019/3/12 15:21:57编辑过]
|