📄 form9.vb
字号:
Imports System.Data
'引入数据库操作类命名空间
Imports System.Data.SqlClient
Public Class Form9
Inherits System.Windows.Forms.Form
Dim tablename As String = "jc"
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents TextBox11 As System.Windows.Forms.TextBox
Friend WithEvents TextBox10 As System.Windows.Forms.TextBox
Friend WithEvents TextBox9 As System.Windows.Forms.TextBox
Friend WithEvents TextBox8 As System.Windows.Forms.TextBox
Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
Friend WithEvents Label20 As System.Windows.Forms.Label
Friend WithEvents Label19 As System.Windows.Forms.Label
Friend WithEvents Label18 As System.Windows.Forms.Label
Friend WithEvents Label17 As System.Windows.Forms.Label
Friend WithEvents Label16 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Button6 As System.Windows.Forms.Button
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox11 = New System.Windows.Forms.TextBox
Me.TextBox10 = New System.Windows.Forms.TextBox
Me.TextBox9 = New System.Windows.Forms.TextBox
Me.TextBox8 = New System.Windows.Forms.TextBox
Me.TextBox7 = New System.Windows.Forms.TextBox
Me.Label20 = New System.Windows.Forms.Label
Me.Label19 = New System.Windows.Forms.Label
Me.Label18 = New System.Windows.Forms.Label
Me.Label17 = New System.Windows.Forms.Label
Me.Label16 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label10 = New System.Windows.Forms.Label
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Label9 = New System.Windows.Forms.Label
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.Button6 = New System.Windows.Forms.Button
Me.Button5 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
'
'TextBox11
'
Me.TextBox11.Location = New System.Drawing.Point(84, 208)
Me.TextBox11.Name = "TextBox11"
Me.TextBox11.Size = New System.Drawing.Size(400, 21)
Me.TextBox11.TabIndex = 28
Me.TextBox11.Text = ""
'
'TextBox10
'
Me.TextBox10.Location = New System.Drawing.Point(84, 160)
Me.TextBox10.Name = "TextBox10"
Me.TextBox10.Size = New System.Drawing.Size(400, 21)
Me.TextBox10.TabIndex = 27
Me.TextBox10.Text = ""
'
'TextBox9
'
Me.TextBox9.Location = New System.Drawing.Point(84, 112)
Me.TextBox9.Name = "TextBox9"
Me.TextBox9.Size = New System.Drawing.Size(400, 21)
Me.TextBox9.TabIndex = 26
Me.TextBox9.Text = ""
'
'TextBox8
'
Me.TextBox8.Location = New System.Drawing.Point(84, 64)
Me.TextBox8.Name = "TextBox8"
Me.TextBox8.Size = New System.Drawing.Size(400, 21)
Me.TextBox8.TabIndex = 25
Me.TextBox8.Text = ""
'
'TextBox7
'
Me.TextBox7.Location = New System.Drawing.Point(84, 16)
Me.TextBox7.Name = "TextBox7"
Me.TextBox7.Size = New System.Drawing.Size(400, 21)
Me.TextBox7.TabIndex = 24
Me.TextBox7.Text = ""
'
'Label20
'
Me.Label20.Location = New System.Drawing.Point(12, 216)
Me.Label20.Name = "Label20"
Me.Label20.Size = New System.Drawing.Size(72, 16)
Me.Label20.TabIndex = 23
Me.Label20.Text = "备 注:"
'
'Label19
'
Me.Label19.Location = New System.Drawing.Point(12, 168)
Me.Label19.Name = "Label19"
Me.Label19.Size = New System.Drawing.Size(72, 16)
Me.Label19.TabIndex = 22
Me.Label19.Text = "惩罚原因:"
'
'Label18
'
Me.Label18.Location = New System.Drawing.Point(12, 120)
Me.Label18.Name = "Label18"
Me.Label18.Size = New System.Drawing.Size(72, 16)
Me.Label18.TabIndex = 21
Me.Label18.Text = "所得惩罚:"
'
'Label17
'
Me.Label17.Location = New System.Drawing.Point(12, 72)
Me.Label17.Name = "Label17"
Me.Label17.Size = New System.Drawing.Size(72, 16)
Me.Label17.TabIndex = 20
Me.Label17.Text = "奖励原因:"
'
'Label16
'
Me.Label16.Location = New System.Drawing.Point(12, 24)
Me.Label16.Name = "Label16"
Me.Label16.Size = New System.Drawing.Size(72, 16)
Me.Label16.TabIndex = 19
Me.Label16.Text = "所获奖励:"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(424, 256)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 24)
Me.Button2.TabIndex = 34
Me.Button2.Text = "刷新"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(344, 256)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 24)
Me.Button1.TabIndex = 33
Me.Button1.Text = "查询"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(240, 256)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(80, 21)
Me.TextBox1.TabIndex = 32
Me.TextBox1.Text = ""
'
'Label10
'
Me.Label10.Location = New System.Drawing.Point(176, 264)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(56, 16)
Me.Label10.TabIndex = 31
Me.Label10.Text = "查询条件"
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {"学号", "姓名"})
Me.ComboBox1.Location = New System.Drawing.Point(72, 256)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(80, 20)
Me.ComboBox1.TabIndex = 30
'
'Label9
'
Me.Label9.Location = New System.Drawing.Point(8, 264)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(56, 16)
Me.Label9.TabIndex = 29
Me.Label9.Text = "查询方式"
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.Button6)
Me.GroupBox2.Controls.Add(Me.Button5)
Me.GroupBox2.Controls.Add(Me.Button4)
Me.GroupBox2.Controls.Add(Me.Button3)
Me.GroupBox2.Location = New System.Drawing.Point(8, 288)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(480, 96)
Me.GroupBox2.TabIndex = 35
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "修改"
'
'Button6
'
Me.Button6.Location = New System.Drawing.Point(400, 40)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(64, 32)
Me.Button6.TabIndex = 3
Me.Button6.Text = "删除信息"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(256, 40)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(88, 32)
Me.Button5.TabIndex = 2
Me.Button5.Text = "取消修改信息"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(128, 40)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(64, 32)
Me.Button4.TabIndex = 1
Me.Button4.Text = "更新数据"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(8, 40)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 32)
Me.Button3.TabIndex = 0
Me.Button3.Text = "修改信息"
'
'Form9
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(496, 389)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.TextBox11)
Me.Controls.Add(Me.TextBox10)
Me.Controls.Add(Me.TextBox9)
Me.Controls.Add(Me.TextBox8)
Me.Controls.Add(Me.TextBox7)
Me.Controls.Add(Me.Label20)
Me.Controls.Add(Me.Label19)
Me.Controls.Add(Me.Label18)
Me.Controls.Add(Me.Label17)
Me.Controls.Add(Me.Label16)
Me.Name = "Form9"
Me.Text = "同学奖惩信息修改"
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ShowData()
Module1.myrow = Module1.mytable.Rows.Item(rownumber)
TextBox7.Text = Module1.myrow.Item(2).ToString
TextBox8.Text = Module1.myrow.Item(3).ToString
TextBox9.Text = Module1.myrow.Item(4).ToString
TextBox10.Text = Module1.myrow.Item(5).ToString
TextBox11.Text = Module1.myrow.Item(6).ToString
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
SearchSQL = "SELECT * FROM jc WHERE (" & ComboBox1.Text & "= '" & TextBox1.Text & "')"
'建立查询
Module1.ExecuteSQL(SearchSQL, tablename)
ShowData()
Catch
MsgBox("不存在该记录!", vbOKOnly + vbExclamation, "警告")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ComboBox1.Text = ""
TextBox9.Text = ""
End Sub
Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox9.Enabled = False
TextBox10.Enabled = False
TextBox8.Enabled = False
TextBox7.Enabled = False
TextBox11.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox9.Enabled = True
TextBox10.Enabled = True
TextBox8.Enabled = True
TextBox7.Enabled = True
TextBox11.Enabled = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
SearchSQL = "select * from jc"
Module1.ExecuteSQL(SearchSQL, "jc")
Module1.myrow.Item(2) = Trim(TextBox7.Text)
Module1.myrow.Item(3) = Trim(TextBox8.Text)
Module1.myrow.Item(4) = Trim(TextBox9.Text)
Module1.myrow.Item(5) = Trim(TextBox10.Text)
Module1.myrow.Item(6) = Trim(TextBox11.Text)
Module1.mytable.GetChanges()
Module1.cmd = New SqlCommandBuilder(Module1.ADOcmd)
'使用自动生成的SQL语句
Module1.ADOcmd.Update(Module1.ds, "jc")
'对数据库进行更新
MsgBox("修改同学信息成功!", vbOKOnly + vbExclamation, "警告")
TextBox7.Enabled = False
TextBox9.Enabled = False
TextBox8.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox7.Enabled = False
TextBox9.Enabled = False
TextBox8.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Module1.mytable.Rows.Item(rownumber).Delete()
If MsgBox("确定要删除改记录吗?", MsgBoxStyle.OKCancel + vbExclamation, "警告") = MsgBoxResult.OK Then
Module1.cmd = New SqlCommandBuilder(Module1.ADOcmd)
'使用自动生成的SQL语句
Module1.ADOcmd.Update(Module1.ds, "jc")
Else
Exit Sub
End If
TextBox9.Text = ""
TextBox10.Text = ""
TextBox8.Text = ""
TextBox7.Text = ""
TextBox11.Text = ""
TextBox7.Enabled = False
TextBox9.Enabled = False
TextBox8.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
MsgBox("删除信息成功!", MsgBoxStyle.ApplicationModal, "提示")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -