目录
4.2 程序输入输出描述
4.2.1 主模块
1.输入项目:操作系统传递至的各种消息以及用户的输入数据。
2.输出项目:用户界面显示。
4.2.1 学生管理模块
1.输入项目:与学生管理操作子对话框有关的用户输入及系统消息。
2.输出项目:操作结果显示。
4.2.2 图书管理模块
1.输入项目:用户口令。
2.输出项目:相应的界面。
4.2.3 借阅管理模块
1.输入项目:学生学号、图书编号。
2.输出项目:学生信息、相关借书信息。
4.2.4 归还管理模块
1.输入项目:图书编号。
2.输出项目:相关学生信息。
4.2.5 管理措施设置模块
1.输入项目:用户的输入。
2.输出项目:根据用户的输入显示相应的对话框。
5.1 程序编码
登陆界面如图5.1所示。
图5.1登陆界面
程序代码如下:
Function Check_Password(ByVal UserName As String,ByVal UserPassword As String) As Integer
On ErrorGoTo ER2:
IfConnectToServer = True Then
SetobjRs = New Recordset
StrSql ="select cOperatorPassword from tOperators where cOperatorName='"& Trim(cboName.Text) & "'"
GetDataStrSql 'Reference function to get data
IfobjRs.EOF Then
Check_Password = 0 'This Operator not exist
Else
IftxtPassword.Text <>Trim(objRs.Fields("cOperatorPassword").Value) Then
Check_Password = 1 ' password error
Else
Check_Password = 2 'password ok
CurrentOpname = Trim(cboName.Text)
CurrentOppassword =objRs.Fields("cOperatorPassword").Value
'Here can save a operator grade for expand
EndIf
End If
objCon.Close
ExitFunction
ER2:
MsgBoxErr.Description
Check_Password = 255
End If
End Function
Private Sub cmdCancel_Click()
Unload Me
End
End Sub
Private Sub cmdOK_Click()
Dim intCheckAs Integer
'StaticintLogTimes to save user login times
StaticintLogTimes As Integer
intLogTimes= intLogTimes + 1 'Save login times
IfintLogTimes > MaxLogTimes Then
'Overallowed login times then list information
MsgBox"You have over allowed loghin times,login failure !", vbCritical,"LoginError"
UnloadMe
Else
intCheck= Check_Password(Trim(txtPassword), Trim(cboName))
SelectCase intCheck
Case 0
MsgBox "Your are not a system user !", vbInformation +vbOKOnly, "LoginError"
Case 1
MsgBox "Password error ,please check your password !",vbInformation + vbOKOnly, "LoginError"
Case 2
Unload Me
IfCurrentOpname = "Admin" And CurrentOppassword = "1" Then
MainWin.mnuOp.Visible = True
Else
MainWin.mnuOp.Visible = False
EndIf
LoadMainWin
MainWin.Show
EndSelect
End If
End Sub
主界面如图5.2所示。
图5.2 程序主界面
程序代码如下:
Option Explicit
Private Sub MDIForm_Activate()
IfCurrentOpname = "Admin" Then
StatusBar2.Panels(1).Text = "管理员:"& CurrentOpname
Toolbar1.Buttons(1).Visible = True
Toolbar1.Buttons(2).Visible = True
Else
StatusBar2.Panels(1).Text = "操作员:"& CurrentOpname
Toolbar1.Buttons(1).Visible = False
Toolbar1.Buttons(2).Visible = False
End If
End Sub
Private Sub MDIForm_MouseDown(Button As Integer, ShiftAs Integer, X As Single, Y As Single)
If Button =vbRightButton Then
PopupMenumnuOperation 'Design popup menu
End If
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
CheckConnect 'Reference functionto make objcon break if connection is open
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show
End Sub
Private Sub mnuBookQuery_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmBookQuery
frmBookQuery.Show
End Sub
Private Sub mnuBookRegist_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmBookReg
frmBookReg.Show
End Sub
Private Sub mnuBorrowQuery_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmReadQuery
frmReadQuery.Show
End Sub
Private Sub mnuExit_Click()
CheckConnect'Reference function to make objcon break if connection is open
Unload Me
End
End Sub
Private Sub mnuReLogin_Click()
CheckConnect'Reference function to make objcon break if connection is open
Unload Me
LoadfrmLogin
frmLogin.Show
End Sub
Private Sub mnuVipQuery_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmVipQuery
frmVipQuery.Show
End Sub
Private Sub mnuVipRegist_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmVipReg
frmVipReg.Show
End Sub
Private Sub munReadRegist_Click()
CheckConnect'Reference function to make objcon break if connection is open
LoadfrmReadRegist
frmReadRegist.Show
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button AsMSComctlLib.Button)
Select Case Button.Key
Case"operatorReg"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmAdmin
frmAdmin.Show
Case"vipReg"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmVipReg
frmVipReg.Show
Case"vipQuery"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmVipQuery
frmVipQuery.Show
Case"BookReg"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmBookReg
frmBookReg.Show
Case"bookQuery"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmBookQuery
frmBookQuery.Show
Case"readReg"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmReadRegist
frmReadRegist.Show
Case"readQuery"
CheckConnect 'Reference function to make objcon break if connection isopen
LoadfrmReadQuery
frmReadQuery.Show
End Select
End Sub
操作员管理界面如图5.3所示。
图5.3操作员管理界面
代码如下:
Option Explicit
Sub SetTextEmpty()
'This function is set all text to empty
txtOpID.Text = ""
txtOpName.Text = ""
txtOpPwd.Text = ""
cboOpGrade.Text = ""
txtOpAddTime.Text = ""
End Sub
Sub RefreshOperator()
'This function is to Refresh text
txtOpID.Text = objRs.Fields(0).Value
txtOpName.Text = objRs.Fields(1).Value
txtOpPwd.Text = objRs.Fields(2).Value
cboOpGrade.Text = objRs.Fields(3).Value
'txtOpAddTime.Text = objRs.Fields(4).Value
End Sub
Private Sub cmdAdd_Click()
txtOpID.Enabled = True 'You don't change datagrid untill you add datafinish
dgdOp.Enabled = False
IfcmdAdd.Caption = "添加" Then
cmdAdd.Caption = "确定"
SetTextEmpty ' reference settextempty founction to set empty
cmdDel.Enabled = False
cmdModify.Enabled = False
cmdRefresh.Enabled = False
txtOpID.SetFocus
Else
IfTrim(txtOpName.Text) = "" Then
MsgBox "Operator name must not null ,please input operator name!", vbInformation + vbOKOnly
txtOpName.SetFocus
ExitSub
ElseIfTrim(txtOpID.Text) = "" Then
MsgBox "Operator ID must not null ,please input operator ID!", vbInformation + vbOKOnly
txtOpID.SetFocus
ExitSub
ElseIfTrim(txtOpPwd.Text) = "" Then
MsgBox "Operator password must not null ,please input operatorpassword !", vbInformation + vbOKOnly
txtOpPwd.SetFocus
ExitSub
Else
With objRs
checkAddNew = True
.Filter = "cOperatorID='" & Trim(txtOpID.Text) &"'"
If .RecordCount > 0 Then
MsgBox "This operator has been exist !"
txtOpID.Text = ""
txtOpID.SetFocus
.Filter = "cOperatorID<>''"
cmdRefresh.Value = True 'To executer refresh once
checkAddNew = False
cmdDel.Enabled = True
cmdModify.Enabled = True
cmdAdd.Caption = "添加(&A)"
txtOpID.Enabled = False
cmdRefresh.Enabled = True
dgdOp.Enabled = True
checkAddNew = False
Exit Sub
End If
checkAddNew = True
.AddNew
.Fields(0).Value = Trim(txtOpID.Text)
.Fields(1).Value = Trim(txtOpName.Text)
.Fields(2).Value = Trim(txtOpPwd.Text)
.Fields(3).Value = Trim(cboOpGrade.Text)
.Fields(4).Value = Trim(txtOpAddTime.Text)
.Update
MsgBox "Operator add success !", vbInformation + vbOKOnly
.Filter = "cOperatorID<>''"
cmdRefresh.Value = True 'To executer refresh once
EndWith
checkAddNew = False
'----There will reference a founction to set empty
txtOpID.Enabled = False
cmdDel.Enabled = True
cmdModify.Enabled = True
cmdRefresh.Enabled = True
cmdAdd.Caption = "添加"
dgdOp.Enabled = True 'You can use datagrid after add finish
End If
End If
End Sub
Private Sub cmdDel_Click()
IfEmpty_Check = True Then Exit Sub 'Reference function to check if your databaseis null
If NotobjRs.EOF And objRs.RecordCount > 0 Then
IfMsgBox("The : " & txtOpName & " 's data will deletecontinue ?", vbYesNo + vbInformation) = vbYes Then
objRs.Delete
End If
End If
End Sub
Private Sub cmdModify_Click()
IfEmpty_Check = True Then Exit Sub 'Reference function to check if your databaseis null
dgdOp.Enabled = False
IftxtOpID.Text <> objRs.Fields(0).Value Then Exit Sub 'To check operator ID
IfcmdModify.Caption = "修改" Then
cmdModify.Caption = "确定"
cmdDel.Enabled = False
cmdAdd.Enabled = False
Else
WithobjRs
.Fields(0).Value = Trim(txtOpID.Text)
.Fields(1).Value =Trim(txtOpName.Text)
.Fields(2).Value = Trim(txtOpPwd.Text)
.Fields(3).Value = Trim(cboOpGrade.Text)
.Update
End With
cmdModify.Caption = "修改"
cmdDel.Enabled = True
cmdAdd.Enabled = True
dgdOp.Enabled = True
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdRefresh_Click()
RefreshOperator 'Reference function is to Refresh text
End Sub
Private Sub dgdOp_RowColChange(LastRow As Variant,ByVal LastCol As Integer)
IfcheckAddNew = True Then Exit Sub
cmdRefresh.Value = True
End Sub
Private Sub Form_Activate()
FormMiddlefrmAdmin 'Reference function to make form in MDIForm'mddile
cboOpGrade.ListIndex = 1
IfConnectToServer = True Then
SetobjRs = New ADODB.Recordset
StrSql = "select * from tOperators"
GetData StrSql 'Reference function to get data
SetdgdOp.DataSource = objRs
cmdRefresh.Value = True
End If
End Sub
Private Sub txtOpAddTime_KeyPress(KeyAscii As Integer)
'CheckInputNum 'Reference function to check input
If Not(KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _
Or KeyAscii = vbKeyBack _
Or KeyAscii = Asc("-")) Then
KeyAscii =0
End If
End Sub
Private Sub txtOpID_KeyPress(KeyAscii As Integer)
If Not(KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _
Or KeyAscii = vbKeyBack) Then
KeyAscii =0
End If
End Sub
学生登记界面如图5.4所示。
图5.4学生信息登记界面
代码如下:
更多相关毕业设计资料:www.doc78.com QQ80072749