?? frmdel_course.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 + -