📄 frmaddclassinfo.vb
字号:
Imports System.Data.SqlClient
Public Class frmaddclassinfo
Inherits System.Windows.Forms.Form
#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 Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtclassno As System.Windows.Forms.TextBox
Friend WithEvents txtinspector As System.Windows.Forms.TextBox
Friend WithEvents txtclassroom As System.Windows.Forms.TextBox
Friend WithEvents combograde As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.txtclassno = New System.Windows.Forms.TextBox
Me.txtinspector = New System.Windows.Forms.TextBox
Me.txtclassroom = New System.Windows.Forms.TextBox
Me.combograde = New System.Windows.Forms.ComboBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(32, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "班号"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(192, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(32, 23)
Me.Label2.TabIndex = 1
Me.Label2.Text = "年级"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(0, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(48, 23)
Me.Label3.TabIndex = 2
Me.Label3.Text = "班主任"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(192, 80)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(32, 23)
Me.Label4.TabIndex = 3
Me.Label4.Text = "教室"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'txtclassno
'
Me.txtclassno.Location = New System.Drawing.Point(72, 24)
Me.txtclassno.Name = "txtclassno"
Me.txtclassno.Size = New System.Drawing.Size(80, 21)
Me.txtclassno.TabIndex = 4
Me.txtclassno.Text = ""
'
'txtinspector
'
Me.txtinspector.Location = New System.Drawing.Point(72, 80)
Me.txtinspector.Name = "txtinspector"
Me.txtinspector.Size = New System.Drawing.Size(80, 21)
Me.txtinspector.TabIndex = 5
Me.txtinspector.Text = ""
'
'txtclassroom
'
Me.txtclassroom.Location = New System.Drawing.Point(248, 80)
Me.txtclassroom.Name = "txtclassroom"
Me.txtclassroom.TabIndex = 6
Me.txtclassroom.Text = ""
'
'combograde
'
Me.combograde.Location = New System.Drawing.Point(248, 24)
Me.combograde.Name = "combograde"
Me.combograde.Size = New System.Drawing.Size(88, 20)
Me.combograde.TabIndex = 7
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 168)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 8
Me.Button1.Text = "添加"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(232, 168)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 9
Me.Button2.Text = "取消"
'
'frmaddclassinfo
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(392, 245)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.combograde)
Me.Controls.Add(Me.txtclassroom)
Me.Controls.Add(Me.txtinspector)
Me.Controls.Add(Me.txtclassno)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "frmaddclassinfo"
Me.Text = "frmaddclassinfo"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tablename As String = "class"
searchsql = "select * from class"
Module1.executesql(searchsql, tablename)
Dim i As Integer
For i = 0 To (Module1.mytable.Rows.Count - 1)
Module1.myrow = Module1.mytable.Rows.Item(i)
If txtclassno.Text.Trim = Trim(Module1.myrow.Item(0).ToString) Then
MsgBox("学号重复", vbOKOnly + vbExclamation, "提示")
Exit Sub
End If
Next
Dim newrow As DataRow
newrow = Module1.mytable.NewRow
newrow.Item(0) = Trim(txtclassno.Text)
newrow.Item(1) = Trim(combograde.SelectedItem)
newrow.Item(2) = Trim(txtinspector.Text)
newrow.Item(3) = Trim(txtclassroom.Text)
mytable.Rows.Add(newrow)
Module1.sqlcmd = New SqlCommandBuilder(Module1.sqladapter)
Try
Module1.sqladapter.Update(Module1.ds, tablename)
MsgBox("添加班级信息成功!", vbOKOnly + vbExclamation, "警告")
Catch
MsgBox(Err.Description)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -