private void Add(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TbLogin.Text)) { MB.MessageBoxInfo("Введите логин"); TbLogin.Focus(); } else if (string.IsNullOrWhiteSpace(TbPassword.Text)) { MB.MessageBoxInfo("Введите пароль"); TbPassword.Focus(); } else if (string.IsNullOrWhiteSpace(CbRole.Text)) { MB.MessageBoxInfo("Выберите роль"); CbRole.Focus(); } else { try { DataService.GetContext().User.Add(user); DataService.GetContext().SaveChanges(); MB.MessageBoxInfo("Пользователь успешно добавлен"); } catch { MB.MessageBoxError("Ошибка подключения к базе данных"); } } }
private void Tbusername_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TbPassword.Focus(); } }
private void FLogin_Activated(object sender, EventArgs e) { if (Properties.Settings.Default.loginsaveusername) { TbPassword.Focus(); TbPassword.ForeColor = Color.Black; TbPassword.Text = string.Empty; TbPassword.PasswordChar = '*'; } else { TbUsername.Focus(); } }
private void CtlActionsPane_Load(object sender, EventArgs e) { SqlUserName = Properties.Settings.Default.SqlUserName; SqlServerName = Properties.Settings.Default.SqlServerName; DatabaseName = Properties.Settings.Default.DatabaseName; CommandTimeout = Properties.Settings.Default.CommandTimeout; Authentication = (AuthenticationMode)Properties.Settings.Default.AuthenticationMode; IncludeActivePeriods = Properties.Settings.Default.IncludeActivePeriods; IncludeOrderBook = Properties.Settings.Default.IncludeOrderBook; IncludeBankTypes = Properties.Settings.Default.IncludeBankTypes; IncludeBankBalances = Properties.Settings.Default.IncludeBankBalances; IncludeVatDetails = Properties.Settings.Default.IncludeVatDetails; IncludeTaxAccruals = Properties.Settings.Default.IncludeTaxAccruals; IncludeBalanceSheet = Properties.Settings.Default.IncludeBalanceSheet; Greyscale = Properties.Settings.Default.Greyscale; if (Authentication == AuthenticationMode.SqlServer) { tabCtl.SelectedTab = pgConnection; TbPassword.Focus(); } }
private void BtSignIn_Click(object sender, EventArgs e) { if (PnConfirmPassword.Visible) { // мы находимся в "регистрация" PnConfirmPassword.Visible = false; return; } PnConfirmPassword.Visible = false; var username = TbUserName.Text.Trim(); var password = TbPassword.Text.Trim(); if (UserNamePassWordCheckIsEmpty()) { return; } // а теперь мы ищем имя пользователя в каком-то списке. В файле, наверное. if (Users.Contains(username, password)) { UserNameIfSuccess = username; //MessageBox.Show(@"Contains. Really."); Close(); } else { if (!Users.Contains(username)) { MessageBox.Show(@"Неверное имя пользователя", @"Ошибка"); TbUserName.Focus(); return; } MessageBox.Show(@"Неверный пароль."); TbPassword.Focus(); TbPassword.Clear(); } }