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

📄 frmmodifyresultinfo.vb

📁 是一套开发的VB的学生成绩管理系统,希望有需要的人去参考
💻 VB
字号:
Imports System.Data.SqlClient
Public Class frmmodifyresultinfo
    Inherits System.Windows.Forms.Form
    Dim tablename As String = "score"

#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 txtdate As System.Windows.Forms.TextBox
    Friend WithEvents txtsid As System.Windows.Forms.TextBox
    Friend WithEvents txtcourseno As System.Windows.Forms.TextBox
    Friend WithEvents txtresult As System.Windows.Forms.TextBox
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    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 GroupBox2 As System.Windows.Forms.GroupBox
    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.txtdate = New System.Windows.Forms.TextBox
        Me.txtsid = New System.Windows.Forms.TextBox
        Me.txtcourseno = New System.Windows.Forms.TextBox
        Me.txtresult = 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.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(56, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "考试时间"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(208, 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(16, 72)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 23)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "课程编号"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(208, 72)
        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
        '
        'txtdate
        '
        Me.txtdate.Location = New System.Drawing.Point(88, 24)
        Me.txtdate.Name = "txtdate"
        Me.txtdate.TabIndex = 4
        Me.txtdate.Text = ""
        '
        'txtsid
        '
        Me.txtsid.Location = New System.Drawing.Point(264, 24)
        Me.txtsid.Name = "txtsid"
        Me.txtsid.TabIndex = 5
        Me.txtsid.Text = ""
        '
        'txtcourseno
        '
        Me.txtcourseno.Location = New System.Drawing.Point(88, 72)
        Me.txtcourseno.Name = "txtcourseno"
        Me.txtcourseno.TabIndex = 6
        Me.txtcourseno.Text = ""
        '
        'txtresult
        '
        Me.txtresult.Location = New System.Drawing.Point(264, 72)
        Me.txtresult.Name = "txtresult"
        Me.txtresult.TabIndex = 7
        Me.txtresult.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(16, 120)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(464, 72)
        Me.GroupBox1.TabIndex = 8
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "查看成绩信息"
        '
        'btlast
        '
        Me.btlast.Location = New System.Drawing.Point(368, 32)
        Me.btlast.Name = "btlast"
        Me.btlast.TabIndex = 3
        Me.btlast.Text = "最后一条记录"
        '
        'btnext
        '
        Me.btnext.Location = New System.Drawing.Point(256, 32)
        Me.btnext.Name = "btnext"
        Me.btnext.TabIndex = 2
        Me.btnext.Text = "下一条记录"
        '
        'btprev
        '
        Me.btprev.Location = New System.Drawing.Point(136, 32)
        Me.btprev.Name = "btprev"
        Me.btprev.TabIndex = 1
        Me.btprev.Text = "上一条记录"
        '
        'btfirst
        '
        Me.btfirst.Location = New System.Drawing.Point(16, 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(16, 208)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(464, 72)
        Me.GroupBox2.TabIndex = 9
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "修改成绩信息"
        '
        'btdelete
        '
        Me.btdelete.Location = New System.Drawing.Point(368, 32)
        Me.btdelete.Name = "btdelete"
        Me.btdelete.TabIndex = 3
        Me.btdelete.Text = "删除记录"
        '
        'btcancel
        '
        Me.btcancel.Location = New System.Drawing.Point(256, 32)
        Me.btcancel.Name = "btcancel"
        Me.btcancel.TabIndex = 2
        Me.btcancel.Text = "取消修改"
        '
        'btupdate
        '
        Me.btupdate.Location = New System.Drawing.Point(136, 32)
        Me.btupdate.Name = "btupdate"
        Me.btupdate.TabIndex = 1
        Me.btupdate.Text = "更新数据"
        '
        'btmodify
        '
        Me.btmodify.Location = New System.Drawing.Point(16, 32)
        Me.btmodify.Name = "btmodify"
        Me.btmodify.TabIndex = 0
        Me.btmodify.Text = "修改记录"
        '
        'frmmodifyresultinfo
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(488, 285)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.txtresult)
        Me.Controls.Add(Me.txtcourseno)
        Me.Controls.Add(Me.txtsid)
        Me.Controls.Add(Me.txtdate)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "frmmodifyresultinfo"
        Me.Text = "frmmodifyresultinfo"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmmodifyresultinfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        txtdate.Enabled = False
        txtsid.Enabled = False
        txtcourseno.Enabled = False
        txtresult.Enabled = False
        sqlcon.Close()
        searchsql = "select * from score"
        MsgBox(searchsql)
        Module1.executesql(searchsql, tablename)
        showdata()
    End Sub
    Private Sub showdata()
        myrow = Module1.mytable.Rows.Item(rownumber)
        txtdate.Text = Module1.myrow.Item(1).ToString
        TxtSID.Text = Module1.myrow.Item(2).ToString
        TxtCourseno.Text = Module1.myrow.Item(3).ToString
        Txtresult.Text = Module1.myrow.Item(4).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
        txtdate.Enabled = False
        TxtSID.Enabled = True
        TxtCourseno.Enabled = True
        Txtresult.Enabled = True
    End Sub

    Private Sub BtUpdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btupdate.Click
        If Not IsNumeric(Trim(txtsid.Text)) Then
            MsgBox("请输入学号!", vbOKOnly + vbExclamation, "警告")
            Exit Sub
            txtsid.Focus()
        End If
        If Not IsDate(Trim(txtdate.Text)) Then
            MsgBox("考试时间应输入日期格式(yyyy-mm-dd)!)", vbOKOnly + vbExclamation, "警告")
            Exit Sub
            txtdate.Focus()
        End If
        If Not IsNumeric(Trim(txtresult.Text)) Then
            MsgBox("请输入分数!", vbOKOnly + vbExclamation, "警告")
            Exit Sub
            txtresult.Focus()
        End If
        If Not IsNumeric(Trim(txtcourseno.Text)) Then
            MsgBox("请输入课程编号!", vbOKOnly + vbExclamation, "警告")
            Exit Sub
            txtcourseno.Focus()
        End If
        searchsql = "select * from score"
        Module1.executesql(searchsql, tablename)
        Module1.myrow.Item(2) = Trim(txtsid.Text)
        Module1.myrow.Item(1) = Trim(txtdate.Text)
        Module1.myrow.Item(3) = Trim(txtcourseno.Text)
        Module1.myrow.Item(4) = Trim(txtresult.Text)
        Module1.mytable.GetChanges()
        Module1.sqlcmd = New SqlCommandBuilder(Module1.sqladapter)
        Module1.sqladapter.Update(Module1.ds, tablename)
        MsgBox("修改成绩信息成功!", vbOKOnly + vbExclamation, "警告")
        txtdate.Enabled = False
        txtsid.Enabled = False
        txtcourseno.Enabled = False
        txtresult.Enabled = False
    End Sub

    Private Sub BtCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcancel.Click
        txtdate.Enabled = False
        txtsid.Enabled = False
        txtcourseno.Enabled = False
        txtresult.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, "score")
            btnext.PerformClick()
        End If
    End Sub

   
End Class

⌨️ 快捷键说明

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