Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr1 As DataRow
cmd.C
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
Cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
If cmd.ExecuteScalar() = 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("您输入的用户名或者密码错误,请重新输入!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
dr1 = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr1("Password") Then
If dt.DataRows.Count = 1 Then
Dim d1 As Date = dt.DataRows(0)("最近在线")
Dim d2 As Date = Date.now()
Dim t As TimeSpan = d2 - d1
If t.TotalSeconds >= 30 Then ‘ 30是秒数,就是用户在30秒没有报道的话,会被系统认为退出,计划管理是10秒执行一次,具体自己修改即可
_UserName = UserName
_UserGroup = dr1("Group")
Dim s As String = e.Form.Controls("UserName").Value '这段代码是用来保存用户名的
FileSys.WriteAllText("c:\UserName.txt", s, False, Encoding.Default)
e.Form.Close
Else
MessageBox.Show("此用户已登录!","提示",MessageBoxButtons.OK)
End If
End If
Else
Messagebox.show("您输入的用户名或者密码错误,请重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If