📄 ba.vb
字号:
Imports System.Data
Imports System.Data.OleDb
Public Class ba
Inherits System.Windows.Forms.Form
Dim MyConnectionstr As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Sellsystem.mdb"
Dim MySQL As String = "Select * From Staff_Table"
Dim MyConnection As New OleDbConnection(MyConnectionstr)
Dim MyCommand As New OleDbCommand(MySQL, MyConnection)
Dim Mydapater As New OleDbDataAdapter(MyCommand)
Dim MyDataset As New DataSet
Dim MyRow As DataRow
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
Friend WithEvents TextBox8 As System.Windows.Forms.TextBox
Friend WithEvents TextBox9 As System.Windows.Forms.TextBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents TextBox10 As System.Windows.Forms.TextBox
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents TextBox11 As System.Windows.Forms.TextBox
Friend WithEvents Label11 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.TextBox11 = New System.Windows.Forms.TextBox
Me.Label11 = New System.Windows.Forms.Label
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.Label6 = New System.Windows.Forms.Label
Me.TextBox7 = New System.Windows.Forms.TextBox
Me.TextBox8 = New System.Windows.Forms.TextBox
Me.TextBox9 = New System.Windows.Forms.TextBox
Me.Label7 = New System.Windows.Forms.Label
Me.TextBox10 = New System.Windows.Forms.TextBox
Me.Label8 = New System.Windows.Forms.Label
Me.Label9 = New System.Windows.Forms.Label
Me.Label10 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.ComboBox1)
Me.GroupBox1.Controls.Add(Me.TextBox11)
Me.GroupBox1.Controls.Add(Me.Label11)
Me.GroupBox1.Controls.Add(Me.TextBox6)
Me.GroupBox1.Controls.Add(Me.Label6)
Me.GroupBox1.Controls.Add(Me.TextBox7)
Me.GroupBox1.Controls.Add(Me.TextBox8)
Me.GroupBox1.Controls.Add(Me.TextBox9)
Me.GroupBox1.Controls.Add(Me.Label7)
Me.GroupBox1.Controls.Add(Me.TextBox10)
Me.GroupBox1.Controls.Add(Me.Label8)
Me.GroupBox1.Controls.Add(Me.Label9)
Me.GroupBox1.Controls.Add(Me.Label10)
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.TextBox2)
Me.GroupBox1.Controls.Add(Me.TextBox5)
Me.GroupBox1.Controls.Add(Me.Label5)
Me.GroupBox1.Controls.Add(Me.TextBox3)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Location = New System.Drawing.Point(24, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(200, 344)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "员工个人信息"
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {" 男", " 女"})
Me.ComboBox1.Location = New System.Drawing.Point(61, 108)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(106, 20)
Me.ComboBox1.TabIndex = 48
'
'TextBox11
'
Me.TextBox11.Location = New System.Drawing.Point(61, 299)
Me.TextBox11.Name = "TextBox11"
Me.TextBox11.Size = New System.Drawing.Size(104, 21)
Me.TextBox11.TabIndex = 47
Me.TextBox11.Text = ""
'
'Label11
'
Me.Label11.Location = New System.Drawing.Point(5, 303)
Me.Label11.Name = "Label11"
Me.Label11.Size = New System.Drawing.Size(56, 16)
Me.Label11.TabIndex = 46
Me.Label11.Text = "员工学历"
Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox6
'
Me.TextBox6.Location = New System.Drawing.Point(61, 162)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(104, 21)
Me.TextBox6.TabIndex = 45
Me.TextBox6.Text = ""
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(6, 193)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(54, 16)
Me.Label6.TabIndex = 44
Me.Label6.Text = "员工电话"
'
'TextBox7
'
Me.TextBox7.Location = New System.Drawing.Point(61, 190)
Me.TextBox7.Name = "TextBox7"
Me.TextBox7.Size = New System.Drawing.Size(104, 21)
Me.TextBox7.TabIndex = 42
Me.TextBox7.Text = ""
'
'TextBox8
'
Me.TextBox8.Location = New System.Drawing.Point(61, 273)
Me.TextBox8.Name = "TextBox8"
Me.TextBox8.Size = New System.Drawing.Size(104, 21)
Me.TextBox8.TabIndex = 41
Me.TextBox8.Text = ""
'
'TextBox9
'
Me.TextBox9.Location = New System.Drawing.Point(61, 245)
Me.TextBox9.Name = "TextBox9"
Me.TextBox9.Size = New System.Drawing.Size(104, 21)
Me.TextBox9.TabIndex = 40
Me.TextBox9.Text = ""
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(4, 277)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(56, 16)
Me.Label7.TabIndex = 38
Me.Label7.Text = "员工工资"
Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox10
'
Me.TextBox10.Location = New System.Drawing.Point(61, 217)
Me.TextBox10.Name = "TextBox10"
Me.TextBox10.Size = New System.Drawing.Size(104, 21)
Me.TextBox10.TabIndex = 39
Me.TextBox10.Text = ""
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(4, 249)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(56, 16)
Me.Label8.TabIndex = 37
Me.Label8.Text = "员工年龄"
Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label9
'
Me.Label9.Location = New System.Drawing.Point(4, 220)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(56, 16)
Me.Label9.TabIndex = 36
Me.Label9.Text = "员工部门"
Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label10
'
Me.Label10.Location = New System.Drawing.Point(6, 165)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(56, 16)
Me.Label10.TabIndex = 43
Me.Label10.Text = "员工地址"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(61, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 21)
Me.TextBox1.TabIndex = 35
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(6, 55)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 16)
Me.Label1.TabIndex = 34
Me.Label1.Text = "员工密码"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(61, 52)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(104, 21)
Me.TextBox2.TabIndex = 32
Me.TextBox2.Text = ""
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(61, 135)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(104, 21)
Me.TextBox5.TabIndex = 31
Me.TextBox5.Text = ""
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(4, 139)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(56, 16)
Me.Label5.TabIndex = 28
Me.Label5.Text = "员工身份"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(61, 79)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(104, 21)
Me.TextBox3.TabIndex = 29
Me.TextBox3.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(4, 111)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(56, 16)
Me.Label4.TabIndex = 27
Me.Label4.Text = "员工性别"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(4, 83)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.TabIndex = 26
Me.Label3.Text = "员工姓名"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(6, 27)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 16)
Me.Label2.TabIndex = 33
Me.Label2.Text = "员工昵称"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 368)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "员工登记"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(144, 368)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 2
Me.Button2.Text = "取消登记"
'
'ba
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(248, 413)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "ba"
Me.Text = "员工登记"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ba_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Cmm As New OleDbCommandBuilder(Mydapater) '新增一个CommandBuilder的对象来邦定数据增加操作
If MyConnection.State = ConnectionState.Closed Then
MyConnection.Open()
End If
Mydapater.Fill(MyDataset, "Staff_Table")
MyRow = MyDataset.Tables("Staff_Table").NewRow '在数据集中增加一个新的空行
MyRow(1) = TextBox1.Text
MyRow(2) = TextBox2.Text
MyRow(3) = TextBox3.Text
MyRow(4) = ComboBox1.Text
MyRow(5) = TextBox5.Text
MyRow(6) = TextBox6.Text
MyRow(7) = TextBox7.Text
MyRow(8) = TextBox8.Text
MyRow(9) = TextBox9.Text
MyRow(10) = TextBox10.Text
MyRow(11) = TextBox11.Text
MyDataset.Tables("Staff_Table").Rows.Add(MyRow) '提交数据到数据集中
Mydapater.Update(MyDataset, "Staff_Table") '通过更改的数据集更新数据库
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MyDataset.Dispose()
Mydapater.Dispose()
MyConnection.Dispose()
Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -