本地保存登录账号实现忘记密码及自动登录

  #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 登录中的忘记密码及自动登录的更多相关文章

  1. php中实现记住密码下次自动登录的例子

    这篇文章主要介绍了php中实现记住密码下次自动登录的例子,本文使用cookie实现记住密码和自动登录功能,需要的朋友可以参考下 做网站的时候经常会碰到要实现记住密码,下次自动登录,一周内免登陆,一个月 ...

  2. 基于localStorge开发登录模块的记住密码与自动登录

    前沿||我是乐于分享,善于交流的鸟窝 先做写一篇关于登录模块中记住密码与自动登录的模块.鸟窝微信:jkxx123321 关于这个模块功能模块的由来,这是鸟大大的处女秀,为什么这么说呢?一天在群里,一个 ...

  3. WinForm应用程序的开机自启、记住密码,自动登录的实现

    一.思路: 1.开机自启,自然是需要用到注册表,我们需要把程序添加到电脑的注册表中去 2.记住密码,自动登录,开机自启,在页面的呈现我们都使用复选框按钮来呈现 3.数据持久化,不能是数据库,可以是sq ...

  4. 64位 windows10,MYSQL8.0.13重置密码(忘记密码或者无法登录)

    上一节的MySQL的配置安装里,并没有用到配置文件my.ini.那在MYSQL8.0.13如何解决密码重置问题呢.我去网上搜了好多的资料都是改配置文件my.ini的,后来终于找到了一条命令:操作步骤如 ...

  5. 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观

    简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...

  6. Centos 解决SSH 免密码登录 以及Crontab制作定时SSH自动登录和关闭的脚本

    一.SSH免密码登录 假设要登录的机器为192.168.1.100,当前登录的机器为192.168.1.101. 首先在101的机器上生成密钥(如果已经生成可以跳过): $ ssh-keygen -t ...

  7. 数据加密实战之记住密码、自动登录和加密保存数据运用DES和MD5混合使用

    MD5的简介:MD5即Message-Digest Algorithm 5(信息-摘要算法5),用于确保信息传输完整一致.是计算机广泛使用的杂凑算法之一(又译摘要算法.哈希算法),主流编程语言普遍已有 ...

  8. cookie、session及实现记住密码,自动登录

    在登录帐号.密码框下,有三种帐号登录模式可供选择,用户可根据自己的具体情况选择其中一种适合自己的模式. 1.网吧模式:勾选网吧模式后,登录的帐号会在歪歪注销/退出的时候自动清除,不会留在登录框中,可以 ...

  9. Android 记住密码和自动登录界面的实现(SharedPreferences 的用法)

    原文:http://blog.csdn.net/liuyiming_/article/details/7704923 SharedPreferences介绍: SharedPreferences是An ...

随机推荐

  1. 报错:NoSuchMethodError: kafka.javaapi.PartitionMetadata.leader()Lkafka/cluster/Broker;

    报错现象: 在pom文件添加: <dependency> <groupId>org.apache.kafka</groupId> <artifactId> ...

  2. 学习MeteoInfo二次开发教程(七)

    1.站点文件 12010615.syn在D:\Program Files (x86)\MeteoInfo\SampleSYNOP_Stations.csv在D:\Program Files (x86) ...

  3. vuex教程,vuex使用介绍案例

    1.demopageaction: import Vue from "vue"; import Store from "../../store.js"; imp ...

  4. Vue自学笔记--项目的创建

    一.项目的创建 1.必须要安装nodejs    2.搭建vue的开发环境 ,安装vue的脚手架工具   官方命令行工具        npm install --global vue-cli  /  ...

  5. 【Python】启动迅雷下载

    import subprocess import base64 thunder_path = 'E:\Thunder\Program\Thunder.exe' def Url2Thunder(url) ...

  6. Oracle 关联查询

    select count(1),a.policy_id from gp_pol_prod a where a.product_id=8401 group by a.policy_id having c ...

  7. Python正则替换字符串函数re.sub用法示例(1)

    本文实例讲述了Python正则替换字符串函数re.sub用法.分享给大家供大家参考,具体如下: python re.sub属于python正则的标准库,主要是的功能是用正则匹配要替换的字符串然后把它替 ...

  8. 一个free异常引发的异常

    有同事反馈说自己的线程不工作,查看堆栈发现其打印如下: # # # # # # # # , info= # <signal handler called> # # # # # # # , ...

  9. 一个nginx 回源限速的bug处理过程记录

    一个生产环境,nginx占用cpu很高. top - :: up day, :, users, load average: 13.26, 13.20, 13.20 Tasks: total, runn ...

  10. ISNUMERIC使用说明和BUG

    ISNUMERIC ( expression )参数 expression 要计算的表达式.返回类型 int 备注当输入表达式的计算结果为有效的 numeric 数据类型时,ISNUMERIC 返回 ...