Select e.DataCol.Name Case "面料名称","面料类别" If e.DataRow.IsNull("面料名称") OrElse e.DataRow.IsNull("面料类别") Then e.DataRow("面料编号") = Nothing Else Dim bfry As String = e.DataRow("面料类别") If e.DataRow("面料类别") = "梭织面料" Then bfry = "SZ" ElseIf e.DataRow("面料类别") = "针织面料" Then bfry = "ZZ" ElseIf e.DataRow("面料类别") = "花边面料" Then bfry = "HB" ElseIf e.DataRow("面料类别") = "无纺面料" Then bfry = "WF" End If Dim bflx As String = GetPy(e.DataRow("面料名称").substring(0,2) ,True) Dim bf As String = "ML" Dim d As Date = Date.Today() Dim bh As String = bf & Format(d,"yy") & bflx & Format(d,"MM") & bfry & Format(d,"yy") & "-" Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(面料编号)","面料编号 like '" & bh & "%'") If max > "" Then '如果存在最大编号 idx = CInt(max.Substring(bh.Length,3)) + 1 '获得最大编号的后三位顺序号,并加1 Else idx = 1 '否则顺序号等于1 End If e.DataRow("面料编号") = bh & Format(idx,"000") End If End Select
|