form3.vb
来自「是一个工资的管理系统 利用的是VB.NET和sql2000来完成的」· VB 代码 · 共 555 行 · 第 1/2 页
VB
555 行
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(96, 21)
Me.TextBox5.TabIndex = 12
Me.TextBox5.Text = ""
'
'TextBox6
'
Me.TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.Ds21, "student.sdept"))
Me.TextBox6.Location = New System.Drawing.Point(88, 112)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(96, 21)
Me.TextBox6.TabIndex = 13
Me.TextBox6.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 24)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(40, 23)
Me.Label3.TabIndex = 14
Me.Label3.Text = "学号"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(200, 24)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 23)
Me.Label4.TabIndex = 15
Me.Label4.Text = "姓名"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 64)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(48, 23)
Me.Label5.TabIndex = 16
Me.Label5.Text = "性别"
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(200, 72)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(48, 23)
Me.Label6.TabIndex = 17
Me.Label6.Text = "年龄"
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(8, 112)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(48, 23)
Me.Label7.TabIndex = 18
Me.Label7.Text = "系别:"
'
'Button6
'
Me.Button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button6.Location = New System.Drawing.Point(360, 72)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(80, 23)
Me.Button6.TabIndex = 19
Me.Button6.Text = "查看全部"
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(184, 200)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(64, 16)
Me.Label8.TabIndex = 20
Me.Label8.Text = "输入姓名:"
'
'TextBox7
'
Me.TextBox7.Location = New System.Drawing.Point(320, 200)
Me.TextBox7.Name = "TextBox7"
Me.TextBox7.TabIndex = 21
Me.TextBox7.Text = ""
'
'Button7
'
Me.Button7.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button7.Location = New System.Drawing.Point(488, 200)
Me.Button7.Name = "Button7"
Me.Button7.Size = New System.Drawing.Size(64, 23)
Me.Button7.TabIndex = 22
Me.Button7.Text = "按姓名"
'
'Panel1
'
Me.Panel1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Panel1.Controls.Add(Me.Button9)
Me.Panel1.Controls.Add(Me.Button8)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.Button7)
Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Controls.Add(Me.Button6)
Me.Panel1.Controls.Add(Me.Button3)
Me.Panel1.Controls.Add(Me.Button4)
Me.Panel1.Controls.Add(Me.Button5)
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.TextBox7)
Me.Panel1.Controls.Add(Me.Label8)
Me.Panel1.Controls.Add(Me.TextBox2)
Me.Panel1.Controls.Add(Me.Label3)
Me.Panel1.Controls.Add(Me.TextBox4)
Me.Panel1.Controls.Add(Me.TextBox6)
Me.Panel1.Controls.Add(Me.Label5)
Me.Panel1.Controls.Add(Me.Label4)
Me.Panel1.Controls.Add(Me.TextBox3)
Me.Panel1.Controls.Add(Me.TextBox5)
Me.Panel1.Controls.Add(Me.Label7)
Me.Panel1.Controls.Add(Me.Label6)
Me.Panel1.Location = New System.Drawing.Point(0, 213)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(672, 224)
Me.Panel1.TabIndex = 23
'
'Button9
'
Me.Button9.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button9.Location = New System.Drawing.Point(560, 24)
Me.Button9.Name = "Button9"
Me.Button9.Size = New System.Drawing.Size(64, 23)
Me.Button9.TabIndex = 24
Me.Button9.Text = "返回首页"
'
'Button8
'
Me.Button8.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button8.Location = New System.Drawing.Point(560, 72)
Me.Button8.Name = "Button8"
Me.Button8.Size = New System.Drawing.Size(64, 24)
Me.Button8.TabIndex = 23
Me.Button8.Text = "取消"
'
'Form3
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(672, 437)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Label1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form3"
Me.Text = "学生信息"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Ds21, System.ComponentModel.ISupportInitialize).EndInit()
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If Trim(TextBox1.Text) = "" Then
Exit Sub
End If
SqlDataAdapter1.SelectCommand.CommandText = "select * from student where sno like '" & TextBox1.Text & "'"
Ds21.Clear()
SqlDataAdapter1.Fill(Ds21, "student")
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Try
If Button4.Text = "添加" Then
Me.BindingContext(Ds21.student).AddNew()
Button4.Text = "确定"
Me.buttonable(False)
Else
If Button4.Text <> "确定" Then
Exit Sub
End If
Me.BindingContext(Ds21.student).EndCurrentEdit()
SqlDataAdapter1.Update(Ds21.student)
MsgBox("添加成功!") '
Button4.Text = "添加"
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Me.buttonable(True)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
SqlDataAdapter1.SelectCommand.CommandText = "select * from student"
Ds21.Clear()
SqlDataAdapter1.Fill(Ds21)
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Catch ex As Exception
MsgBox(ex.Message)
'
End Try
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
If MsgBox("真的要删除此记录?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Ds21.student.Rows(Me.BindingContext(Ds21, "student").Position).Delete()
SqlDataAdapter1.Update(Ds21)
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub buttonable(ByVal bool As Boolean)
Button1.Enabled = bool
Button5.Enabled = bool
Button6.Enabled = bool
Button3.Enabled = bool
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
Me.BindingContext(Ds21.student).EndCurrentEdit()
If Ds21.HasChanges(DataRowState.Modified) Then
SqlDataAdapter1.Update(Ds21)
MsgBox("更新成功!")
End If
Catch
End Try
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Try
If Trim(TextBox7.Text) = "" Then
Exit Sub
End If
SqlDataAdapter1.SelectCommand.CommandText = "select * from student where sname like '" & TextBox7.Text & "'"
Ds21.Clear()
SqlDataAdapter1.Fill(Ds21, "student")
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Me.BindingContext(Ds21.student).CancelCurrentEdit()
Button4.Text = "添加"
Me.buttonable(True)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim y As New Form2
y.Show()
Me.Hide()
End Sub
Private Sub Form3_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
Me.Hide()
Dim ob_form As New Form2
ob_form.Show()
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?