⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmodifyclassinfo.vb

📁 是一套开发的VB的学生成绩管理系统,希望有需要的人去参考
💻 VB
字号:
Imports System.Data.SqlClient
Public Class frmmodifyclassinfo
    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 GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    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 btfirst As System.Windows.Forms.Button
    Friend WithEvents btprev As System.Windows.Forms.Button
    Friend WithEvents btnext As System.Windows.Forms.Button
    Friend WithEvents btlast As System.Windows.Forms.Button
    Friend WithEvents combograde As System.Windows.Forms.ComboBox
    Friend WithEvents btmodify As System.Windows.Forms.Button
    Friend WithEvents btupdate As System.Windows.Forms.Button
    Friend WithEvents btcancel As System.Windows.Forms.Button
    Friend WithEvents btdelete 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.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.btlast = New System.Windows.Forms.Button
        Me.btnext = New System.Windows.Forms.Button
        Me.btprev = New System.Windows.Forms.Button
        Me.btfirst = New System.Windows.Forms.Button
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.btdelete = New System.Windows.Forms.Button
        Me.btcancel = New System.Windows.Forms.Button
        Me.btupdate = New System.Windows.Forms.Button
        Me.btmodify = New System.Windows.Forms.Button
        Me.combograde = New System.Windows.Forms.ComboBox
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 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.MiddleCenter
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(232, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(48, 23)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "年级"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 72)
        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.MiddleCenter
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(224, 72)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 23)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "教室"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'txtclassno
        '
        Me.txtclassno.Location = New System.Drawing.Point(88, 24)
        Me.txtclassno.Name = "txtclassno"
        Me.txtclassno.TabIndex = 4
        Me.txtclassno.Text = ""
        '
        'txtinspector
        '
        Me.txtinspector.Location = New System.Drawing.Point(88, 72)
        Me.txtinspector.Name = "txtinspector"
        Me.txtinspector.TabIndex = 6
        Me.txtinspector.Text = ""
        '
        'txtclassroom
        '
        Me.txtclassroom.Location = New System.Drawing.Point(320, 72)
        Me.txtclassroom.Name = "txtclassroom"
        Me.txtclassroom.TabIndex = 7
        Me.txtclassroom.Text = ""
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.btlast)
        Me.GroupBox1.Controls.Add(Me.btnext)
        Me.GroupBox1.Controls.Add(Me.btprev)
        Me.GroupBox1.Controls.Add(Me.btfirst)
        Me.GroupBox1.Location = New System.Drawing.Point(8, 112)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(440, 80)
        Me.GroupBox1.TabIndex = 8
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "查看班级信息"
        '
        'btlast
        '
        Me.btlast.Location = New System.Drawing.Point(344, 32)
        Me.btlast.Name = "btlast"
        Me.btlast.TabIndex = 3
        Me.btlast.Text = "最后一条记录"
        '
        'btnext
        '
        Me.btnext.Location = New System.Drawing.Point(240, 32)
        Me.btnext.Name = "btnext"
        Me.btnext.TabIndex = 2
        Me.btnext.Text = "下一条记录"
        '
        'btprev
        '
        Me.btprev.Location = New System.Drawing.Point(128, 32)
        Me.btprev.Name = "btprev"
        Me.btprev.TabIndex = 1
        Me.btprev.Text = "上一条记录"
        '
        'btfirst
        '
        Me.btfirst.Location = New System.Drawing.Point(24, 32)
        Me.btfirst.Name = "btfirst"
        Me.btfirst.TabIndex = 0
        Me.btfirst.Text = "第一条记录"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.btdelete)
        Me.GroupBox2.Controls.Add(Me.btcancel)
        Me.GroupBox2.Controls.Add(Me.btupdate)
        Me.GroupBox2.Controls.Add(Me.btmodify)
        Me.GroupBox2.Location = New System.Drawing.Point(8, 208)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(440, 88)
        Me.GroupBox2.TabIndex = 9
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "修改班级信息"
        '
        'btdelete
        '
        Me.btdelete.Location = New System.Drawing.Point(344, 40)
        Me.btdelete.Name = "btdelete"
        Me.btdelete.TabIndex = 3
        Me.btdelete.Text = "删除记录"
        '
        'btcancel
        '
        Me.btcancel.Location = New System.Drawing.Point(240, 40)
        Me.btcancel.Name = "btcancel"
        Me.btcancel.TabIndex = 2
        Me.btcancel.Text = "取消修改"
        '
        'btupdate
        '
        Me.btupdate.Location = New System.Drawing.Point(136, 40)
        Me.btupdate.Name = "btupdate"
        Me.btupdate.TabIndex = 1
        Me.btupdate.Text = "更新数据"
        '
        'btmodify
        '
        Me.btmodify.Location = New System.Drawing.Point(24, 40)
        Me.btmodify.Name = "btmodify"
        Me.btmodify.TabIndex = 0
        Me.btmodify.Text = "修改记录"
        '
        'combograde
        '
        Me.combograde.Items.AddRange(New Object() {"大一", "大二", "大三"})
        Me.combograde.Location = New System.Drawing.Point(320, 24)
        Me.combograde.Name = "combograde"
        Me.combograde.Size = New System.Drawing.Size(104, 20)
        Me.combograde.TabIndex = 10
        '
        'frmmodifyclassinfo
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(456, 325)
        Me.Controls.Add(Me.combograde)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        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 = "frmmodifyclassinfo"
        Me.Text = "frmmodifyclassinfo"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmmodifyclassinfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtclassno.Enabled = False
        combograde.Enabled = False
        txtinspector.Enabled = False
        txtclassroom.Enabled = False
        Dim tablename As String = "class"
        searchsql = "select * from class"
        MsgBox(searchsql)
        Module1.executesql(searchsql, tablename)
        showdata()
    End Sub
    Private Sub showdata()
        myrow = Module1.mytable.Rows.Item(rownumber)
        TxtClassno.Text = Module1.myrow.Item(0).ToString
        ComboGrade.Text = Module1.myrow.Item(1).ToString
        TxtInspector.Text = Module1.myrow.Item(2).ToString
        TxtClassroom.Text = Module1.myrow.Item(3).ToString
    End Sub

    Private Sub btfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btfirst.Click
        rownumber = 0
        showdata()
    End Sub

    Private Sub btprev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btprev.Click
        btnext.Enabled = True
        rownumber = rownumber - 1
        If rownumber < 0 Then
            rownumber = 0
            btprev.Enabled = False
        End If
        showdata()
    End Sub

    Private Sub btnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnext.Click
        btprev.Enabled = True
        rownumber = rownumber + 1
        If rownumber > Module1.mytable.Rows.Count - 1 Then
            rownumber = Module1.mytable.Rows.Count - 1
            btnext.Enabled = False
        End If
        showdata()
    End Sub

    Private Sub btlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlast.Click
        rownumber = Module1.mytable.Rows.Count - 1
        showdata()
    End Sub

    Private Sub btmodify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmodify.Click
        txtclassno.Enabled = False
        combograde.Enabled = True
        txtinspector.Enabled = True
        txtclassroom.Enabled = True
    End Sub

    Private Sub btupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btupdate.Click
        If Not testtxt(Trim(txtclassno.Text)) Then
            MsgBox("请选择班号!", vbOKOnly + vbExclamation, "警告")
            txtclassno.Focus()
            Exit Sub
        End If
        If Not testtxt(Trim(combograde.Text)) Then
            MsgBox("请输入年级!", vbOKOnly + vbExclamation, "警告")
            combograde.Focus()
            Exit Sub
        End If
        If Not testtxt(Trim(txtinspector.Text)) Then
            MsgBox("请输入班主任姓名!", vbOKOnly + vbExclamation, "警告")
            txtinspector.Focus()
            Exit Sub
        End If
        If Not IsNumeric(Trim(txtclassroom.Text)) Then
            MsgBox("请输入数字!", vbOKOnly + vbExclamation, "警告")
            Exit Sub
            txtclassroom.Focus()
        End If
        Module1.myrow.Item(0) = Trim(txtclassno.Text)
        Module1.myrow.Item(1) = Trim(combograde.SelectedItem)
        Module1.myrow.Item(2) = Trim(txtinspector.Text)
        Module1.myrow.Item(3) = Trim(txtclassroom.Text)
        Module1.mytable.GetChanges()
        Module1.sqlcmd = New SqlCommandBuilder(Module1.sqladapter)
        Module1.sqladapter.UpdateCommand = Module1.sqlcmd.GetUpdateCommand()
        Module1.sqladapter.Update(Module1.ds, "class")
        MsgBox("修改班级信息成功!", vbOKOnly + vbExclamation, "警告")
        
    End Sub

    Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcancel.Click
        txtclassno.Enabled = False
        combograde.Enabled = False
        txtinspector.Enabled = False
        txtclassroom.Enabled = False
    End Sub

    Private Sub btdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdelete.Click
        Module1.mytable.Rows.Item(rownumber).Delete()
        If MsgBox("确定要删除改记录吗?", MsgBoxStyle.OKCancel + vbExclamation, "警告") = MsgBoxResult.OK Then
            Module1.sqlcmd = New SqlCommandBuilder(Module1.sqladapter)

            Module1.sqladapter.Update(Module1.ds, "class")
            btnext.PerformClick()
        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -