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

📄 frmadd_course.frm

📁 用VB开发的一个学生管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frmadd_course 
   Caption         =   "课程管理—添加"
   ClientHeight    =   3765
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   8355
   LinkTopic       =   "Form1"
   ScaleHeight     =   3765
   ScaleWidth      =   8355
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "返回"
      Height          =   375
      Left            =   4560
      TabIndex        =   8
      Top             =   2880
      Width           =   1095
   End
   Begin VB.CommandButton cmd_add 
      Caption         =   "添加"
      Height          =   375
      Left            =   2400
      TabIndex        =   7
      Top             =   2880
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Caption         =   "课程基本信息"
      Height          =   2295
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   8055
      Begin VB.TextBox course_score 
         Height          =   375
         Left            =   5880
         TabIndex        =   14
         Top             =   1560
         Width           =   975
      End
      Begin VB.TextBox course_teacher 
         Height          =   375
         Left            =   5880
         TabIndex        =   13
         Top             =   960
         Width           =   1455
      End
      Begin VB.TextBox course_no 
         Height          =   375
         Left            =   5880
         TabIndex        =   12
         Top             =   360
         Width           =   1455
      End
      Begin VB.TextBox course_hours 
         Height          =   375
         Left            =   1560
         TabIndex        =   11
         Top             =   1560
         Width           =   975
      End
      Begin VB.ComboBox course_type 
         Height          =   300
         Left            =   1560
         TabIndex        =   10
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox course_name 
         Height          =   375
         Left            =   1560
         TabIndex        =   9
         Top             =   360
         Width           =   1695
      End
      Begin VB.Label Label6 
         Caption         =   "学 分:"
         Height          =   255
         Left            =   4800
         TabIndex        =   6
         Top             =   1560
         Width           =   735
      End
      Begin VB.Label Label5 
         Caption         =   "任课老师:"
         Height          =   255
         Left            =   4560
         TabIndex        =   5
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label Label4 
         Caption         =   "课程编号:"
         Height          =   255
         Left            =   4560
         TabIndex        =   4
         Top             =   480
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "学时数:"
         Height          =   255
         Left            =   480
         TabIndex        =   3
         Top             =   1560
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "课程类型:"
         Height          =   255
         Left            =   360
         TabIndex        =   2
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "课程名:"
         Height          =   255
         Left            =   480
         TabIndex        =   1
         Top             =   360
         Width           =   735
      End
   End
End
Attribute VB_Name = "Frmadd_course"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_add_Click()
Dim rs As ADODB.Recordset
Dim rstcourse As ADODB.Recordset

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

 sqlStr = "select * from courses where Course_no ='" & course_no.Text & "'"
 Set rs = executesql(sqlStr, msgText)
 If rs.RecordCount = 0 Then
 sqlStr = "select * from courses"
 Set rstcourse = executesql(sqlStr, msgText)
  rstcourse.AddNew
  rstcourse.Fields("Course_no") = Trim(course_no.Text)
  rstcourse.Fields("Course_name") = Trim(course_name.Text)
  rstcourse.Fields("Course_type") = Trim(course_type.Text)
  rstcourse.Fields("course_hours") = course_hours.Text
  rstcourse.Fields("Score") = Trim(course_score.Text)
  rstcourse.Fields("Teacher") = Trim(course_teacher.Text)
  
  rstcourse.Update
  rstcourse.Close
  rs.Close
  MsgBox "添加课程信息成功", 48, "提示"
  initform
 Else
     MsgBox "您输入的课程编号已存在,请重新输入一个新课程编号", vbOKOnly + vbExclamation, "警告"
     course_no.Text = ""
     course_no.SetFocus
  End If


End Sub

Private Sub cmd_cancel_Click()
Unload Me
End Sub
'Sub initcourse_type()
'Dim rstcourse As ADODB.Recordset
'sqlStr = "select Course_type from courses group by course_type"
'Set rstcourse = executesql(sqlStr, msgText)
'course_type.Clear
'If Not rstcourse.EOF Then
'Do While Not rstcourse.EOF
 '   course_type.AddItem Trim(rstcourse.Fields(0))
 '   rstcourse.MoveNext
'Loop
'course_type.ListIndex = 0
'Else
'MsgBox "请添加课程类型", vbOKOnly + vbExclamation, "警告"
'Exit Sub
'End If
'rstcourse.Close

'End Sub
Sub initform()
course_no.Text = ""
course_name.Text = ""
course_type.Text = ""
course_score.Text = ""
course_teacher.Text = ""
course_hours.Text = ""
End Sub
Private Sub Form_Load()
'initcourse_type

course_type.AddItem Trim("必修课")
course_type.AddItem Trim("选修课")
initform
End Sub

⌨️ 快捷键说明

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