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

📄 frmcjadd.frm

📁 学生成绩管理系统,学生成绩的增删改查功能,学期管理功能
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmcjadd 
   Caption         =   "添加成绩信息"
   ClientHeight    =   3060
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5895
   LinkTopic       =   "Form1"
   ScaleHeight     =   3060
   ScaleWidth      =   5895
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton Command4 
      Caption         =   "删除成绩"
      Height          =   405
      Left            =   2520
      TabIndex        =   11
      Top             =   2340
      Width           =   1215
   End
   Begin VB.CommandButton Command3 
      Caption         =   "修改成绩"
      Height          =   405
      Left            =   840
      TabIndex        =   10
      Top             =   2340
      Width           =   1365
   End
   Begin VB.TextBox Text1 
      Height          =   435
      Left            =   2880
      TabIndex        =   9
      Top             =   1680
      Width           =   1515
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   405
      Left            =   3960
      TabIndex        =   8
      Top             =   2340
      Width           =   1275
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确认添加"
      Height          =   405
      Left            =   120
      TabIndex        =   7
      Top             =   1680
      Width           =   1395
   End
   Begin VB.ComboBox Combo3 
      Height          =   315
      Left            =   1050
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   1110
      Width           =   4575
   End
   Begin VB.ComboBox Combo2 
      Height          =   315
      Left            =   1050
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   570
      Width           =   4575
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   1050
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   60
      Width           =   1935
   End
   Begin VB.Label Label6 
      Caption         =   "输入考试分数:"
      Height          =   435
      Left            =   1560
      TabIndex        =   6
      Top             =   1680
      Width           =   1545
   End
   Begin VB.Label Label4 
      Caption         =   "选择课程:"
      Height          =   345
      Left            =   180
      TabIndex        =   5
      Top             =   570
      Width           =   1245
   End
   Begin VB.Label Label2 
      Caption         =   "选择学号:"
      Height          =   375
      Left            =   180
      TabIndex        =   2
      Top             =   1110
      Width           =   1365
   End
   Begin VB.Label Label1 
      Caption         =   "选择班级:"
      Height          =   315
      Left            =   180
      TabIndex        =   0
      Top             =   90
      Width           =   1245
   End
End
Attribute VB_Name = "frmcjadd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
  Dim mrc As ADODB.Recordset
  Dim txtsql As String
  Dim msgtext As String
  Combo1.Clear
  Combo2.Clear
  '添加班级信息到下拉列表框中
  txtsql = "select distinct classname from student_info"
  Set mrc = ExecuteSQL(txtsql, msgtext)
  While (mrc.EOF = False)
    Combo1.AddItem mrc.Fields("classname")
    mrc.MoveNext
  Wend
  '添加课程信息到下拉列表框中
  txtsql = "select course_no,course_name from course_info"
  Set mrc = ExecuteSQL(txtsql, msgtext)
  While (mrc.EOF = False)
    Combo2.AddItem mrc.Fields("course_no") & "--" & mrc.Fields("course_name")
    mrc.MoveNext
  Wend
  mrc.Close
End Sub
Private Sub Combo1_Click()
  Dim mrc As ADODB.Recordset
  Dim txtsql As String
  Dim msgtext As String
  Combo3.Clear
  '添加学生信息到下拉列表框中
  txtsql = "select student_ID,student_name from student_info where classname='" & Combo1.Text & "'"
  Set mrc = ExecuteSQL(txtsql, msgtext)
  While (mrc.EOF = False)
    Combo3.AddItem mrc.Fields("student_ID") & "--" & mrc.Fields("student_name")
    mrc.MoveNext
  Wend
End Sub

Private Sub Command1_Click()
  Dim xh As String '定义学号
  Dim kz As String '定义课程号
  Dim mrc As ADODB.Recordset
  Dim txtsql As String
  Dim msgtext As String
  If Combo2.Text = "" Then
    MsgBox "您还没有选择课程!"
    Exit Sub
    End If
  If Combo3.Text = "" Then
    MsgBox "您还没有选择学生学号!"
    Exit Sub
    End If
  '判断输入的考试分数是不是数值
  If Not IsNumeric(Text1.Text) Then
    MsgBox "分数输入不为数字!"
    Text1.SetFocus
    Exit Sub
    End If
  '取当前在课程下拉框中选择的课程编号
  kz = Left(Combo2.Text, InStr(1, Combo2.Text, "-") - 1)
  '取当前在学号下拉框中选择的学号
  xh = Left(Combo3.Text, InStr(1, Combo3.Text, "-") - 1)
  '判断当前这个学生这门课程的成绩是否已录入过
  txtsql = "select * from student_course_info where student_id='" & xh & "' and course_no='" & kz & "'"
  Set mrc = ExecuteSQL(txtsql, msgtext)
  If mrc.EOF = False Then
   '当前学生的这门成绩已经录入了,报告错误
    MsgBox "这个学生的这门成绩已录过!", vbOKOnly, "警告"
    mrc.Close
    Exit Sub
  Else '成绩写入数据库中
    mrc.AddNew
    mrc.Fields("student_id") = xh
    mrc.Fields("course_no") = kz
    mrc.Fields("score") = Val(Text1.Text)
    mrc.Update
    mrc.Close
    MsgBox "写入成功!", vbOKOnly
    Text1.Text = ""
  End If
End Sub
Private Sub Command2_Click()
 Unload Me  '退出本窗体
End Sub

⌨️ 快捷键说明

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