Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
下载信息 [文件大小: 下载次数: ] | |
![]() |
取消按钮代码改成:
Syscmd.Project.Exit(False)
“登录窗口”的“确定”按钮里如何写代码,达到:当在用户名中输入的用户名在后台数据源中找不到的情况下,如何处理?是退出还是转入“增加用户”窗口,代码怎么写
你现在用户名输入框是不允许输入的,所以你说的问题不会出现。
如果允许输入呢
1、没必要允许直接输入
2、如果你一定要允许直接输入,可以在确定按钮,判断输入的用户是否存在:
Dim UserName As
String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As
DataTable
Dim dr As
DataRow
cmd.ConnectionName = "User"
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End
If
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.Datarows.Count = 0 Then
Messagebox.show("用户不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("Password") Then
_UserName = UserName
_UserGroup = dr("Group")
e.Form.Close
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If