药品库房管理系统+VB开题报告答辩PPT外文翻译(四)
ring
Public username As String
Public userright As String
Public conn As String
Private Sub Command1_Click()
Dim password As String
Dim respond As String
username = Text1.Text
password = Text2.Text
On Error GoTo err1
Adodc1.ConnectionString = conn
Adodc1.RecordSource = "select * from usertab where 用户名=" & "'" & username & "'" & " and " & "密码=" & "'" & password & "'"
Adodc1.Refresh
If Adodc1.Recordset.AbsolutePosition = adPosUnknown Then
respond = MsgBox("用户名或密码错误,请重新输入!", vbOKOnly, "警告")
If respond <> vbOKOnly Then
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
username = ""
password = ""
End If
Else
userright = Adodc1.Recordset.Fields("权限")
Unload frmlogin
frmmain.Show
End If
Exit Sub
err1:
MsgBox "系统配置错误!无法与服务器连接!"
userright = "0"
Unload Me
frmsysset.Show
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
'conn = Frmstart.pconn
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\his.mdb;Persist Security Info=False"
End Sub
用户修改密码界面设计:
代码设计:
Private Sub Command1_Click()
On Error GoTo err1
username = frmlogin.username
If Text1.Text <> "" And Text2.Text <> "" Then
Adodc1.RecordSource = "select * from usertab where 用户名='" & username & "' and 密码=" & "'" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.AbsolutePosition = adPosUnknown Then
MsgBox "旧密码错误!"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Else
Adodc1.Recordset.Fields("密码") = Text2.Text
Adodc1.Recordset.Update
MsgBox "密码修改成功!"
Text1.Text = ""
Text2.Text = ""
End If
Else
MsgBox "新旧密码均不得为空!"
Text1.SetFocus
End If
Exit Sub
err1:
MsgBox "远程服务器连接失败!"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo err2
chpwd.Top = (frmmain.Height - chpwd.Height) / 2 - 500
chpwd.Left = (frmmain.Width - chpwd.Width) / 2
Adodc1.ConnectionString = frmlogin.conn
Text1.Text = ""
Text2.Text = ""
Exit Sub
err2:
MsgBox "远程服务器连接失败!"
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmmain.StatusBar1.Panels(2) = "目前没有窗口被激活"
End Sub
Private Sub Form_Activate()
frmmain.StatusBar1.Panels(2) = "活动窗口:" & chpwd.Caption
End Sub