c#登录窗体密码错误三次关闭窗体

c#登录窗体密码错误三次关闭窗体

ID:17001432

大小:31.00 KB

页数:6页

时间:2018-08-26

c#登录窗体密码错误三次关闭窗体_第1页
c#登录窗体密码错误三次关闭窗体_第2页
c#登录窗体密码错误三次关闭窗体_第3页
c#登录窗体密码错误三次关闭窗体_第4页
c#登录窗体密码错误三次关闭窗体_第5页
资源描述:

《c#登录窗体密码错误三次关闭窗体》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Configuration;usingSystem.Data.SqlClient;namespacedenglu1._0{publicpartialc

2、lassForm1:Form{stringstr=string.Empty;interrorcount=0;publicForm1(){InitializeComponent();}privatevoidbtn_login_Click(objectsender,EventArgse){str=ConfigurationManager.ConnectionStrings["strcnn"].ConnectionString;intsqlerror=GetError();//获取当期用户的登陆次数,以便进行比

3、较if(sqlerror>=3){20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelenderDateTimeerrortim

4、e=GetErrorTime();//Subtract函数减去指定时间,返回一个时间差,时间的格式可以是分钟也可以是秒、小时TimeSpanspan=DateTime.Now.Subtract(errortime);doubleminute=span.TotalMinutes;//取时间间隔的分钟数//doublem=span.TotalSeconds;if(minute<2){MessageBox.Show("您已经连续3次输入密码错误,系统已被锁定,请两分钟之后再次重试");//后面的代码不执行ret

5、urn;}else{errorcount=0;UpdateError(errorcount);}}errorcount=GetError();DataTabledt=GetDataTable();if(dt.Rows.Count<=0){errorcount++;UpdateError(errorcount);UpdateErrorTime();MessageBox.Show("输入的用户名和密码不正确,请重新输入");}20currencydeposit,weprescribeapassonaregul

6、arbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelenderelseif(dt.Rows.Count>1){MessageBox.Show("系统出现故障,请与管理员联系");}else{//登陆成功后,错误次

7、数清零errorcount=0;UpdateError(errorcount);MessageBox.Show("登陆成功");}}//更改用户登陆错误的当前时间privatevoidUpdateErrorTime(){SqlConnectionsqlcnn=newSqlConnection(str);SqlCommandsqlcmm=newSqlCommand();sqlcnn.Open();sqlcmm.Connection=sqlcnn;sqlcmm.CommandText="updateusers

8、seterrortime=@errortimewhereusername=@username";sqlcmm.Parameters.AddWithValue("@errortime",DateTime.Now);sqlcmm.Parameters.AddWithValue("@username",this.txt_name.Text);sqlcmm.ExecuteNonQuery();}//获取当前用户错误登陆时的时间priv

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。