public bool GetLoginCheck(TextBox userName, TextBox userPass)
{
try
{
SqlConnection myConn = SqlHelper.dbConn();
myConn.Open();
SqlCommand sqlCmd = new SqlCommand("select * from AdminInfo where adminNO = '"+userName.Text+"'",myConn);
SqlDataReader dataRead = sqlCmd.ExecuteReader();
if(dataRead.Read())
{
if(dataRead["adminPWD"].ToString().CompareTo(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userPass.Text,"MD5")) == 0)
{
DataAccess.Common.Usersave.Power = dataRead["adminPower"].ToString().Trim();
//Log.WriteLoginLog(userName.Text);
dataRead.Close();
myConn.Close();
return true;
}
else
{
userPass.Text = string.Empty;
userPass.Focus();
MessageBox.Show("输入的密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return false;
}
}
else
{
userName.Text=string.Empty;
userPass.Text=string.Empty;
userName.Focus();
MessageBox.Show("没有这个用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return false;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message+"读取数据错误,请检查数据库是否出错!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
Log.WriteErrorLog("发生登陆异常:"+ex.Message);
return false;
}
{
try
{
SqlConnection myConn = SqlHelper.dbConn();
myConn.Open();
SqlCommand sqlCmd = new SqlCommand("select * from AdminInfo where adminNO = '"+userName.Text+"'",myConn);
SqlDataReader dataRead = sqlCmd.ExecuteReader();
if(dataRead.Read())
{
if(dataRead["adminPWD"].ToString().CompareTo(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userPass.Text,"MD5")) == 0)
{
DataAccess.Common.Usersave.Power = dataRead["adminPower"].ToString().Trim();
//Log.WriteLoginLog(userName.Text);
dataRead.Close();
myConn.Close();
return true;
}
else
{
userPass.Text = string.Empty;
userPass.Focus();
MessageBox.Show("输入的密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return false;
}
}
else
{
userName.Text=string.Empty;
userPass.Text=string.Empty;
userName.Focus();
MessageBox.Show("没有这个用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return false;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message+"读取数据错误,请检查数据库是否出错!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
Log.WriteErrorLog("发生登陆异常:"+ex.Message);
return false;
}
解决方案 »
- winform中有没有类似快捷菜单的空控件,给下控件的名字。。。
- 在线等待:如何最快的统计arraylist中元素出现次数?
- 我做了一个WINDOWS的窗口,开辟了一个线程监听,然后用异步的的接收.可每次关闭窗口时总是显示程序还在调试
- sqlDataAdapter da=new sqlDataAdapter("GetScheduleByGivenDay",myconn)
- 求读取缓存内容的代码
- 奇怪了!内码转换的问题。
- VS。NET 2003 安装文件解压缩问题求救 , 为什么我下载 3 个RAR 文件没办法解压呢,求救
- 在C#中如何对剪切板进行操作?
- 请问一个关于动态写 sql 语句的问题,与hash有关么?
- 请问限制还有什么网址能上google
- 这个API函数在C#里应该如何声明和使用
- 调用存储过程问题(在线等!)
MS的登录框都有哪些约束,。我好仿造他的开发阿,汗了
我的语言有障碍??
hehe ~~~
密码好像没有
csdn文档中的一个讲正则表达式的文章
汗阿..................................用正则不也得知道怎么正马?
倒了。看来是我的描述有严重的bug。呵呵我要的是:
用户名:必须有复杂的字符(都有哪些呢?)。过滤非法字符(该过滤得都有什么?)。长度限制为20(多少位)。等等//。就是冒号后面的那些。我现在不知道都该有些什么
我要的不是实现方法
匹配非法字符如:< > & / ' | --------------------------------------(主要就要的这个)
正则表达式 [^<>&/|'\]+ -------------------------------------
多谢楼上的。这个应该有用。MS的安全机制中提供的,就是密码不可以过于简单得功能。太简单(指的不是用户名长度。是复杂程度)
必须有复杂字符例如@~
大家谁知道都有哪些
呵呵,玩笑一个。。
我上面还说得不明白吗???我要的不是实现方法~~~~~~
我怒了都。我的主啊`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~哈哈
调用 特殊字符验证();
调用 大小写转换();//可有可无
调用 用户输入信息对比验证();
}
字符串长度验证(){如果 长度超过XXX
用户提示框(“长度不合法,请重试!”);
否则
返回 ture;
}
特殊字符验证(){for(字符 in 非法字符数组){
如果 ture
提示(“字符”+字符+“不合法!”);返回 false;}
}
大小写转换(必须大写){for(字符 in 用户输入字符){
如果 ASC(字符)>‘36’并且<'64'{//小写字符域(ASC表示)我忘记了
提示(“字符”+字符+“不合法,必须为大写!”);返回 false;}}
} 用户输入信息对比,你了解我不多说了。
我要的是什么来着????艾`~~~~~~~~
密码 应该没有什么特殊限制,长度一般也不应该超过20,为了安全的话,同样屏蔽 可以 导致 SQL 注入的特殊字符