以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 编码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=101584) |
||||
-- 作者:xusuyang -- 发布时间:2017/6/3 11:53:00 -- 编码 Select Case e.DataCol.Name
Case "产品名称"
If e.DataRow.IsNull("产品名称") Then
e.DataRow("产品编码") = Nothing
Else
e.DataRow("产品编码") = GetPy(e.DataRow("产品名称"), 1)
End If
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 = Format(d,"yyyyMM") & "-" \'生成编号的前缀
Dim fix As String = "-" & e.DataRow("产品编码")
If e.DataRow("销售订单编码").StartsWith(bh) = False OrElse e.DataRow("销售订单编码").EndsWith(fix) = False \'如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "销售订单编码 like \'" & bh & "%\' and 销售订单编码 like \'%" & fix & "\' And 销售日期 >= #" & fd & "# And 销售日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(销售订单编码)",flt) \'取得该月的相同工程代码的最大单据编号
If max > "" Then \'如果存在最大单据编号
idx = CInt(max.Substring(7,3)) + 1 \'获得最大单据编号的后四位顺序号,并加1
Else
idx = 1 \'否则顺序号等于1
End If
e.DataRow("销售订单编码") = bh & Format(idx,"000") & fix
End If
End If
End Select
老师:您好!执行此代码后,销售日期如2017-06-03,销售订单编码201706-001-DZSZB中没有显示为20170603-001-DZSZB?03没有
|
||||
-- 作者:有点蓝 -- 发布时间:2017/6/3 12:17:00 -- Select Case e.DataCol.Name Case "产品名称" If e.DataRow.IsNull("产品名称") Then e.DataRow("产品编码") = Nothing Else e.DataRow("产品编码") = GetPy(e.DataRow("产品名称"), 1) End If Case "销售日期","产品编码" If e.DataRow.IsNull("销售日期") OrElse e.DataRow.IsNull("产品编码") Then e.DataRow("销售订单编码") = Nothing Else Dim d As Date = e.DataRow("销售日期").Date Dim bh As String = Format(d,"yyyyMMdd") & "-" \'生成编号的前缀 Dim fix As String = "-" & e.DataRow("产品编码") If e.DataRow("销售订单编码").StartsWith(bh) = False OrElse e.DataRow("销售订单编码").EndsWith(fix) = False \'如果单据编号前缀不符 Dim max As String Dim idx As Integer Dim flt As String flt = "销售订单编码 like \'" & bh & "%\' and 销售订单编码 like \'%" & fix & "\' And 销售日期 >= #" & d & "# And 销售日期 < #" & d.AddDays(1) & "# And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.Compute("Max(销售订单编码)",flt) \'取得该月的相同工程代码的最大单据编号 If max > "" Then \'如果存在最大单据编号 idx = CInt(max.Substring(9,3)) + 1 \'获得最大单据编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("销售订单编码") = bh & Format(idx,"000") & fix End If End If End Select
|