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

📄 frmdel_course.frm

📁 用VB开发的一个学生管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frmdel_course 
   Caption         =   "课程-修改删除"
   ClientHeight    =   4755
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   8145
   LinkTopic       =   "Form1"
   ScaleHeight     =   4755
   ScaleWidth      =   8145
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "返回"
      Height          =   375
      Left            =   5520
      TabIndex        =   18
      Top             =   4200
      Width           =   1095
   End
   Begin VB.CommandButton cmd_del 
      Caption         =   "删除"
      Height          =   375
      Left            =   3360
      TabIndex        =   17
      Top             =   4200
      Width           =   1215
   End
   Begin VB.CommandButton cmd_modify 
      Caption         =   "修改"
      Height          =   375
      Left            =   1200
      TabIndex        =   16
      Top             =   4200
      Width           =   1215
   End
   Begin VB.Frame Frame2 
      Caption         =   "课程基本信息"
      Height          =   2295
      Left            =   360
      TabIndex        =   3
      Top             =   1440
      Width           =   7455
      Begin VB.TextBox course_score 
         Height          =   375
         Left            =   5160
         TabIndex        =   15
         Top             =   1680
         Width           =   735
      End
      Begin VB.TextBox course_teacher 
         Height          =   390
         Left            =   5160
         TabIndex        =   14
         Top             =   960
         Width           =   1335
      End
      Begin VB.TextBox course_no2 
         Height          =   375
         Left            =   5160
         TabIndex        =   13
         Top             =   240
         Width           =   1335
      End
      Begin VB.TextBox course_hours 
         Height          =   390
         Left            =   1680
         TabIndex        =   12
         Top             =   1680
         Width           =   615
      End
      Begin VB.ComboBox course_type 
         Height          =   300
         Left            =   1680
         TabIndex        =   11
         Top             =   1080
         Width           =   1215
      End
      Begin VB.TextBox course_name 
         Height          =   375
         Left            =   1680
         TabIndex        =   10
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label7 
         Caption         =   "学 分:"
         Height          =   255
         Left            =   4080
         TabIndex        =   9
         Top             =   1800
         Width           =   735
      End
      Begin VB.Label Label6 
         Caption         =   "授课老师:"
         Height          =   255
         Left            =   3960
         TabIndex        =   8
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "课程编号:"
         Height          =   255
         Left            =   3960
         TabIndex        =   7
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "课时数:"
         Height          =   255
         Left            =   600
         TabIndex        =   6
         Top             =   1800
         Width           =   855
      End
      Begin VB.Label Label3 
         Caption         =   "课程类型:"
         Height          =   255
         Left            =   480
         TabIndex        =   5
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "课程名:"
         Height          =   255
         Left            =   600
         TabIndex        =   4
         Top             =   360
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询"
      Height          =   855
      Left            =   480
      TabIndex        =   0
      Top             =   120
      Width           =   7095
      Begin VB.CommandButton cmd_query 
         Caption         =   "查询"
         Height          =   375
         Left            =   5040
         TabIndex        =   19
         Top             =   240
         Width           =   1095
      End
      Begin VB.TextBox course_no1 
         Height          =   375
         Left            =   1680
         TabIndex        =   2
         Top             =   240
         Width           =   1935
      End
      Begin VB.Label Label1 
         Caption         =   "输入课程编号:"
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   1335
      End
   End
End
Attribute VB_Name = "Frmdel_course"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_cancel_Click()
Unload Me
End Sub
Sub initform()
course_no1.Text = ""
course_no2.Text = ""
course_name.Text = ""
course_type.Text = ""
course_score.Text = ""
course_teacher.Text = ""
course_hours.Text = ""
End Sub

Private Sub cmd_del_Click()
Dim conn As ADODB.Connection
sqlStr = "delete from courses where Course_no='" & course_no1.Text & "'"
On Error GoTo exitsub
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "成功删除数据!"
exitsub:
conn.Close
initform
End Sub

Private Sub cmd_modify_Click()
Dim rs As ADODB.Recordset

sqlStr = "update courses set [Course_name]='" & course_name.Text & "',[Course_type]='" & course_type.Text & "',[Course_hours]='" & course_hours.Text & "' ,[Score]='" & course_score.Text & "',[Teacher]='" & course_teacher.Text & "'   where course_no='" & course_no1.Text & "'"

On Error GoTo exitsub
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "修改数据成功!"
exitsub:
conn.Close

initform
End Sub

Private Sub cmd_query_Click()
getCourseinfo
End Sub

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

Sub getCourseinfo()
Dim rs As ADODB.Recordset
sqlStr = "select * from courses where Course_no='" & course_no1.Text & "'"
Set rs = executesql(sqlStr, msgText)
If Not rs.EOF Then
course_no2 = Trim(rs.Fields("course_no"))
course_name = Trim(rs.Fields("Course_Name"))
course_type = Trim(rs.Fields("Course_type"))
course_hours.Text = Trim(rs.Fields("Course_hours"))
course_teacher.Text = Trim(rs.Fields("Teacher"))
course_score.Text = Trim(rs.Fields("Score"))

Else
MsgBox "没找到符合条件的数据!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rs.Close

End Sub

⌨️ 快捷键说明

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