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

📄 frmscoreadd.frm

📁 学生信息管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   540
      End
   End
   Begin VB.TextBox txtName 
      BackColor       =   &H80000018&
      Height          =   270
      Left            =   3480
      TabIndex        =   6
      Top             =   600
      Width           =   1575
   End
   Begin VB.ComboBox comTerm 
      BackColor       =   &H80000018&
      Height          =   300
      Left            =   960
      TabIndex        =   5
      Top             =   240
      Width           =   4095
   End
   Begin VB.ComboBox comID 
      BackColor       =   &H80000018&
      Height          =   300
      Left            =   960
      TabIndex        =   4
      Top             =   585
      Width           =   1575
   End
   Begin VB.ComboBox comTestType 
      BackColor       =   &H80000018&
      Height          =   300
      Left            =   3480
      TabIndex        =   3
      Top             =   960
      Width           =   1575
   End
   Begin VB.ComboBox comClass 
      BackColor       =   &H80000018&
      Height          =   300
      Left            =   960
      TabIndex        =   2
      Top             =   960
      Width           =   1575
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定"
      Height          =   390
      Left            =   1560
      TabIndex        =   0
      Top             =   4560
      Width           =   1095
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   390
      Left            =   2880
      TabIndex        =   1
      Top             =   4560
      Width           =   1095
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      Caption         =   "姓名:"
      Height          =   180
      Left            =   2880
      TabIndex        =   11
      Top             =   645
      Width           =   540
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "类型:"
      Height          =   180
      Left            =   2880
      TabIndex        =   10
      Top             =   1020
      Width           =   540
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "学号:"
      Height          =   180
      Left            =   360
      TabIndex        =   9
      Top             =   645
      Width           =   540
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "班级:"
      Height          =   180
      Left            =   360
      TabIndex        =   8
      Top             =   1020
      Width           =   540
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "学期:"
      Height          =   180
      Left            =   360
      TabIndex        =   7
      Top             =   300
      Width           =   540
   End
End
Attribute VB_Name = "frmScoreAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmScoreAdd.frm----------------------------------
Option Explicit

Dim intCourseCount As Integer

'选择学期
Private Sub comTerm_Click()
    If comClass.Text = "" Or comTerm.Text = "" Then
        Exit Sub
    End If
    SetCourse
End Sub

'选择班级
Private Sub comClass_Click()
    Dim objRecordset As ADODB.Recordset
    
    '查询学号,并将学生信息加载到控件中
    strSQL = "select DISTINCT 学号 from Documents where 班级='" & Trim(comClass.Text) & "' order by 学号"
    Set objRecordset = ExecuteSQL(strSQL)
    '如果没有数据记录
    If objRecordset.EOF = True Then
        comID.Clear
        txtName.Text = ""
    '如果有数据记录就将数据添加到控件中
    Else
        objRecordset.MoveFirst
        comID.Clear
        Do While Not objRecordset.EOF
            comID.AddItem objRecordset.Fields(0)
            objRecordset.MoveNext
        Loop
        comID.ListIndex = 0
        Set objRecordset = Nothing
    End If
    
    If comClass.Text = "" Or comTerm.Text = "" Then
        Exit Sub
    End If
    SetCourse
End Sub

'修改学号
Private Sub comID_Change()
    Dim objRecordset As ADODB.Recordset
    Dim strSQL As String
    
    '查询学号
    strSQL = "select   DISTINCT 姓名 from Documents where 学号 ='" & Trim(comID.Text) & "'"
    Set objRecordset = ExecuteSQL(strSQL)
    If objRecordset.EOF = True Then
        MsgBox "没有此学号!", vbExclamation + vbOKOnly, "警告"
        txtName.Text = ""
        Exit Sub
    End If
    txtName.Text = objRecordset.Fields(0)
    Set objRecordset = Nothing
End Sub

'查询学号
Private Sub comID_Click()
    Dim objRecordset As ADODB.Recordset
    
    strSQL = "select   DISTINCT 姓名 from Documents where 学号 ='" & Trim(comID.Text) & "'"
    Set objRecordset = ExecuteSQL(strSQL)
    txtName.Text = objRecordset.Fields(0)
    Set objRecordset = Nothing
End Sub

