第五章 编码实现 5.1 程序编码 登陆界面如图5.1所示。 copyright paper51.com
http://www.paper51.com 图5.1登陆界面 paper51.com 程序代码如下: http://www.paper51.com Function Check_Password(ByVal UserName As String,ByVal UserPassword As String) As Integer copyright paper51.com
On Error GoTo ER2: 内容来自论文无忧网 www.paper51.com If ConnectToServer = True Then copyright paper51.com SetobjRs = New Recordset copyright paper51.com StrSql = "select cOperatorPassword from tOperators wherecOperatorName='" & Trim(cboName.Text) & "'" 内容来自论文无忧网 www.paper51.com GetData StrSql 'Reference function to get data copyright paper51.com IfobjRs.EOF Then copyright paper51.com Check_Password = 0 'This Operator not exist 内容来自www.paper51.com Else paper51.com If txtPassword.Text <>Trim(objRs.Fields("cOperatorPassword").Value) Then copyright paper51.com Check_Password = 1 ' password error 内容来自www.paper51.com
Else http://www.paper51.com Check_Password = 2 'password ok copyright paper51.com CurrentOpname = Trim(cboName.Text) http://www.paper51.com CurrentOppassword = objRs.Fields("cOperatorPassword").Value 内容来自www.paper51.com 'Here can save a operator grade for expand copyright paper51.com
End If http://www.paper51.com EndIf http://www.paper51.com objCon.Close 内容来自www.paper51.com
ExitFunction copyright paper51.com ER2: 内容来自www.paper51.com MsgBox Err.Description http://www.paper51.com Check_Password = 255 内容来自www.paper51.com End If copyright paper51.com
End Function 内容来自论文无忧网 www.paper51.com Private Sub cmdCancel_Click() 内容来自论文无忧网 www.paper51.com
Unload Me 内容来自论文无忧网 www.paper51.com End 内容来自www.paper51.com End Sub http://www.paper51.com Private Sub cmdOK_Click() paper51.com Dim intCheck As Integer paper51.com 'Static intLogTimes to save user login times paper51.com Static intLogTimes As Integer paper51.com
intLogTimes = intLogTimes + 1 'Save login times paper51.com If intLogTimes > MaxLogTimes Then 内容来自www.paper51.com 'Over allowed login times then list information http://www.paper51.com MsgBox "You have over allowed loghin times,login failure !",vbCritical, "LoginError" paper51.com
Unload Me 内容来自www.paper51.com Else 内容来自论文无忧网 www.paper51.com intCheck = Check_Password(Trim(txtPassword), Trim(cboName)) 内容来自www.paper51.com Select Case intCheck http://www.paper51.com Case0 内容来自论文无忧网 www.paper51.com
MsgBox "Your are not a system user !", vbInformation +vbOKOnly, "LoginError" copyright paper51.com Case1 copyright paper51.com MsgBox "Password error ,please check your password !",vbInformation + vbOKOnly, "LoginError" http://www.paper51.com Case2 内容来自www.paper51.com
Unload Me 内容来自www.paper51.com If CurrentOpname = "Admin" And CurrentOppassword ="1" Then http://www.paper51.com
MainWin.mnuOp.Visible = True 内容来自www.paper51.com Else paper51.com MainWin.mnuOp.Visible = False paper51.com
End If 内容来自论文无忧网 www.paper51.com Load MainWin 内容来自www.paper51.com MainWin.Show paper51.com EndSelect copyright paper51.com End If paper51.com End Sub paper51.com |