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