机房收费系统之用户登录
2017-11-26 21:41
288 查看
前言
机房敲了一个半月了,之前总是一直修改,需要好好的总结一下,首先是登陆窗体。登陆窗体:
Created with Raphaël 2.1.0登陆窗体文本框是否为空用户是否存在 (user表)密码是否正确(user表)更新onwork,worklog表登陆成功yesyesyes
问题及重点代码:
1.问题1实时错误’3704’ 对象关闭时,不允许操作
出现这个问题是因为前面写了代码mrc.Close导致后面mrc1调用mrc数据集里面的内容时无法调用。
Trim函数用来删除一个字符串的字头或字尾,删除字符串首尾的空白
End Sub 和Exit Sub的区别:
end sub 是一个过程的结束代码(每一个SUB中必须对应一个END SUB)Exit Sub 是在过程内代码执行时,可选择性的退出过程执行(即不执行Exit sub之后的代码,相当于中途退出的意思),这不是必须的。
所以代码编写的时候不要随便乱加Exit Sub
Private Sub cmdOK_Click() Dim txtSQL As String Dim txtSQL1 As String Dim txtSQL2 As String Dim mrc As ADODB.Recordset '连接user表 Dim mrc1 As ADODB.Recordset '连接onwork表 Dim mrc2 As ADODB.Recordset '连接worklog表 Dim MsgText As String If Trim(txtUserName.Text = "") Then MsgBox "文本框不能输入为空!", vbOKOnly, "提示" txtUserName.Text = "" txtPassword.Text = "" End If If Trim(txtPassword.Text = "") Then MsgBox "文本框不能输入为空!", vbOKOnly, "提示" txtUserName.Text = "" txtPassword.Text = "" End If txtSQL = "select * from user_Info where userID = '" & txtUserName.Text & "'" Set mrc = ExecuteSQL(txtSQL, MsgText) If mrc.EOF Then MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly, "提示" txtUserName = "" txtPassword = "" Exit Sub End If txtSQL = "select * from user_Info where user_PWD = '" & txtPassword.Text & "'and UserID = '" & txtUserName.Text & "'" Set mrc = ExecuteSQL(txtSQL, MsgText) If mrc.EOF Then MsgBox "密码输入不正确,请重新输入密码!", vbOKOnly, "提示" txtUserName = "" txtPassword = "" Exit Sub End If If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then Me.Hide Else MsgBox "密码不正确,请重新输入密码!", vbOKOnly, "提示" End If miCount = miCount + 1 '登陆限制 If miCount > 3 Then MsgBox "登陆超过次数限制!", vbOKOnly, "提示" End If '结束条件语句 txtSQL1 = "select * from OnWork_Info " Set mrc1 = ExecuteSQL(txtSQL1, MsgText) mrc1.AddNew mrc1.Fields(0) = Trim(txtUserName.Text) mrc1.Fields(1) = mrc.Fields(2) mrc1.Fields(2) = Date mrc1.Fields(3) = Time mrc1.Update mrc1.Close txtSQL2 = "select * from worklog_Info" Set mrc2 = ExecuteSQL(txtSQL2, MsgText) mrc2.AddNew mrc2.Fields(0) = Trim(txtUserName) 'Trim函数用来删除一个字符串的字头或字尾,删除字符串首尾的空白 mrc2.Fields(1) = mrc.Fields(2) mrc2.Fields(2) = Date mrc2.Fields(3) = Time mrc2.Update mrc2.Close MsgBox "登陆成功!", vbOKOnly, "提示" Me.Hide frmMain.Show End Sub Private Sub Form_Load() txtUserName.FontSize = txtUserName.FontSize + 10 txtPassword.FontSize = txtPassword.FontSize + 10 Me.Width = Screen.Width * 0.4 Me.Height = Screen.Height * 0.5 Left = 0 ' 在水平方向上居中显示。 Top = 0 ' 在垂直方向上居中显示 End Sub
相关文章推荐
- 机房收费系统重构之用户登录
- 【VB.NET版机房收费系统】——三层VS七层用户登录
- VB.NET版机房收费系统之七层登录
- 机房收费系统登录功能的代码记录
- 机房收费系统—模块登录
- VB机房收费系统03——登录窗体
- 个人重构机房收费系统DataGridView显示用户信息
- 机房收费系统总结之登录功能实例解析抽象工厂+配置文件
- 机房收费系统---用户手册
- 机房收费系统登录模块代码记录
- 机房收费系统系列一:运行时错误‘-2147217843(80040e4d)’;用户‘sa’登陆失败
- 机房收费系统——登录
- 机房收费系统之添加删除用户
- 机房收费系统之用户手册
- 机房收费系统--一般用户模块的建立(一)
- 机房收费系统登录模块代码记录
- 机房收费系统之登录
- 机房收费系统-登录窗体
- 【机房收费系统】用户功能&系统结构
- VB机房收费系统05——一般用户模块逻辑问题总结