?? addmark.frm
字號:
VERSION 5.00
Begin VB.Form frmMark
BackColor = &H8000000B&
Caption = "成績管理"
ClientHeight = 3660
ClientLeft = 60
ClientTop = 450
ClientWidth = 5115
FillColor = &H00FF0000&
ForeColor = &H8000000D&
LinkTopic = "Form5"
ScaleHeight = 3660
ScaleWidth = 5115
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cmbdepar
Height = 315
Left = 3480
TabIndex = 16
Top = 1080
Width = 1575
End
Begin VB.ComboBox cmbCourse
Height = 315
Left = 1200
TabIndex = 15
Top = 1080
Width = 1335
End
Begin VB.CommandButton cmdQuery
Caption = "查詢"
Height = 375
Left = 3120
TabIndex = 14
Top = 2400
Width = 975
End
Begin VB.CommandButton Command1
Caption = "刪除"
Height = 375
Left = 2280
TabIndex = 13
Top = 2400
Width = 855
End
Begin VB.CommandButton cmdChange
Caption = "修改"
Height = 375
Left = 1320
TabIndex = 12
Top = 2400
Width = 975
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游標
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 495
Left = 1440
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 3120
Visible = 0 'False
Width = 1695
End
Begin VB.CommandButton cmdcancel
Caption = "取消"
Height = 375
Left = 4080
TabIndex = 11
Top = 2400
Width = 975
End
Begin VB.CommandButton cmdaddmark
Caption = "添加"
Height = 375
Left = 360
TabIndex = 10
Top = 2400
Width = 975
End
Begin VB.TextBox Text6
Height = 375
Left = 3360
TabIndex = 9
Top = 1800
Width = 1695
End
Begin VB.TextBox Text4
Height = 375
Left = 3480
TabIndex = 8
Top = 360
Width = 1095
End
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 7
Top = 1800
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 6
Top = 480
Width = 1215
End
Begin VB.Label Label6
Caption = "身份證號碼"
Height = 255
Left = 2400
TabIndex = 5
Top = 1800
Width = 975
End
Begin VB.Label Label5
Caption = "系別"
Height = 375
Left = 2640
TabIndex = 4
Top = 1080
Width = 735
End
Begin VB.Label Label4
Caption = "考試編號"
Height = 375
Left = 2520
TabIndex = 3
Top = 480
Width = 855
End
Begin VB.Label Label3
Caption = "科目分數"
Height = 255
Left = 240
TabIndex = 2
Top = 1800
Width = 735
End
Begin VB.Label Label2
Caption = "考試科目"
Height = 255
Left = 240
TabIndex = 1
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "考生姓名"
Height = 255
Left = 240
TabIndex = 0
Top = 480
Width = 855
End
End
Attribute VB_Name = "frmMark"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdaddmark_Click()
If flag = 2 Then
MsgBox "您沒有權限進行添加學籍!退出操作!!"
Text1.Text = ""
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text6.Text = ""
Text1.SetFocus
Exit Sub
End If
'判斷基本信息不能為空!!
If Text1.Text = "" Then
MsgBox "考生姓名不能為空,請重新輸入!??!"
Text1.SetFocus
Exit Sub
End If
If cmbCourse.Text = "" Then
MsgBox "考試科目不能為空,請重新輸入??!"
cmbCourse.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "科目分數不能為空?。?quot;
Text3.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "考試編號不能為空??!"
Text4.SetFocus
Exit Sub
End If
If cmbdepar.Text = "" Then
MsgBox "系別不能為空!!!"
cmbdepar.SetFocus
Exit Sub
End If
If Text6.Text = "" Then
MsgBox "身份證不能為空!!!"
Text6.SetFocus
Exit Sub
End If
'查找是否存在輸入的身份證號這條記錄
Data1.Recordset.MoveFirst
While Data1.Recordset.Fields("card_Id") <> Text6.Text Or Data1.Recordset.Fields("course") <> cmbCourse.Text
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Data1.Recordset.AddNew
Data1.Recordset.Fields("name") = Text1.Text
Data1.Recordset.Fields("course") = cmbCourse.Text
Data1.Recordset.Fields("mark") = Text3.Text
Data1.Recordset.Fields("exam_Id") = Text4.Text
Data1.Recordset.Fields("department") = cmbdepar.Text
Data1.Recordset.Fields("card_Id") = Text6.Text
Data1.Recordset.Update
MsgBox "恭喜,添加成功?。。。?quot;
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text1.SetFocus
Exit Sub
End If
Wend
'提示已經添加,文本框清空
MsgBox "該學生的該門課已經添加!!??!"
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text1.SetFocus
End Sub
Private Sub cmdcancel_Click()
Unload frmMark
End Sub
Private Sub cmdChange_Click()
If flag = 2 Then
MsgBox "您沒有權限進行修改學籍!退出操作!!"
Text1.Text = ""
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text6.Text = ""
Text1.SetFocus
Exit Sub
End If
'判斷是否找出要修改的記錄
If Text1.Text = "" Or cmbCourse.Text = "" Or Text6.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "請先查找出您要修改的記錄!謝謝合作??!"
Exit Sub
End If
'修改記錄
Data1.Recordset.Edit
Data1.Recordset.Fields("name") = Text1.Text
Data1.Recordset.Fields("course") = cmbCourse.Text
Data1.Recordset.Fields("mark") = Text3.Text
Data1.Recordset.Fields("exam_Id") = Text4.Text
Data1.Recordset.Fields("department") = cmbdepar.Text
Data1.Recordset.Fields("card_Id") = Text6.Text
Data1.Recordset.Update
MsgBox "修改成功,請確定!!!"
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text1.SetFocus
End Sub
Private Sub cmdQuery_Click()
'驗證查詢信息非空
If Text6.Text = "" Then
MsgBox "查詢成績時,身份證號碼不能為空?。。?quot;
Text6.SetFocus
Exit Sub
End If
If cmbCourse.Text = "" Then
MsgBox "查詢成績時,科目不能為空!?。?quot;
cmbCourse.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "查詢成績時,考生姓名不能為空?。。?quot;
Text1.SetFocus
Exit Sub
End If
'查看該學生的成績記錄是否存在
Data1.Recordset.MoveFirst
While Data1.Recordset.Fields("card_Id") <> Text6.Text Or Data1.Recordset.Fields("course") <> cmbCourse.Text
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
MsgBox "沒有該學生的成績,請重新輸入身份證號碼及姓名和科目??!"
cmbCourse.Text = ""
Text6.Text = ""
Text1.SetFocus
Exit Sub
End If
Wend
'顯示查到的記錄
Text1.Text = Data1.Recordset.Fields("name")
cmbCourse.Text = Data1.Recordset.Fields("course")
Text3.Text = Data1.Recordset.Fields("mark")
Text4.Text = Data1.Recordset.Fields("exam_Id")
cmbdepar.Text = Data1.Recordset.Fields("department")
Text6.Text = Data1.Recordset.Fields("card_Id")
MsgBox "查詢成功!請確定!!"
End Sub
Private Sub Command1_Click()
If flag = 2 Then
MsgBox "您沒有權限進行刪除學籍!退出操作??!"
Text1.Text = ""
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text6.Text = ""
Text1.SetFocus
Exit Sub
End If
'提示要找出刪除學生成績的的記錄
If Text1.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
Text1.SetFocus
Exit Sub
End If
If cmbCourse.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
cmbCourse.SetFocus
Exit Sub
End If
If Text6.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
Text6.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
Text3.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
Text4.SetFocus
Exit Sub
End If
If cmbdepar.Text = "" Then
MsgBox "請先查詢出要刪除考生成績的記錄,再刪除.謝謝!!!"
cmbdepar.SetFocus
Exit Sub
End If
Data1.Recordset.Delete
MsgBox "刪除成功!!"
Text1.Text = ""
cmbCourse.Text = ""
Text3.Text = ""
Text4.Text = ""
cmbdepar.Text = ""
Text6.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
If flag = 2 Then
Label1.ToolTipText = "您無權添加、刪除、修改!"
Text1.ToolTipText = "您無權添加、刪除、修改!"
End If
cmbCourse.AddItem "數據庫"
cmbCourse.AddItem "數據結構"
cmbCourse.AddItem "c語言"
cmbCourse.AddItem "操作系統"
cmbCourse.AddItem "c++程序設計"
cmbCourse.AddItem "心理學"
cmbCourse.AddItem "鄧小平理論"
cmbdepar.AddItem "計算機系"
cmbdepar.AddItem "外國語學院"
cmbdepar.AddItem "文學院"
cmbdepar.AddItem "體育系"
cmbdepar.AddItem "化學系"
cmbdepar.AddItem "物電系"
cmbdepar.AddItem "數學系"
cmbdepar.AddItem "生物系"
cmbdepar.AddItem "貿經系"
cmbdepar.AddItem "藝術學院"
cmbdepar.AddItem "教育技術系"
Data1.Connect = "Access"
Data1.DatabaseName = "" & App.Path & "\db1.mdb"
Data1.RecordSource = "exam"
Data1.Refresh
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -