📄 guanli.frm
字号:
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "请输入性别!", vbOKOnly + vbExclamation, "警告"
Combo1.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "请输入民族!"
Text5.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "请输入出生年月!出生年月应输入日期格式(YYYY-MM-DD)!", vbOKOnly + vbExclamation, "警告"
Text4.SetFocus
Exit Sub
End If
If Text7.Text = "" Then
MsgBox "请输入地址!", vbOKOnly + vbExclamation, "警告"
Text7.SetFocus
Exit Sub
End If
If Text8.Text = "" Then
MsgBox "请输入邮政编码!", vbOKOnly + vbExclamation, "警告"
Text8.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请输入班级!", vbOKOnly + vbExclamation, "警告"
Text3.SetFocus
Exit Sub
End If
If DataCombo1.Text = "" Then
MsgBox "请输入专业!", vbOKOnly + vbExclamation, "警告"
DataCombo1.SetFocus
Exit Sub
End If
If Text10.Text = "" Then
MsgBox "请输入院系!", vbOKOnly + vbExclamation, "警告"
Text10.SetFocus
Exit Sub
End If
If Text9.Text = "" Then
MsgBox "请输入电话号码!", vbOKOnly + vbExclamation, "警告"
Text9.SetFocus
Exit Sub
End If
End If
If check1 = False Then
If Text1.Text <> Adodc2.Recordset.Fields("学号") Then
MsgBox "学号重复", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Else
' Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("学号").Value = Text1.Text
Adodc2.Recordset.Fields("姓名").Value = Text2.Text
Adodc2.Recordset.Fields("班级").Value = Text3.Text
Adodc2.Recordset.Fields("性别").Value = Combo1.Text
Adodc2.Recordset.Fields("出生日期").Value = Text4.Text
Adodc2.Recordset.Fields("民族").Value = Text5.Text
Adodc2.Recordset.Fields("地址").Value = Text7.Text
Adodc2.Recordset.Fields("邮政编码").Value = Text8.Text
Adodc2.Recordset.Fields("电话号码").Value = Text9.Text
Adodc2.Recordset.Fields("院系").Value = Text10.Text
Adodc2.Recordset.Fields("专业").Value = DataCombo1.Text
Adodc2.Recordset.Fields("备注").Value = Text12.Text
Adodc2.Recordset.Update
'Adodc2.Recordset.Close
MsgBox "修改学生信息成功!", vbOKOnly + vbExclamation, "修改学生信息"
' Adodc2.Recordset.Bookmark = mybookmark
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command10.Enabled = True
'Text1.Enabled = False
'Text2.Enabled = False
'Text3.Enabled = False
'Text4.Enabled = False
'Text5.Enabled = False
'Text6.Enabled = False
'Text7.Enabled = False
'Text8.Enabled = False
'Text9.Enabled = False
'Combo1.Enabled = False
'DataCombo1.Enabled = False
'Text10.Enabled = False
'Text12.Enabled = False
mcclean = True
End If
Else
Adodc2.Recordset.Fields("学号").Value = Text1.Text
Adodc2.Recordset.Fields("姓名").Value = Text2.Text
Adodc2.Recordset.Fields("班级").Value = Text3.Text
Adodc2.Recordset.Fields("性别").Value = Combo1.Text
Adodc2.Recordset.Fields("出生日期").Value = Text4.Text
Adodc2.Recordset.Fields("民族").Value = Text5.Text
Adodc2.Recordset.Fields("地址").Value = Text7.Text
Adodc2.Recordset.Fields("邮政编码").Value = Text8.Text
Adodc2.Recordset.Fields("电话号码").Value = Text9.Text
Adodc2.Recordset.Fields("院系").Value = Text10.Text
Adodc2.Recordset.Fields("专业").Value = DataCombo1.Text
Adodc2.Recordset.Fields("备注").Value = Text12.Text
Adodc2.Recordset.Update
'Adodc2.Recordset.Close
MsgBox "修改学生信息成功!", vbOKOnly + vbExclamation, "修改学生信息"
' Adodc2.Recordset.Bookmark = mybookmark
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command10.Enabled = True
mcclean = True
End If
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command10_Click()
On Error GoTo AddErr
If MsgBox("你确信吗?", vbOKCancel, "警告") = vbOK Then
Adodc2.Recordset.Delete
Adodc2.Recordset.MoveNext
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
End If
GradeRefresh
End If
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
On Error GoTo AddErr
Adodc2.Recordset.MoveFirst
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command3_Click()
On Error GoTo AddErr
Adodc2.Recordset.MoveLast
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command4_Click()
On Error GoTo AddErr
If Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveFirst
Adodc2.Recordset.MoveNext
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command5_Click()
On Error GoTo AddErr
If Adodc2.Recordset.BOF Then Adodc2.Recordset.MoveLast
Adodc2.Recordset.MovePrevious
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command6_Click()
On Error GoTo AditErr
mcclean = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command10.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
'Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Combo1.Enabled = True
DataCombo1.Enabled = True
Text10.Enabled = True
Text12.Enabled = True
Exit Sub
'mybookmark = Adodc2.Recordset.Bookmark
AditErr:
MsgBox Err.Description
End Sub
Private Sub Command7_Click()
On Error GoTo errh
If Text1.Text <> "" Then
If Text13.Text <> "" Then
If Combo4.Text <> "" Then
If Combo2.Text <> "" Then
If Combo3.Text <> "" Then
If checkclass = False Then
If match Then
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
rs.Open "select * from 成绩表 where 课程号='" & Trim(Combo4.Text) & "' and 课程名称='" & Trim(Combo2.Text) & "' and 学号='" & Trim(Text1.Text) & "' ", cn, , , adCmdText
'rs.Find ("UserName=" & "'" & Text1.Text & "'")
'If rs.Fields("Password").Value = Text2.Text Then
'rs.Fields(0).Value = Text3.Text
'rs.Fields(1).Value = Combo3.Text
'rs.Update
'rs.Update "成绩", Text3.Text
rs.Fields("成绩").Value = Text13.Text
rs.Fields("备注").Value = Combo3.Text
rs.Update
rs.Close
MsgBox "修改成功!"
Combo4.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Text13.Text = ""
Combo4.SetFocus
Else
MsgBox "成绩和备注不匹配,请核对!"
End If
Else
MsgBox "没有该课程成绩,不能修改!"
End If
Else
MsgBox "该项不能为空,请输入备注!"
End If
Else
MsgBox "该项不能为空,请输入课程名称!"
End If
Else
MsgBox "该项不能为空,请输入课程号!"
End If
Else
MsgBox "该项不能为空,请输入成绩!"
End If
Else
MsgBox "该项不能为空,请输入学号!"
End If
Exit Sub
errh:
MsgBox Err.Description
'rs.Close
End Sub
Private Sub Command8_Click()
On Error GoTo errh
If MsgBox("你的操作将会删除当前的纪录,你确信吗?", vbOKCancel, "警告") = vbOK Then
If Combo4.Text <> "" Then
If Combo2.Text <> "" Then
Set rs1 = New ADODB.Recordset
rs1.CursorType = adOpenDynamic
rs1.LockType = adLockOptimistic
rs1.Open "SELECT * FROM 成绩表 WHERE 课程名称='" & Trim(Combo2.Text) & "'AND 课程号='" & Trim(Combo4.Text) & "' and 学号='" & Trim(Text1.Text) & "'", cn, adOpenDynamic, adLockOptimistic, adCmdText
If rs1.EOF Then
'Adodc2.Recordset.Close
rs1.Close
MsgBox "没有这条记录,无法删除!"
Exit Sub
End If
rs1.Delete
rs1.Update
rs1.Close
MsgBox "删除成功!"
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End If
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub Command9_Click()
Unload Me
End Sub
Private Sub DataCombo1_Click(Area As Integer)
'datacombo1.
End Sub
Private Sub Form_Load()
MakeCenter guanli
If IsAdmin = False Then
Command6.Enabled = False
Command1.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
'Command9.Enabled = False
CmdUpdata.Enabled = False
CmdBolish.Enabled = False
' CmdBolish.Enabled = False
'CmdUpdata.Enabled = False
Command10.Enabled = False
End If
mcclean = True
Set rs = cn.Execute("select distinct 课程名称,课程号 from 课程表")
rs.MoveFirst
Do
Combo4.AddItem rs.Fields(1).Value
Combo2.AddItem rs.Fields(0).Value
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo3.AddItem "优异"
Combo3.AddItem "良好"
Combo3.AddItem "中等"
Combo3.AddItem "及格"
Combo3.AddItem "不及格"
Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=cj.MDB;" & _
"DefaultDir=" & CheckPath(App.path) & ";" & _
"UID=;PWD=;"
Adodc2.RecordSource = "SELECT * FROM 学生表"
Text1.DataField = "学号"
Text2.DataField = "姓名"
Text3.DataField = "班级"
Text4.DataField = "出生日期"
Text5.DataField = "民族"
Text7.DataField = "地址"
Text8.DataField = "邮政编码"
Text9.DataField = "电话号码"
Text10.DataField = "院系"
' Text11.DataField = "专业"
Text12.DataField = "备注"
GradeRefresh
End Sub
'Private Sub Form_Unload(Cancel As Integer)
'On Error Resume Next
' Adodc2.Recordset.Close
'End Sub
Private Function check1() As Boolean '检测添加的课程是否重复
On Error GoTo errh
Set rs = cn.Execute("SELECT 学号 FROM 学生表 WHERE 学号='" & Trim(Text1.Text) & "'")
' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
check1 = True
Exit Function
End If
check1 = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Sub GradeRefresh()
Adodc1.RecordSource = "Select * from 成绩表 where 学号 = '" & Trim(Text1.Text) & "'"
Adodc1.Refresh
End Sub
Private Function checkcourse() As Boolean
On Error GoTo errh
Set rs = cn.Execute("select * from 课程表 where 课程名称='" & Trim(Combo2.Text) & "' and 课程号='" & Trim(Combo4.Text) & "'")
'If Adodc2.Recordset.EOF Then
'Adodc2.Recordset.Close
If rs.EOF Then
rs.Close
checkcourse = False
Exit Function
End If
checkcourse = True
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Function checkclass() As Boolean '检测添加的课程是否重复
On Error GoTo errh
' Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=db5.MDB;" & _
"DefaultDir=" & CheckPath(App.path) & ";" & _
"UID=;PWD=;"
Set rs = cn.Execute("SELECT 课程名称 FROM 成绩表 WHERE 课程名称='" & Trim(Combo2.Text) & "' and 学号='" & Trim(Text1.Text) & "' And 成绩 Is Not Null ")
' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
checkclass = True
Exit Function
End If
checkclass = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Function match() As Boolean
On Error GoTo Error
If Text13.Text < 60 Then
If Combo3.Text = "不及格" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 70 And Text13.Text >= 60 Then
If Combo3.Text = "及格" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 80 And Text13.Text >= 70 Then
If Combo3.Text = "中等" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 90 And Text13.Text >= 80 Then
If Combo3.Text = "良好" Then
match = True
Else
match = False
End If
End If
If Text13.Text <= 100 And Text13.Text >= 90 Then
If Combo3.Text = "优异" Then
match = True
Else
match = False
End If
End If
Exit Function
Error:
MsgBox Err.descirption
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -