我要做一个材料分类管理,窗口界面如下:
使用的代码在“添加”按钮中,其代码为:
Dim t1 As String = e.Form.Controls("编号").VALUE
Dim t2 As String = e.Form.Controls("名称").VALUE
Dim t3 As String = e.Form.Controls("类别").VALUE
Dim t4 As String = e.Form.Controls("标准").VALUE
Dim t5 As String = e.Form.Controls("型号").VALUE
Dim t6 As String = e.Form.Controls("单位").VALUE
Dim t7 As Single = e.Form.Controls("单价").VALUE
If DataTables("材料信息表").DataRows.Count = 0 Then
Tables("材料信息表").AddNew
Else
If t2 = "" Or t3 = "" Or t4 = "" Or t5 = "" Or t6 = "" Then
MessageBox.show("请输入完整的材料信息","提示")
Return
Else
'定位第1组编号
With Tables("材料名称管理")
Dim bh1 As String
Dim r1 As Integer = .FindRow("分组名称=t2",.Position + 1, True)
If r1 >= 0 Then '如果找到的话
.Position = r1
bh1 = .Current("分组编号")
End If
End With
'定位第2组编号
With Tables("材料类别管理")
Dim bh2 As String
Dim r2 As Integer = .FindRow("分组名称 = t3",.Position + 1, True)
If r2 >= 0 Then '如果找到的话
.Position = r2
bh2 = .Current("分组编号")
End If
End With
'定位第3组编号
With Tables("材料应用标准管理")
Dim bh3 As String
Dim r3 As Integer = .FindRow("分组名称 = t4",.Position + 1, True)
If r3 >= 0 Then '如果找到的话
.Position = r3
bh3 = .Current("分组编号")
End If
End With
'定位第4组编号
With Tables("材料规格型号管理")
Dim bh4 As String
Dim r4 As Integer = .FindRow("分组名称 = t5",.Position + 1, True)
If r4 >= 0 Then '如果找到的话
.Position = r4
bh4 = .Current("分组编号")
End If
End With
t1 = bh1 & bh2 & bh3 & bh4"
Tables("材料信息表").AddNew
End If
End If
希望在输入材料名称、类别、标准、规格后,编号能够从材料分组的各管理表中,定位行后提取分组编号,组成新的材料编号,并在材料编号的textbox中显示,便于识别后添加到材料信息表中。

此主题相关图片如下:5667.jpg