'确认成绩设置
Private Sub cmdOK_Click()
    Dim objRecordset As ADODB.Recordset
    Dim i As Integer
    
    For i = 0 To 13
        If Trim(txtScores(i).Text) = "" Then
            txtScores(i).Text = "0"
        End If
    Next
    
    If comID.Text = "" Then
        MsgBox "学号不能为空!", vbExclamation + vbOKOnly, "警告"
        comID.SetFocus
        Exit Sub
    End If
    
    '打开数据库
    strSQL = "select 学号 from Scores where 学号='" & Trim(comID.Text) & "' and 学期='" & Trim(comTerm.Text) & "' and 类型='" & Trim(comTestType.Text) & "'"
    Set objRecordset = ExecuteSQL(strSQL)
    If objRecordset.EOF = False Then
        MsgBox "已存在该学生本学期的成绩记录!", vbExclamation + vbOKOnly, "警告"
        comID.SetFocus
        comID.SelStart = 0
        comID.SelLength = Len(comID.Text)
        Exit Sub
    End If
    '将成绩更新到数据库
    strSQL = "select  * from Scores"
    Set objRecordset = ExecuteSQL(strSQL)
    For i = 0 To (intCourseCount - 1)
        objRecordset.AddNew
        objRecordset.Fields(0) = Trim(comID.Text)
        objRecordset.Fields(1) = Trim(comTerm.Text)
        objRecordset.Fields(2) = Trim(comTestType.Text)
        objRecordset.Fields(3) = Trim(lblCourse(i).Caption)
        objRecordset.Fields(4) = Val(Trim(txtScores(i).Text))
        objRecordset.Update
    Next
    
    '初始化控件
    For i = 0 To 13
        txtScores(i).Text = "0"
    Next
    comID.Text = ""
    txtName.Text = ""
    comID.SetFocus
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub Form_Activate()
    Dim objRecordset As ADODB.Recordset
    
    '查询班级,并添加到班级框中
    strSQL = "select  DISTINCT 班级  from Classes order by 班级"
    Set objRecordset = ExecuteSQL(strSQL)
    objRecordset.MoveFirst
    comClass.Clear
    Do While Not objRecordset.EOF
        comClass.AddItem objRecordset.Fields(0)
        objRecordset.MoveNext
    Loop
    comClass.ListIndex = 0
    
    '添加学期
    comTerm.AddItem Val(Format(Date, "yyyy")) - 1 & "---" & Val(Format(Date, "yyyy")) & "年级第一学期"
    comTerm.AddItem Val(Format(Date, "yyyy")) - 1 & "---" & Val(Format(Date, "yyyy")) & "年级第二学期"
    comTerm.AddItem Format(Date, "yyyy") & "---" & Val(Format(Date, "yyyy")) + 1 & "年级第一学期"
    comTerm.AddItem Format(Date, "yyyy") & "---" & Val(Format(Date, "yyyy")) + 1 & "年级第二学期"
    comTerm.AddItem Val(Format(Date, "yyyy")) + 1 & "---" & Val(Format(Date, "yyyy")) + 2 & "年级第一学期"
    comTerm.AddItem Val(Format(Date, "yyyy")) + 1 & "---" & Val(Format(Date, "yyyy")) + 2 & "年级第二学期"
    If Val(Format(Date, "mm")) > 8 Then
        comTerm.ListIndex = 2
    Else
        comTerm.ListIndex = 1
    End If
    
    '查询考试类型,并添加到考试类型框中
    strSQL = "select * from ExamType"
    Set objRecordset = ExecuteSQL(strSQL)
    comTestType.Clear
    objRecordset.MoveFirst
    Do While Not objRecordset.EOF
        comTestType.AddItem objRecordset.Fields(0)
        objRecordset.MoveNext
    Loop
    comTestType.ListIndex = 0
    
    Set objRecordset = Nothing
    SetCourse
End Sub

'设置课程名称
Private Sub SetCourse()
    Dim objRecordset As ADODB.Recordset
    Dim objSubRecordset As ADODB.Recordset
    Dim i As Integer
    
    For i = 0 To 13
        txtScores(i).Enabled = False
    Next
    
    '将课程名初始化到控件中
    strSQL = "select 年级,专业,年制 from Classes where 班级='" & Trim(comClass.Text) & "'"
    Set objSubRecordset = ExecuteSQL(strSQL)
    strSQL = "select 课程名称 from ClassCourses where 学期='" & Trim(comTerm.Text) & "'and 年级='" & Trim(objSubRecordset.Fields(0)) & "' and 专业='" & Trim(objSubRecordset.Fields(1)) & "' and 年制='" & Trim(objSubRecordset.Fields(2)) & "'"
    Set objSubRecordset = Nothing
    Set objRecordset = ExecuteSQL(strSQL)
    If objRecordset.EOF = True Then
        MsgBox "请先设置班级课程!", vbExclamation + vbOKOnly, "警告"
        cmdOK.Enabled = False
        cmdCancel.Enabled = False
        Exit Sub
    End If
    
    '初始化控件
    cmdOK.Enabled = True
    cmdCancel.Enabled = True
    objRecordset.MoveFirst
    intCourseCount = objRecordset.RecordCount
    For i = 0 To (objRecordset.RecordCount - 1)
        txtScores(i).Enabled = True
        lblCourse(i).Caption = objRecordset.Fields(0)
        txtScores(i).Text = 0
        objRecordset.MoveNext
    Next
    Set objRecordset = Nothing
End Sub


⌨️ 快捷键说明

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