Dim str As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim utr As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim tst As WinForm.Label = e.Form.Controls("Label8")
Dim dr As DataRow
dr = DataTables("规格类别").Find("[规格类别] = '" & str.Value & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
If str.Value = "" Then
tst = Nothing
Else
If tst.text.StartsWith(str.Value) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
max = DataTables("规格类别").Compute("Max(代码)","规格类别 = '" & str.Value & "' And Len(代码) = 4")
If max > "" Then '如果存在最大编号
idx = CInt(max) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
tst.text = Format(idx,"0000")
Dim pdm As DataRow
pdm = DataTables("规格类别").AddNew()
pdm("规格类别") = str.Value
pdm("名称") = utr.Value
pdm("代码") = tst.text
DataTables("规格类别").Save()
End If
End If
End If
写入表时“名称”列没有写入
[此贴子已经被作者于2022/4/24 13:54:52编辑过]