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

📄 frmscore.vb

📁 vb.net+SQL开发工具 是一个很好的管理系统的源码
💻 VB
字号:
Public Class frmScore
    Inherits System.Windows.Forms.Form
    Private dtData As DataTable
#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 GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    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 Label5 As System.Windows.Forms.Label
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents btnClear As System.Windows.Forms.Button
    Friend WithEvents dgdList As System.Windows.Forms.DataGrid
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents txbPY As System.Windows.Forms.TextBox
    Friend WithEvents txbName As System.Windows.Forms.TextBox
    Friend WithEvents txbId As System.Windows.Forms.TextBox
    Friend WithEvents btnSearch As System.Windows.Forms.Button
    Friend WithEvents btnSubmit As System.Windows.Forms.Button
    Friend WithEvents txbScore As System.Windows.Forms.TextBox
    Friend WithEvents btnUpdate As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmScore))
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.btnClear = New System.Windows.Forms.Button
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.btnSubmit = New System.Windows.Forms.Button
        Me.btnSearch = New System.Windows.Forms.Button
        Me.txbId = New System.Windows.Forms.TextBox
        Me.txbName = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.txbPY = New System.Windows.Forms.TextBox
        Me.GroupBox3 = New System.Windows.Forms.GroupBox
        Me.btnUpdate = New System.Windows.Forms.Button
        Me.Label6 = New System.Windows.Forms.Label
        Me.txbScore = New System.Windows.Forms.TextBox
        Me.dgdList = New System.Windows.Forms.DataGrid
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.GroupBox3.SuspendLayout()
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Controls.Add(Me.btnClear)
        Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Top
        Me.GroupBox1.Location = New System.Drawing.Point(0, 0)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(664, 88)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "结束选课,生成空成绩单"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(200, 8)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(360, 72)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "应该单独有一个终止选课的功能,终止选课后生成空的成绩单,所有学生将不允许更改课程信息,如果需要更改,必须单独申请,特殊处理。终止选课一学年应该只能进行一次操作。读" & _
        "者需要注意实例没有制作开始选课等功能,终止选课后在学生选课中仍然可以更改选择的课程。"
        '
        'btnClear
        '
        Me.btnClear.Location = New System.Drawing.Point(8, 32)
        Me.btnClear.Name = "btnClear"
        Me.btnClear.Size = New System.Drawing.Size(152, 23)
        Me.btnClear.TabIndex = 0
        Me.btnClear.Text = "终止选课,生成空成绩单"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.btnSubmit)
        Me.GroupBox2.Controls.Add(Me.btnSearch)
        Me.GroupBox2.Controls.Add(Me.txbId)
        Me.GroupBox2.Controls.Add(Me.txbName)
        Me.GroupBox2.Controls.Add(Me.Label5)
        Me.GroupBox2.Controls.Add(Me.Label4)
        Me.GroupBox2.Controls.Add(Me.Label3)
        Me.GroupBox2.Controls.Add(Me.Label2)
        Me.GroupBox2.Controls.Add(Me.txbPY)
        Me.GroupBox2.Dock = System.Windows.Forms.DockStyle.Top
        Me.GroupBox2.Location = New System.Drawing.Point(0, 88)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(664, 88)
        Me.GroupBox2.TabIndex = 1
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "选择课程"
        '
        'btnSubmit
        '
        Me.btnSubmit.Location = New System.Drawing.Point(208, 48)
        Me.btnSubmit.Name = "btnSubmit"
        Me.btnSubmit.Size = New System.Drawing.Size(64, 23)
        Me.btnSubmit.TabIndex = 8
        Me.btnSubmit.Text = "最终提交"
        '
        'btnSearch
        '
        Me.btnSearch.Location = New System.Drawing.Point(144, 48)
        Me.btnSearch.Name = "btnSearch"
        Me.btnSearch.Size = New System.Drawing.Size(56, 23)
        Me.btnSearch.TabIndex = 7
        Me.btnSearch.Text = "查询"
        '
        'txbId
        '
        Me.txbId.Location = New System.Drawing.Point(64, 50)
        Me.txbId.Name = "txbId"
        Me.txbId.Size = New System.Drawing.Size(64, 21)
        Me.txbId.TabIndex = 6
        Me.txbId.Text = ""
        '
        'txbName
        '
        Me.txbName.Location = New System.Drawing.Point(201, 19)
        Me.txbName.Name = "txbName"
        Me.txbName.Size = New System.Drawing.Size(64, 21)
        Me.txbName.TabIndex = 5
        Me.txbName.Text = ""
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(144, 24)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(56, 16)
        Me.Label5.TabIndex = 3
        Me.Label5.Text = "课程名称"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 56)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 16)
        Me.Label4.TabIndex = 2
        Me.Label4.Text = "课程编号"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 16)
        Me.Label3.TabIndex = 1
        Me.Label3.Text = "课程拼音"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(288, 16)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(368, 64)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "这里选择一门课程,查询出该课程所有的学生,并输入成绩。实际应用时不用选择课程,而是根据登陆系统的的老师的编号,自动列出该老师所有课程,老师只能对自己的课程进行成绩" & _
        "的输入的操作;最终提交是老师提交的成绩,提交后的成绩将不可以修改。"
        '
        'txbPY
        '
        Me.txbPY.Location = New System.Drawing.Point(64, 19)
        Me.txbPY.Name = "txbPY"
        Me.txbPY.Size = New System.Drawing.Size(64, 21)
        Me.txbPY.TabIndex = 4
        Me.txbPY.Text = ""
        '
        'GroupBox3
        '
        Me.GroupBox3.Controls.Add(Me.btnUpdate)
        Me.GroupBox3.Controls.Add(Me.Label6)
        Me.GroupBox3.Controls.Add(Me.txbScore)
        Me.GroupBox3.Controls.Add(Me.dgdList)
        Me.GroupBox3.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupBox3.Location = New System.Drawing.Point(0, 176)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(664, 149)
        Me.GroupBox3.TabIndex = 2
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "课程成绩输入"
        '
        'btnUpdate
        '
        Me.btnUpdate.Location = New System.Drawing.Point(568, 80)
        Me.btnUpdate.Name = "btnUpdate"
        Me.btnUpdate.Size = New System.Drawing.Size(64, 23)
        Me.btnUpdate.TabIndex = 8
        Me.btnUpdate.Text = "修改成绩"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(536, 45)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(32, 16)
        Me.Label6.TabIndex = 5
        Me.Label6.Text = "成绩"
        '
        'txbScore
        '
        Me.txbScore.Location = New System.Drawing.Point(568, 40)
        Me.txbScore.Name = "txbScore"
        Me.txbScore.Size = New System.Drawing.Size(64, 21)
        Me.txbScore.TabIndex = 6
        Me.txbScore.Text = ""
        '
        'dgdList
        '
        Me.dgdList.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.dgdList.CaptionVisible = False
        Me.dgdList.DataMember = ""
        Me.dgdList.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgdList.Location = New System.Drawing.Point(8, 16)
        Me.dgdList.Name = "dgdList"
        Me.dgdList.Size = New System.Drawing.Size(520, 128)
        Me.dgdList.TabIndex = 0
        '
        'frmScore
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(664, 325)
        Me.Controls.Add(Me.GroupBox3)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmScore"
        Me.Text = "成绩输入"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnClear_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnClear.Click
        Dim db As DataBase = New DataBase
        db.RunDelOrInsSQL("exec sf_终止选课")
        db.Dispose()
    End Sub
    Private Sub SetDGDList()
        Dim strSQL As String = "select b.课程名称,a.学号,c.姓名,a.成绩,"
        strSQL += " a.编号,a.课程编号  from 成绩表 as a, 课程信息 as b, "
        strSQL += "学生信息 as c where a.课程编号=b.课程编号 and a.学号"
        strSQL += "=c.学号 and 是否已确定成绩 = 'N' "
        Dim strFilter As String = ""
        If Me.txbPY.Text.Trim.Length <> 0 Then
            strFilter += " and 拼音码 like '" + txbPY.Text.Trim + "%'"
        End If
        If Me.txbName.Text.Trim.Length <> 0 Then
            strFilter += " and a.学号 like '" + txbId.Text.Trim + "%'"
        End If
        If Me.txbName.Text.Trim.Length <> 0 Then
            strFilter += " and c.姓名 like '" + txbName.Text + "%'"
        End If
        If strFilter.Trim.Length = 0 Then
            Exit Sub
        Else
            strFilter += " order by b.课程名称,a.学号"
            Dim db As DataBase = New DataBase
            Dim dv As DataView = db.RunSelectSQL(strSQL + strFilter)
            dv.AllowDelete = False
            dv.AllowEdit = False
            dv.AllowNew = False
            dtData = dv.Table
            Me.dgdList.DataSource = dv
            Me.dgdList.AllowSorting = False
            db.Dispose()
        End If
    End Sub

    Private Sub txbId_KeyDown(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbId.KeyDown
        If e.KeyCode = Keys.Enter Then
            SetDGDList()
        End If
    End Sub

    Private Sub txbName_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbName.KeyDown
        If e.KeyCode = Keys.Enter Then
            SetDGDList()
        End If
    End Sub

    Private Sub txbPY_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbPY.KeyDown
        If e.KeyCode = Keys.Enter Then
            SetDGDList()
        End If
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnUpdate.Click
        Try
            Dim score As Integer = CInt(txbScore.Text)
        Catch ex As Exception
            MessageBox.Show("成绩格式不正确!")
        End Try
        If dgdList.CurrentCell.RowNumber <> -1 Then
            Dim db As DataBase = New DataBase
            Dim strSQL As String = "update 成绩表 set 成绩="
            strSQL += txbScore.Text.Trim + " where 编号="
            strSQL += dtData.Rows(dgdList. _
            CurrentCell.RowNumber)(4).ToString.Trim
            db.RunDelOrInsSQL(strSQL)
            db.Dispose()
            SetDGDList()
        End If
    End Sub

    Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSubmit.Click
        If dgdList.CurrentCell.RowNumber = -1 Then
            Exit Sub
        End If
        Dim strSubject = dtData.Rows( _
        dgdList.CurrentCell.RowNumber)(5).ToString.Trim
        Dim dlgResult As DialogResult = MessageBox.Show _
        ("提交后成绩不可以修改,是否确认提交?", _
        "提示", MessageBoxButtons.YesNo)
        If dlgResult = DialogResult.Yes Then
            Dim strSQL As String = "exec sf_成绩提交 " + strSubject
            Dim db As DataBase = New DataBase
            db.RunDelOrInsSQL(strSQL)
            db.Dispose()
            MessageBox.Show("提交成绩成功!")
            SetDGDList()
        End If
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSearch.Click
        SetDGDList()
    End Sub
End Class

⌨️ 快捷键说明

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