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

📄 frmadd_score.frm

📁 用VB开发的一个学生管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frmadd_score 
   Caption         =   "成绩管理-添加"
   ClientHeight    =   2940
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   7260
   LinkTopic       =   "Form1"
   ScaleHeight     =   2940
   ScaleWidth      =   7260
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "返回"
      Height          =   375
      Left            =   3960
      TabIndex        =   11
      Top             =   2400
      Width           =   975
   End
   Begin VB.CommandButton cmd_add 
      Caption         =   "添加"
      Height          =   375
      Left            =   2520
      TabIndex        =   10
      Top             =   2400
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Caption         =   "课程基本信息"
      Height          =   1935
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   6615
      Begin VB.ComboBox stu_no 
         Height          =   300
         Left            =   1440
         TabIndex        =   12
         Top             =   360
         Width           =   1335
      End
      Begin VB.TextBox course_name 
         Height          =   375
         Left            =   4680
         TabIndex        =   6
         Top             =   840
         Width           =   1215
      End
      Begin VB.TextBox score 
         Height          =   375
         Left            =   1440
         TabIndex        =   7
         Top             =   1320
         Width           =   855
      End
      Begin VB.ComboBox course_no 
         Height          =   300
         Left            =   1440
         TabIndex        =   5
         Top             =   840
         Width           =   1335
      End
      Begin VB.TextBox stu_name 
         Height          =   390
         Left            =   4680
         TabIndex        =   4
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label5 
         Caption         =   "课程名称:"
         Height          =   255
         Left            =   3360
         TabIndex        =   9
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label4 
         Caption         =   "学生姓名:"
         Height          =   255
         Left            =   3360
         TabIndex        =   8
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "课程成绩:"
         Height          =   255
         Left            =   360
         TabIndex        =   3
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "课程编号:"
         Height          =   255
         Left            =   360
         TabIndex        =   2
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "学生学号:"
         Height          =   255
         Left            =   360
         TabIndex        =   1
         Top             =   360
         Width           =   975
      End
   End
End
Attribute VB_Name = "Frmadd_score"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub initcourse_no()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_no from courses "
Set rstcourse = executesql(sqlStr, msgText)
course_no.Clear
If Not rstcourse.EOF Then
Do While Not rstcourse.EOF
   course_no.AddItem Trim(rstcourse.Fields(0))
   rstcourse.MoveNext
Loop
course_no.ListIndex = 0
Else
MsgBox "请添加课程编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstcourse.Close
End Sub
Sub initstu_no()
Dim rststudent As ADODB.Recordset
sqlStr = "select stu_no from students "
Set rststudent = executesql(sqlStr, msgText)
stu_no.Clear
If Not rststudent.EOF Then
Do While Not rststudent.EOF
   stu_no.AddItem Trim(rststudent.Fields(0))
   rststudent.MoveNext
Loop
stu_no.ListIndex = 0
Else
MsgBox "请添加学生编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rststudent.Close
End Sub
Private Sub cmd_cancel_Click()
Unload Me
End Sub

Private Sub Form_Load()
initcourse_no
initstu_no
initform
End Sub
Sub initform()
course_no.Text = ""
course_name.Text = ""
stu_no.Text = ""
stu_name.Text = ""
score.Text = ""
End Sub
Private Sub stu_no_click()
Dim rststudent As ADODB.Recordset
sqlStr = "select name from students where stu_no='" & stu_no.Text & "'"
Set rststudent = executesql(sqlStr, msgText)
If Not rststudent.EOF Then
stu_name.Text = rststudent.Fields(0)
rststudent.Close
End If
End Sub
Private Sub course_no_click()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_name from courses where Course_no='" & course_no.Text & "'"
Set rstcourse = executesql(sqlStr, msgText)
If Not rstcourse.EOF Then
course_name.Text = rstcourse.Fields(0)
rstcourse.Close
End If
End Sub
Private Sub cmd_add_Click()
Dim rs As ADODB.Recordset
Dim rstscore As ADODB.Recordset

If Trim(course_no.Text) = "" Or Trim(stu_no.Text) = "" Or Trim(score.Text) = "" Then
MsgBox "请将信息补充完整", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If

 sqlStr = "select * from score where Course_no ='" & course_no.Text & "' and stu_no='" & stu_no.Text & "'"
 Set rs = executesql(sqlStr, msgText)
 If rs.RecordCount = 0 Then
     sqlStr = "select * from score"
     Set rstscore = executesql(sqlStr, msgText)
     rstscore.AddNew
     rstscore.Fields("Stu_no") = Trim(stu_no.Text)
     rstscore.Fields("Course_no") = Trim(course_no.Text)
     rstscore.Fields("Score") = score.Text
     rstscore.Update
     rstscore.Close
     rs.Close
     MsgBox "添加成绩信息成功", 48, "提示"
     initform
    
   Else
     MsgBox "您输入的成绩信息已存在!", vbOKOnly + vbExclamation, "警告"
     initform
     Exit Sub
 End If
End Sub

⌨️ 快捷键说明

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