📄 technologymaterjalinf.vb
字号:
Me.ComboBox3.Enabled = True
Me.TextBox8.Text = ""
Me.TextBox9.Text = ""
cailiaoCanshu()
Dim mystr As String
Dim mydataset As New DataSet
mystr = "select * from material_cd34 "
mydataset = GetDataFromDB(mystr)
Dim myint As Integer = mydataset.Tables(0).Rows.Count
Dim i As Integer = 0
Dim itemsstr As String
Me.ComboBox3.Items.Clear()
For i = 0 To (myint - 1)
itemsstr = mydataset.Tables(0).Rows(i)("CD3+4名称")
itemsstr = itemsstr.Trim
Me.ComboBox3.Items.Add(itemsstr)
Next
mydataset.Dispose()
Me.ComboBox3.SelectedIndex = 0
Else
Me.TextBox8.ReadOnly = True
Me.TextBox9.ReadOnly = True
Me.ComboBox3.Enabled = False
End If
End Sub
'显示象具体小项(材料费用)等的已经录入的内容
Private Sub cailiaoCanshu()
Dim mystr As String
Dim mydataset As New DataSet
mystr = "select * from material_canshu "
mydataset = GetDataFromDB(mystr)
Me.DataGrid1.DataSource = mydataset
mydataset.Dispose()
End Sub
'当DataGrid当前单元格变化的时候响应事件
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
If Me.RadioButton1.Checked = True Then
Button4.Enabled = True
'textbox1中的文本不可更改
TextBox1.ReadOnly = True
'Textbox1显示的是费用编号
TextBox1.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0))
'Textbox2显示的是费用名称
TextBox2.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1))
TextBox3.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2))
ElseIf Me.RadioButton2.Checked = True Then
Button4.Enabled = True
'textbox1中的文本不可更改
TextBox4.ReadOnly = True
'Textbox1显示的是费用编号
TextBox4.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0))
'Textbox2显示的是费用名称
ComboBox1.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1))
TextBox5.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2))
ElseIf Me.RadioButton3.Checked = True Then
Button4.Enabled = True
'textbox7中的文本不可更改
TextBox7.ReadOnly = True
TextBox7.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0))
ComboBox2.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2))
TextBox6.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1))
ElseIf Me.RadioButton4.Checked = True Then
Button4.Enabled = True
'textbox9中的文本不可更改
TextBox9.ReadOnly = True
TextBox9.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0))
ComboBox3.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1))
TextBox8.Text = Trim(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2))
End If
End Sub
'添加新项
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Me.RadioButton1.Checked = True Then
If Me.TextBox1.Text.Trim = "" Then
MsgBox("请输入费用编号!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
Dim mystr As String
Dim mystr1 As String = Me.TextBox1.Text.Trim
mystr = "select * from material_zongbiao where 费用编号 =" + Chr(39) + mystr1 + Chr(39)
If panduan(mystr) = True Then
MsgBox("费用编号已经存在!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
Dim sqlstr As String
sqlstr = "INSERT INTO material_zongbiao " & _
"(费用编号,费用名称,备注) " & _
"VALUES ('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加该新用户", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
End If
cailiao100()
ElseIf Me.RadioButton2.Checked = True Then
If Me.TextBox4.Text.Trim = "" Then
MsgBox("请输入CD1+2编号!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
Dim mystr As String
Dim mystr1 As String = Me.TextBox4.Text.Trim
mystr = "select * from material_cd12 where" + " [CD1+2编号] =" + Chr(39) + mystr1 + Chr(39)
If panduan(mystr) = True Then
MsgBox("CD1+2编号-已经存在!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
Dim sqlstr As String
sqlstr = "INSERT INTO material_cd12 " & _
"([CD1+2编号],费用名称,[CD1+2名称]) " & _
"VALUES ('" & Me.TextBox4.Text.Trim & "','" & Me.ComboBox1.Text.Trim & "','" & Me.TextBox5.Text.Trim & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加该新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
Else
MsgBox("成功添加该新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
cailiao112()
End If
ElseIf Me.RadioButton3.Checked = True Then
If Me.TextBox7.Text.Trim = "" Then
MsgBox("请输入CD3+4编号!", MsgBoxStyle.Information, "提示!")
Me.TextBox7.Text = Nothing
Exit Sub
End If
Dim mystr As String
Dim mystr1 As String = Me.TextBox7.Text.Trim
mystr = "select * from material_cd34 where" + " [CD3+4编号] =" + Chr(39) + mystr1 + Chr(39)
If panduan(mystr) = True Then
MsgBox("CD3+4编号-已经存在!", MsgBoxStyle.Information, "提示!")
Me.TextBox7.Text = Nothing
Exit Sub
End If
Dim sqlstr As String
sqlstr = "INSERT INTO material_cd34 " & _
"([CD3+4编号],[CD3+4名称],[CD1+2名称]) " & _
"VALUES ('" & Me.TextBox7.Text.Trim & "','" & Me.TextBox6.Text.Trim & "','" & Me.ComboBox2.Text.Trim & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
Else
MsgBox("成功添加该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
cailiaocd34()
End If
ElseIf Me.RadioButton4.Checked = True Then
If Me.TextBox9.Text.Trim = "" Then
MsgBox("请输入型号编号!", MsgBoxStyle.Information, "提示!")
Me.TextBox9.Text = Nothing
Exit Sub
End If
Dim mystr As String
Dim mystr1 As String = Me.TextBox9.Text.Trim
mystr = "select * from material_canshu where" + " 型号编号 =" + Chr(39) + mystr1 + Chr(39)
If panduan(mystr) = True Then
MsgBox("型号编号-已经存在!", MsgBoxStyle.Information, "提示!")
Me.TextBox9.Text = Nothing
Exit Sub
End If
Dim sqlstr As String
sqlstr = "INSERT INTO material_canshu " & _
"([CD3+4名称],参数,型号编号) " & _
"VALUES ('" & Me.ComboBox3.Text.Trim & "','" & Me.TextBox8.Text.Trim & "','" & Me.TextBox9.Text.Trim & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
Else
MsgBox("成功添加该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
cailiaoCanshu()
End If
End If
End Sub
'删除选项
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Me.RadioButton1.Checked = True Then
Dim sqlstr As String
sqlstr = "DELETE FROM material_zongbiao WHERE 费用编号='" & Trim(TextBox1.Text) & "'"
If MsgBox("该费用信息是否已经使用?", MsgBoxStyle.YesNo, "提示!") = MsgBoxResult.Yes Then
MsgBox("不能进行删除,请与开发者联系?", MsgBoxStyle.Information, "提示")
Exit Sub
End If
If UpdateData(sqlstr) = True Then
MsgBox("已经成功删除了该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
cailiao100()
End If
ElseIf Me.RadioButton2.Checked = True Then
Dim sqlstr As String
sqlstr = "DELETE FROM material_cd12 WHERE [CD1+2编号]='" & Trim(TextBox4.Text) & "'"
If MsgBox("该信息是否已经使用?", MsgBoxStyle.YesNo, "提示!") = MsgBoxResult.Yes Then
MsgBox("不能进行删除,请与开发者联系?", MsgBoxStyle.Information, "提示")
Exit Sub
End If
If UpdateData(sqlstr) = True Then
MsgBox("已经成功删除了该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
cailiao112()
End If
ElseIf Me.RadioButton3.Checked = True Then
Dim sqlstr As String
sqlstr = "DELETE FROM material_cd34 WHERE [CD3+4编号]='" & Trim(TextBox7.Text) & "'"
If MsgBox("该信息是否已经使用?", MsgBoxStyle.YesNo, "提示!") = MsgBoxResult.Yes Then
MsgBox("不能进行删除,请与开发者联系?", MsgBoxStyle.Information, "提示")
Exit Sub
End If
If UpdateData(sqlstr) = True Then
MsgBox("已经成功删除了该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
cailiaocd34()
End If
ElseIf Me.RadioButton4.Checked = True Then
Dim sqlstr As String
sqlstr = "DELETE FROM material_canshu WHERE 型号编号='" & Trim(TextBox9.Text) & "'"
If MsgBox("该信息是否已经使用?", MsgBoxStyle.YesNo, "提示!") = MsgBoxResult.Yes Then
MsgBox("不能进行删除,请与开发者联系?", MsgBoxStyle.Information, "提示")
Exit Sub
End If
If UpdateData(sqlstr) = True Then
MsgBox("已经成功删除了该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
cailiaoCanshu()
End If
End If
End Sub
'更新数据库的内容
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Me.RadioButton1.Checked = True Then
Dim sqlstr As String
sqlstr = "UPDATE material_zongbiao SET 费用名称=" + Chr(39) + Trim(TextBox2.Text) + Chr(39) + ",备注=" + Chr(39) + Trim(TextBox3.Text) + Chr(39) + "where 费用编号=" + Chr(39) + Trim(TextBox1.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
cailiao100()
Else
MsgBox("没有成功更新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
End If
ElseIf Me.RadioButton2.Checked = True Then
Dim sqlstr As String
sqlstr = "UPDATE material_cd12 SET 费用名称=" + Chr(39) + Trim(ComboBox1.Text) + Chr(39) + ",[CD1+2名称]=" + Chr(39) + Trim(TextBox5.Text) + Chr(39) + "where [CD1+2编号]=" + Chr(39) + Trim(TextBox4.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该信息资料", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
cailiao112()
Else
MsgBox("没有成功更新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
End If
ElseIf Me.RadioButton3.Checked = True Then
Dim sqlstr As String
sqlstr = "UPDATE material_cd34 SET [CD1+2名称]=" + Chr(39) + Trim(ComboBox2.Text) + Chr(39) + ",[CD3+4名称]=" + Chr(39) + Trim(TextBox6.Text) + Chr(39) + "where [CD3+4编号]=" + Chr(39) + Trim(TextBox7.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该用户资料", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
cailiaocd34()
Else
MsgBox("没有成功更新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
End If
ElseIf Me.RadioButton4.Checked = True Then
Dim sqlstr As String
sqlstr = "UPDATE material_canshu SET [CD3+4名称]=" + Chr(39) + Trim(ComboBox3.Text) + Chr(39) + ",参数=" + Chr(39) + Trim(TextBox8.Text) + Chr(39) + " where 型号编号=" + Chr(39) + Trim(TextBox9.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该用户资料", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
cailiaoCanshu()
Else
MsgBox("没有成功更新信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
End If
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Dispose()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -