/// <summary> /// 登陆界面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, RoutedEventArgs e) { if (failueLoginCount >= errorCountLimit) { var str = string.Format("密码错误大于{0}次,禁止登陆", errorCountLimit); MessageBox.Show(str, "登陆警告"); logger.AddMessage("登陆警告", str, Log.LogType.Login); return; } if (accountManager.LoginCheck(txtLoginUser.Text, passBox.SecurePassword)) { var str = string.Format("登陆尝试{0}后登陆成功", failueLoginCount); logger.AddMessage(accountManager.LoginAccount.UserName, str, Log.LogType.Login); logger.SaveLog(); var main = new MainWindow(accountManager, logger); main.Show(); this.Close(); } else { if (++failueLoginCount >= errorCountLimit) { var str = string.Format("密码错误大于{0}次,禁止登陆", errorCountLimit); MessageBox.Show(str, "登陆警告"); logger.AddMessage("登陆警告", str, Log.LogType.Login); } else { var str = string.Format("密码错误,还剩下{0}次机会", errorCountLimit - failueLoginCount); MessageBox.Show(str, "登陆警告"); logger.AddMessage("登陆警告", str, Log.LogType.Login); } } }