public void LoginCommand() { bool flagToLogin = true; bool IsDone = true; flag = true; ErrorMes = ""; if (PasswordSecond == String.Empty || PasswordSecond == null) { flagToLogin = false; ErrorMes = Properties.Resources.emptyfield; } if (flagToLogin && canreg) { SqlConnect spam = new SqlConnect(); string Pass = firstHash(PasswordSecond).ToString(); IsDone = spam.GiveUsersRecords(PhoneNumberLog, Pass); if (IsDone) { Properties.Settings.Default.User = PhoneNumberLog; Properties.Settings.Default.UserId = spam.GetIdUserByName(PhoneNumberLog); Properties.Settings.Default.Save(); MainWindow sp = new MainWindow(); sp.Show(); CloseAction2(); } } if (!IsDone) { ErrorMes = Properties.Resources.nosuchuser; } flag = false; canreg = true; }
public void LoginCommand() { bool fl = true; bool IsDone = true; ErrorMes = ""; flag = true; Login += " "; int x1 = Login.Length - 1; Login = Login.Substring(0, x1); if (PasswordFieldText == String.Empty || PasswordFieldText == null) { fl = false; ErrorMes = Properties.Resources.emptyfield; } if (fl && canreg) { SqlConnect spam = new SqlConnect(); string Pass = firstHash(PasswordFieldText).ToString(); IsDone = spam.GiveUsersRecords(Login, Pass); if (IsDone) { Properties.Settings.Default.Language = "en"; LocalizeDictionary.Instance.SetCurrentThreadCulture = true; LocalizeDictionary.Instance.Culture = new CultureInfo("en"); Properties.Settings.Default.User = Login; Properties.Settings.Default.UserId = spam.GetIdUserByName(Login); Properties.Settings.Default.Save(); MainWindow sp = new MainWindow(); sp.WindowStartupLocation = WindowStartupLocation.CenterScreen; sp.Show(); CloseAction2(); } } if (!IsDone) { ErrorMes = Properties.Resources.nosuchuser; } flag = false; canreg = true; }
public void RegisterCommand() { ErrorMes = ""; //разрешаем валидацию flag = true; Login += " "; int x1 = Login.Length - 1; Login = Login.Substring(0, x1); bool fl = true; //проверка на равенство паролей if (PasswordFirst != PasswordSecond) { fl = false; ErrorMes = Properties.Resources.eaqfield; } // проверка на длинну if (PasswordFirst != null) { if (PasswordFirst.Length < 8) { fl = false; ErrorMes = Properties.Resources.charac; } } //проверяем на пустую строку if (PasswordFirst == String.Empty || PasswordSecond == String.Empty || PasswordFirst == null || PasswordSecond == null) { fl = false; ErrorMes = Properties.Resources.emptyfield; } //флаг проверяющий записались ли данный в бд bool IsDone = true; if (fl && canreg) { SqlConnect spam = new SqlConnect(); string Pass = firstHash(PasswordFirst).ToString(); IsDone = spam.InsertUsersRecords(Login, Pass); if (IsDone) { //записываю пустые поля в финансовую информацию SqlConnect sqlConnect = new SqlConnect(); int id = Convert.ToInt32(sqlConnect.GetIdUserByName(Login)); SqlConnectUserInfo connectUserInfo = new SqlConnectUserInfo(); connectUserInfo.InsertEmptyFields(id); ViewLogin t = new ViewLogin(); t.WindowStartupLocation = WindowStartupLocation.CenterScreen; t.Show(); CloseAction(); } } //если данные не записались ошибка if (!IsDone) { ErrorMes = Properties.Resources.existserr; } canreg = true; //запрещаем валидацию flag = false; }