C# Winform 登录中的忘记密码及自动登录
本地保存登录账号实现忘记密码及自动登录
#region 删除本地自动登录及记住密码信息
/// <summary>
/// 删除本地自动登录及记住密码信息
/// </summary>
private void DeleteSelfMotionLoginOrRememberPwd()
{
if (cbAutomatic.Checked == false)
{
if (Directory.Exists("SelfMotionLogin"))
{
if (File.Exists(@"SelfMotionLogin/SelfMotionLoginInfo.xml"))
{
File.Delete(@"SelfMotionLogin/SelfMotionLoginInfo.xml");
}
}
}
if (cbRememberPwd.Checked == false)
{
if (Directory.Exists("RememberPwd"))
{
if (File.Exists(@"RememberPwd\" + txtLoginName.Text + ".xml"))
{
File.Delete(@"RememberPwd\" + txtLoginName.Text + ".xml");
}
}
}
}
#endregion #region 保存自动登录及记住密码到本地事件方法
/// <summary>
/// 保存自动登录及记住密码到本地事件方法
/// </summary>
private void SelfMotionLoginOrRememberPwd()
{ if (cbAutomatic.Checked && cbRememberPwd.Checked)
{
XElement xml = new XElement(
new XElement("LoginInfo",
new XElement("SelfMotionLogin",
new XElement("UserName", txtLoginName.Text),
new XElement("UserPwd", txtLoginPwd.Text)
))
);
xml.Save(@"SelfMotionLogin/SelfMotionLoginInfo.xml");
}
else if (cbRememberPwd.Checked)
{
XElement xml = new XElement(
new XElement("LoginInfo",
new XElement("RememberPwd",
new XElement("UserName", txtLoginName.Text),
new XElement("UserPwd", txtLoginPwd.Text)
))
);
xml.Save(@"RememberPwd/" + txtLoginName.Text + ".xml");
}
}
#endregion #region 获取自动登录及记住密码信息
#region 获取记住密码信息
/// <summary>
/// 获取记住密码信息
/// </summary>
private void GetRememberPwd()
{
if (Directory.Exists("RememberPwd"))
{
if (File.Exists(@"RememberPwd/" + txtLoginName.Text + ".xml"))
{
XElement xml = XElement.Load(@"RememberPwd/" + txtLoginName.Text + ".xml");
var AllInfo = from info in xml.Elements("RememberPwd")
select new Users
{
UserName = info.Element("UserName").Value,
UseuPwd = info.Element("UserPwd").Value
};
if (AllInfo != null)
{
foreach (Users l in AllInfo)
{
txtLoginName.Text = l.UserName;
txtLoginPwd.Text = l.UseuPwd;
cbRememberPwd.Checked = true;
}
}
}
}
}
#endregion #region 获取本地自动登录
/// <summary>
/// 获取本地自动登录
/// </summary>
private void GetSelfMotionLogin()
{
if (Directory.Exists("SelfMotionLogin"))
{
if (File.Exists(@"SelfMotionLogin/SelfMotionLoginInfo.xml"))
{
XElement xml = XElement.Load(@"SelfMotionLogin/SelfMotionLoginInfo.xml");
var AllInfo = from info in xml.Elements("SelfMotionLogin")
select new Users
{
UserName = info.Element("UserName").Value,
UseuPwd = info.Element("UserPwd").Value
};
if (AllInfo != null)
{
foreach (Users l in AllInfo)
{
txtLoginName.Text = l.UserName;
txtLoginPwd.Text = l.UseuPwd;
cbAutomatic.Checked = true;
var checkoutData = from a in am.SelectUsersAll()
where a.UserName == l.UserName
select a;
Users getCheckoutData = new Users();
foreach (var get in checkoutData)
{
getCheckoutData.UserName = get.UserName;
getCheckoutData.UseuPwd = get.UseuPwd;
}
DialogResult dialogResult = MessageBox.Show("你确定要自动登录 [" + txtLoginName.Text + "]吗?", "自动登录提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Asterisk);
if (dialogResult == DialogResult.OK)
{
if (txtLoginName.Text != getCheckoutData.UserName)
{
MessageBox.Show("自动登录账号 [" + txtLoginName.Text + "] 不存在!", "登录出错",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtLoginName.Focus();
return;
}
if (txtLoginPwd.Text != getCheckoutData.UseuPwd)
{
MessageBox.Show("自动登录密码不正确!", "登录提示",
MessageBoxButtons.OK,
MessageBoxIcon.Asterisk);
txtLoginPwd.Focus();
return;
}
//传值
List<Users> Userss = am.SelectUsersAll().FindAll((p) => p.UserName.IndexOf(txtLoginName.Text) >= );
foreach (Users a in Userss)
{
saveUsersInfo.Name = a.Name;
saveUsersInfo.userNo = a.UNo;
} this.Hide();
FrmMain frm = new FrmMain();
frm.Show();
//List<Users> Users = am.SelectUsersByconn(txtLoginName.Text);
//foreach (Users a in Users)
//{
// Ano = a.ANo;
// Name = a.Name;
//}
}
}
}
}
else
{
timeLogin.Enabled = false;
}
}
else
{
timeLogin.Enabled = false;
}
}
#endregion private void cbAutomatic_CheckedChanged(object sender, EventArgs e)
{
if (cbAutomatic.Checked)
{
cbRememberPwd.Checked = true;
return;
}
}
#endregion
C# Winform 登录中的忘记密码及自动登录的更多相关文章
- php中实现记住密码下次自动登录的例子
这篇文章主要介绍了php中实现记住密码下次自动登录的例子,本文使用cookie实现记住密码和自动登录功能,需要的朋友可以参考下 做网站的时候经常会碰到要实现记住密码,下次自动登录,一周内免登陆,一个月 ...
- 基于localStorge开发登录模块的记住密码与自动登录
前沿||我是乐于分享,善于交流的鸟窝 先做写一篇关于登录模块中记住密码与自动登录的模块.鸟窝微信:jkxx123321 关于这个模块功能模块的由来,这是鸟大大的处女秀,为什么这么说呢?一天在群里,一个 ...
- WinForm应用程序的开机自启、记住密码,自动登录的实现
一.思路: 1.开机自启,自然是需要用到注册表,我们需要把程序添加到电脑的注册表中去 2.记住密码,自动登录,开机自启,在页面的呈现我们都使用复选框按钮来呈现 3.数据持久化,不能是数据库,可以是sq ...
- 64位 windows10,MYSQL8.0.13重置密码(忘记密码或者无法登录)
上一节的MySQL的配置安装里,并没有用到配置文件my.ini.那在MYSQL8.0.13如何解决密码重置问题呢.我去网上搜了好多的资料都是改配置文件my.ini的,后来终于找到了一条命令:操作步骤如 ...
- 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观
简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...
- Centos 解决SSH 免密码登录 以及Crontab制作定时SSH自动登录和关闭的脚本
一.SSH免密码登录 假设要登录的机器为192.168.1.100,当前登录的机器为192.168.1.101. 首先在101的机器上生成密钥(如果已经生成可以跳过): $ ssh-keygen -t ...
- 数据加密实战之记住密码、自动登录和加密保存数据运用DES和MD5混合使用
MD5的简介:MD5即Message-Digest Algorithm 5(信息-摘要算法5),用于确保信息传输完整一致.是计算机广泛使用的杂凑算法之一(又译摘要算法.哈希算法),主流编程语言普遍已有 ...
- cookie、session及实现记住密码,自动登录
在登录帐号.密码框下,有三种帐号登录模式可供选择,用户可根据自己的具体情况选择其中一种适合自己的模式. 1.网吧模式:勾选网吧模式后,登录的帐号会在歪歪注销/退出的时候自动清除,不会留在登录框中,可以 ...
- Android 记住密码和自动登录界面的实现(SharedPreferences 的用法)
原文:http://blog.csdn.net/liuyiming_/article/details/7704923 SharedPreferences介绍: SharedPreferences是An ...
随机推荐
- 使用docker compose编排容器
一.安装docker compose 二进制包安装 1.安装 Docker Compose 从 官方 GitHub Release 处直接下载编译好的二进制文件即可 # curl -L https:/ ...
- List接口、Set接口和Map接口
1.List和Set接口继承自Collection接口,而Map不是继承的Collection接口 Map没有继承Collection接口,Map提供key到value的映射;一个Map中不能包含相同 ...
- 红黑树Python实现
# coding=utf-8 # 红黑树Python实现 # 颜色常量 RED = 0 BLACK = 1 def left_rotate(tree, node): if not node.right ...
- bitbucket 上公钥SSH key如何add key并进行项目运用
前提:从sourcetree 添加项目时老是拉取不下来,查到原因是应为bitbucket需要SSH key公钥 目的:公钥相当于你在任何一台电脑只要有公钥授权就可以随时提交代码到服务器 原因: 1.很 ...
- Python2.x 与 Python3.x 共存
一.Python2.x 安装 说明:我们先安装python2.x,默认C盘安装即可. 链接: https://pan.baidu.com/s/1yfsVNKmeOR-2C0fK0rPh4A 密码: x ...
- RMI(远程方法调用)入门
这两篇可以入门 http://www.cnblogs.com/ninahan0419/archive/2009/06/25/javarmi.html http://www.cnblogs.com/wx ...
- Centos创建用户
1.创建用户: adduser fish 2.用户设置密码: passwd linuxidc 3.创建文件夹: mkdir fish 4.删除文件夹 rm -rf fish 5.文件夹重命名: mv ...
- ios unicode
转义字符,反斜扛\ \u 后跟4位16进制数 \U 后跟8位16进制数
- mapper.xml文件,sql语句参数为list
<insert id="insertPjCustomAttribute" parameterType="com.devops.server.model.PjCust ...
- codeforces 1041A Heist
electronic a.电子的 heist v.抢劫 in ascending order 升序 indice n.标记 device n.装置设备 staff n.职员 in arbitrary ...