当前位置:文档之家› 数据库技术之学生成绩管理系统程序设计

数据库技术之学生成绩管理系统程序设计

数据库技术之学生成绩管理系统程序设计<数据库技术>课程设计<学生成绩管理系统>程序附录用户登陆窗口代码: Dim username As String, userpass As String Private Sub Command1_Click() Adodc1.Recordset.MoveFirstAdodc1.Recordset.Find ("userID='" & Text1 & "'") IfAdodc1.Recordset.EOF ThenMsgBox "无此用户,请重新输入!"Exit SubElseabc = Adodc1.Recordset.Fields(1)If Text2 = Trim(abc) ThenMsgBox "欢迎使用本系统,点击进入!", vbOKOnly, "登陆" Me.HideForm2.ShowElseMsgBox " 用户名或密码不正确, 请重新输入!"Text1 = ""Text2 = ""Exit SubEnd IfEnd IfEnd SubPrivate Sub Command2_Click() EndEnd Sub添加记录代码:Private Sub Command1_Click() Adodc1.Recordset.AddNewText1 = InputBox(" 请输入学生学号", " 添加学号")Text2= InputBox("请输入学生姓名", " 添加姓名")Text3= InputBox("请输入学生性别", " 添加性别")Text4= InputBox("请输入学生年龄", " 添加年龄")If Not IsNumeric(Text4) Then MsgBox " 请输入数值" Text4.SetFocusEnd IfText5 = InputBox(" 请输入学生系别", " 添加系别") resu = MsgBox(" 确认添加到数据库", vbOKCancel, " If resu =确认添加") vbOK ThenAdodc1.Recordset.UpdateElseAdodc1.Recordset.DeleteEnd IfEnd SubPrivate Sub Command2_Click()Me.HideForm2.ShowEnd Sub学生查询代码:Private Sub Command1_Click()If Text1 = "" ThenMsgBox " 请输入查询条件"Text1.SetFocusEnd IfIf Option1.Value = True ThenAdodc1.Recordset.Find ("sno='" & Text1 & " '")If Adodc1.Recordset.EOF Then MsgBox " 没有该学生ElseIf Option2.Value = True ThenAdodc1.Recordset.Find ("sname='" & Text1 & " '")If Adodc1.Recordset.EOF Then MsgBox " 没有该学生" End IfEnd SubPrivate Sub Option1_Click()Text2 = ""Adodc1.Recordset.MoveFirstEnd SubPrivate Sub Option2_Click()Text1 = ""Adodc1.Recordset.MoveFirstEnd Sub 成绩查询代码:Private Sub Command1_Click()If Text4 = "" ThenMsgBox " 请输入查询的学号"Text4.SetFocusEnd IfAdodc1.Recordset.MoveFirst abcd = "Sno='" & Text4 & " '" Adodc1.Recordset.Find (abcd)If Adodc1.Recordset.EOF ThenMsgBox " 没有该学生记录"Text4.SetFocusEnd IfEnd SubPrivate Sub Text4_Change()If Len(Text4) > 0 ThenCommand1.Enabled = TrueElseCommand1.Enabled = FalseEnd IfEnd Sub修改记录代码:Private Sub Adodc1_MoveComplete(ByVal adReason AsADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & "/"& Adodc1.Recordset.RecordCountEnd SubPrivate Sub Command1_Click(Index As Integer)Select Case IndexCase 0Adodc1.Recordset.MoveFirst ' 一条Case 1Adodc1.Recordset.MovePrevious ' 一条If Adodc1.Recordset.BOFAdodc1.Recordset.MoveFirstCase 2Adodc1.Recordset.MoveNext 'If Adodc1.Recordset.EOFAdodc1.Recordset.MoveLastCase 3Adodc1.Recordset.MoveLast ' 后一条Case 4Dim mno As Stringmno = InputBox(" 请输入学号", " 查找窗") 存到变量内Adodc1.Recordset.MoveFirst ' 录指针到第一条记录上Adodc1.Recordset.Find ("sno='" & mno & "'") '用.Find 方法查找指定科目第上Then 下一条Then最If Adodc1.Recordset.EOF Then MsgBox " 无此学号!" & Adodc1.Recordset.AbsolutePosition, , " 提示"End SelectEnd SubPrivate Sub Command2_Click()Adodc1.Recordset.UpdateEnd Sub成绩添加代码:Private Sub Command1_Click()Dim adc As StringAdodc1.Recordset.AddNewa: Text1 = InputBox(" 输入学生学号", " 添加成绩")mm = Len(Text1)For i = 1 To mmabc = Mid(Text1, i, 1)If abc < "0" Or abc > "9" ThenMsgBox " 输入格式不正确请重新输入"GoTo aEnd IfNext ib: Text2 = InputBox(" 输入课程号", " 添加成绩")mm = Len(Text2)For i = 1 To mmabc = Mid(Text2, i, 1)If abc < "0" Or abc > "9" ThenMsgBox " 输入格式不正确请重新输入"GoTo bEnd IfNext ic: Text3 = InputBox(" 输入学生成绩", " 添加成绩")mm = Len(Text3)For i = 1 To mmabc = Mid(Text3, i, 1)If abc < "0" Or abc > "9" ThenMsgBox " 输入格式不正确请重新输入"GoTo aEnd IfNext iresu = MsgBox(" 确认添加数据库??", vbOKOnly, " 确认添加") If resu = vbOK ThenAdodc1.Recordset.Update ElseText1 = ""Text2 = ""Text3 = ""End IfEnd Sub学生档案管理代码:Private Sub Command1_Click(Index As Integer) Select Case IndexCase 0Adodc1.Recordset.MoveFirst ' 一条Case 1Adodc1.Recordset.MovePrevious ' 一条If Adodc1.Recordset.BOFAdodc1.Recordset.MoveFirstCase 2Adodc1.Recordset.MoveNext 'If Adodc1.Recordset.EOFAdodc1.Recordset.MoveLastCase 3Adodc1.Recordset.MoveLast ' 后一条上Then下一条ThenCase 4Dim mno As Stringmno = InputBox(" 请输入学号", " 查找窗")存到变量内Adodc1.Recordset.MoveFirst ' 录指针到第一条记录上Adodc1.Recordset.Find ("sno='" & mno & "'") ' 用.Find 方法查找指定科目If Adodc1.Recordset.EOF Then MsgBox " Adodc1.Recordset.AbsolutePosition, , " 提示End SelectEnd SubPrivate Sub Command2_Click()Dim abcd As StringDim find1a: If Option1.Value = Option2.Value ThenMsgBox " 请选择查询条件!"Exit SubEnd IfIf Text6.Text = "" Then ' 将输入值移动记无此学号!" &MsgBox " 请输入查询条件"Text1.SetFocusExit SubEnd IfIf Option1.Value = True ThenAdodc1.Recordset.Find ("sno='" & Text6 & " '")If Adodc1.Recordset.EOF Then MsgBox " 没有该学生" ElseIf Option2.Value = True ThenAdodc1.Recordset.Find ("sname='" & Text6 & " '")If Adodc1.Recordset.EOF Then MsgBox " 没有该学生" End IfEnd SubPrivate Sub Command3_Click()If Option3.Value = True ThenAdodc1.Recordset.UpdateText1.Locked = TrueText2.Locked = TrueText3.Locked = TrueText4.Locked = TrueText5.Locked = TrueElseAdodc1.Recordset.DeleteAdodc1.Recordset.Update End IfEnd SubPrivate Sub Option1_Click() Text6 = "" Adodc1.Recordset.MoveFirst End SubPrivate Sub Option2_Click() Text6 = "" Adodc1.Recordset.MoveFirst End SubPrivate Sub Option3_Click() Command3.Enabled = True Text1.Locked = False Text2.Locked = False Text3.Locked = False Text4.Locked = False Text5.Locked = False End SubPrivate Sub Option4_Click() Command3.Enabled = True End Sub。

相关主题