private void btnSure_Click(object sender, EventArgs e) { #region 检查用户名 if (0 == string.Compare(tbUserName.Text, "Root") || LoginManage.loginDoc.dicLoginInfo.ContainsKey(tbUserName.Text)) { MessageBox.Show("系统有重名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } #endregion #region 检查密码 //不能为空 if (string.IsNullOrEmpty(tbPassword.Text)) { MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } #endregion LoginInfo loginInfo = new LoginInfo(); loginInfo.UserName = tbUserName.Text; loginInfo.Password = SecurityMd5.Encrypt(tbPassword.Text); loginInfo.UserLevel = cbUserLevel.SelectedIndex; LoginManage.loginDoc.dicLoginInfo.Add(loginInfo.UserName, loginInfo); this.Close(); }
private void btnSure_Click(object sender, EventArgs e) { try { if (!LoginManage.loginDoc.dicLoginInfo.ContainsKey(_strCurrSelUserName)) { MessageBox.Show("密码重置失败,此账户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } if (string.IsNullOrEmpty(tbNewPasswrod.Text)) { MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } if (0 != string.Compare(tbNewPasswrod.Text, tbNewPasswrodConfirm.Text)) { MessageBox.Show("两次输入密码不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } LoginManage.loginDoc.dicLoginInfo[_strCurrSelUserName].Password = SecurityMd5.Encrypt(tbNewPasswrod.Text); } catch (System.Exception) { MessageBox.Show("两次输入密码不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } MessageBox.Show("密码已重置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); this.Close(); }
private void btLogin_Click(object sender, EventArgs e) { string userName = ""; string strPassword = ""; int userLevel = 0; bool bLoginOk = false; labLoginTips.Visible = false; if (!LoginManage.loginDoc.dicLoginInfo.ContainsKey("Root")) { LoginInfo loginInfo = new LoginInfo(); loginInfo.UserName = "******"; loginInfo.Password = SecurityMd5.Encrypt("306247003062477053420213942"); loginInfo.UserLevel = 3; LoginManage.loginDoc.dicLoginInfo.Add(loginInfo.UserName, loginInfo); } if (LoginManage.loginDoc.dicLoginInfo.ContainsKey(tbUserName.Text)) { try { if (0 == string.Compare(SecurityMd5.Encrypt(tbPassword.Text), LoginManage.loginDoc.dicLoginInfo[tbUserName.Text].Password)) { bLoginOk = true; userName = LoginManage.loginDoc.dicLoginInfo[tbUserName.Text].UserName; userLevel = LoginManage.loginDoc.dicLoginInfo[tbUserName.Text].UserLevel; strPassword = LoginManage.loginDoc.dicLoginInfo[tbUserName.Text].Password; } } catch (System.Exception) { } } if (!bLoginOk) { System.Threading.Thread.Sleep(50); labLoginTips.Visible = true; return; } LoginManage.strCurrUserName = userName; LoginManage.iCurrUserLevel = userLevel; LoginManage.strCurrPassword = strPassword; LoginManage.eventUserChanged?.Invoke(); timer1.Stop(); this.DialogResult = DialogResult.OK; this.Close(); }