private void LoginButton_Click(object sender, RoutedEventArgs e) { using (var context = new ExpansesManagerContext()) { if (context.Users.Any(u => u.Username == UsernameTextBox.Text && u.Password == PasswordBox.Password)) { MessageBox.Show("Successfully logged in!"); } else { ErrorLabel.Content = ("Username or password is invalid."); return; } AuthenticationManager.Login(UsernameTextBox.Text, PasswordBox.Password); UsernameTextBox.Clear(); PasswordBox.Clear(); } MainApp mainApp = new MainApp(); this.Close(); mainApp.ShowDialog(); }
private void SaveUser() { if (isEditing) { var currentUser = userBindingSource.Current as User; if (currentUser != null) { currentUser.Username = UsernameTextBox.Text; currentUser.Password = encryptor.GetEncrypted(PasswordTextBox.Text); currentUser.Role = (Role)RoleComboBox.SelectedItem; } } else { var user = new User { Username = UsernameTextBox.Text, Password = encryptor.GetEncrypted(PasswordTextBox.Text), Role = (Role)RoleComboBox.SelectedItem }; context.Users.Add(user); } context.SaveChanges(); EditUser(false); UsernameTextBox.Clear(); PasswordTextBox.Clear(); }
private void OK_Click(System.Object sender, System.EventArgs e) { if (UsernameTextBox.Text == "" | PasswordTextBox.Text == "") { MessageBox.Show("Enter your Username and password!", "Fields Empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } sql.addprams("@name", UsernameTextBox.Text); sql.addprams("@pass", PasswordTextBox.Text); sql.ExecSql("Select * from users where username = @name and pass = @pass"); if (sql.count == 0) { MessageBox.Show("Invalid Username or Password", "Wrong info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); return; } else { this.Hide(); MainInterface mainInterface = new MainInterface(); mainInterface.FormClosed += (s, args) => this.Close(); mainInterface.Show(); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { bool isPasswordDiff = OldPasswordBox.Password != PasswordBox.Password && OldPasswordBox.Password != RepeatPasswordBox.Password; bool isOldPassCorrect = _user.Password == OldPasswordBox.Password; bool isPasswordSame = PasswordBox.Password == RepeatPasswordBox.Password; if (isOldPassCorrect && isPasswordDiff && isPasswordSame) { using (var context = new ExpansesManagerContext()) { _user.Password = PasswordBox.Password; context.Users.AddOrUpdate(_user); context.SaveChanges(); } UsernameTextBox.Clear(); PasswordBox.Clear(); RepeatPasswordBox.Clear(); OldPasswordBox.Clear(); ErrorLabel.Content = "Successfully Changed Password !"; } else { ErrorLabel.Content = Checks.PasswordsDoNotMatch; } }
private void UsernameTextBox_Enter(object sender, EventArgs e) { UsernameTextBox.ForeColor = Color.FromArgb(78, 184, 206); UsernamePictureBox.Image = Properties.Resources.user_icon_colored; UsernameFieldPanel.BackColor = Color.FromArgb(78, 184, 206); LoginStatusLabel.Text = ""; if (UsernameTextBox.Text == "Логин") { UsernameTextBox.Clear(); } }
private bool CheckPassword(IS2G10_DBSSSDataSet.USERPROFILERow userProfile, string sPass) { var check = _passwordBuilder.CheckPassword(sPass, userProfile.password_hash, userProfile.password_salt); //check if password is right if (!check) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); PasswordTextBox.Clear(); UsernameTextBox.Clear(); UsernameTextBox.Focus(); } return(check); }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { if (Checks.UsernameIsTaken(UsernameTextBox.Text)) { ErrorLabel.Content = Checks.UsernameIsAlreadyTaken; return; } if (PasswordBox.Password != RepeatPasswordBox.Password) { ErrorLabel.Content = Checks.PasswordsDoNotMatch; return; } if (!Checks.PasswordIsValid(PasswordBox.Password)) { ErrorLabel.Content = Checks.PasswordIsInvalid; return; } if (Checks.EmailIsValid(EmailtextBox.Text)) { ErrorLabel.Content = Checks.EmailIsNotValid; return; } using (var context = new ExpansesManagerContext()) { User user = new User() { Username = UsernameTextBox.Text, Password = PasswordBox.Password, Email = EmailtextBox.Text, DateRegistered = DateTime.UtcNow, }; context.Users.Add(user); context.SaveChanges(); } UsernameTextBox.Clear(); PasswordBox.Clear(); RepeatPasswordBox.Clear(); EmailtextBox.Clear(); ErrorLabel.Content = "Successfully registered!"; }
private void LoginButton_Click(object sender, EventArgs e) { if (!LoginValidation()) { return; } Controller.UserAccount userAccount = new Controller.UserAccount(); if (userAccount.UserLoginAuthentication(UsernameTextBox.Text, PasswordTextBox.Text)) { UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); HomeForm homeForm = new HomeForm(userAccount); this.Hide(); homeForm.ShowDialog(); } }
private bool IsFormValid() { if (UsernameTextBox.Text.Trim() == String.Empty) { Messages.ShowErrorMessage("Username is required"); UsernameTextBox.Clear(); UsernameTextBox.Focus(); return(false); } if (PasswordTextBox.Text.Trim() == String.Empty) { Messages.ShowErrorMessage("Password is required"); PasswordTextBox.Clear(); PasswordTextBox.Focus(); return(false); } return(true); }
private void EditButton_Click(object sender, EventArgs e) { if (!UserIdTextBox.Text.Trim().Equals(string.Empty) && !UsernameTextBox.Text.Trim().Equals(string.Empty) && !PasswordTextBox.Text.Trim().Equals(string.Empty) && !AttributComboBox.Text.Trim().Equals(string.Empty)) { int id = Convert.ToInt32(UserIdTextBox.Text); string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; string attribut = AttributComboBox.Text; databaseManager.EditUser(id, username, password, attribut); UserIdTextBox.Clear(); UsernameTextBox.Clear(); PasswordTextBox.Clear(); } else { MessageBox.Show("Please fill all the fields"); } }
private void SaveButton_Click(object sender, EventArgs e) { if (!UsernameTextBox.Text.Trim().Equals(string.Empty) && !PasswordTextBox.Text.Trim().Equals(string.Empty) && !AttributComboBox.Text.Trim().Equals(string.Empty)) { string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; string attribut = AttributComboBox.Text; databaseManager.AddUser(username, password, attribut); UsernameTextBox.Clear(); PasswordTextBox.Clear(); AdminUI adminUI = new AdminUI(); this.Close(); adminUI.Show(); } else { MessageBox.Show("Please fill all the fields!"); } }
public void OK_Click(System.Object sender, System.EventArgs e) { if (UsernameTextBox.Text.Trim() == "" || PasswordTextBox.Text.Trim() == "") { Interaction.MsgBox("Por favor, llene ambos campos!", Constants.vbInformation, "Nota"); } else { Modulo1.con.Open(); var sql = "SELECT * FROM tblUser WHERE username = \'" + Modulo1.SafeSqlLiteral(UsernameTextBox.Text, 2) + "\' AND password = \'" + Modulo1.SafeSqlLiteral(PasswordTextBox.Text, 2) + "\'"; var cmd = new OleDbCommand(sql, Modulo1.con); OleDbDataReader dr = cmd.ExecuteReader(); try { if (dr.Read() == false) { Interaction.MsgBox("Inicio de sesión fallida ¬¬", Constants.vbCritical, "Nota"); } else { Interaction.MsgBox("¡Bienvenido! ツ", Constants.vbInformation, "Nota"); frmMain.Default.status.Items[0].Text = "Logueado como : " + UsernameTextBox.Text.Trim(); DateTime datenow = DateTime.Now; frmMain.Default.status.Items[2].Text = "Fecha y Hora : " + datenow.ToString("MMMM dd, yyyy") + " " + DateAndTime.TimeOfDay; Modulo1.con.Close(); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); this.Hide(); frmMain.Default.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } Modulo1.con.Close(); } }
private void button1_Click(object sender, EventArgs e) { string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; if (username == loginClass.getusername()) { if (password == loginClass.getpassword()) { date_time = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); writer = file.AppendText(); writer.WriteLine("Logged in at " + date_time); writer.Close(); MessageBox.Show("Logged in Successfully"); this.Hide(); DashboardForm dashboardForm = new DashboardForm(); dashboardForm.Show(); } else { date_time = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); writer = file.AppendText(); writer.WriteLine("Invalid Password Attempt is made on " + date_time); writer.Close(); MessageBox.Show("Invalid Password"); PasswordTextBox.Clear(); } } else { date_time = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); writer = file.AppendText(); writer.WriteLine("Invalid Username Attempt is made on " + date_time); writer.Close(); MessageBox.Show("Invalid username"); UsernameTextBox.Clear(); } }
private void AddAndAddAnotherButton_Click(object sender, EventArgs e) { try { XMLHelper helper = new XMLHelper(); MailServer NewServer = new MailServer() { ID = helper.LastElementUniqueID(XMLDataStorage.Location + "MailServers.xml", "Server") + 1, Name = NameTextBox.Text, Description = DescriptionTextBox.Text, Host = HostTextBox.Text, Port = Convert.ToInt32(PortTextBox.Text), Username = UsernameTextBox.Text, Password = PasswordTextBox.Text, FromAddress = FromAddressTextBox.Text, IsSecured = IsSecuredCheckbox.Checked }; mailServerManager.Add(NewServer); MessageBox.Show("Mail Server is successfully added"); NameTextBox.Clear(); DescriptionTextBox.Clear(); HostTextBox.Clear(); PortTextBox.Clear(); UsernameTextBox.Clear(); PasswordTextBox.Clear(); FromAddressTextBox.Clear(); IsSecuredCheckbox.Checked = false; } catch (Exception ex) { MessageBox.Show("Failed to add new mail server", ex.Message); } }
private void SignInButton_Click(object sender, EventArgs e) { DateTime dateTimeNow = DateTime.Now; string strMaxFormat = dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss tt");//24 hours format hh gets 12 format try { if (UsernameTextBox.Text == DbUserName && PasswordTextBox.Text == DbPassword) { try { //logs the login information //saves for me at: C:\Users\joshu\Google Drive\Visual Studio Projects\C969 Scheduling Software Project_05312019\C969 Scheduling Software Project\bin\Debug\C969SchedulingSoftwareProjectLogin.txt FileStream outp = new FileStream(fileName, FileMode.Append, FileAccess.Write); fileWriter = new StreamWriter(outp); fileWriter.WriteLine("Time of login: "******". Current Logged in user: "******". Login was a success!"); fileWriter.Close(); } catch (Exception) { MessageBox.Show("Cannot write to local file"); } //checks for an appointment within 15 minutes of login MySqlConnection con1 = new MySqlConnection(ConfigurationManager.ConnectionStrings["U04i5a"].ConnectionString); MySqlCommand cmd1 = new MySqlCommand("SELECT * from appointment;", con1); con1.Open(); MySqlDataAdapter adapter1 = new MySqlDataAdapter(cmd1); DataTable dt = new DataTable(); adapter1.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { //changes the database time and date to local time DateTime dbApptStart = (DateTime)dt.Rows[i]["start"]; dbApptStart = dbApptStart.ToLocalTime(); TimeSpan span = dbApptStart.Subtract(dateTimeNow); Console.WriteLine("Time Difference (minutes): " + span.TotalMinutes); if (span.TotalMinutes < 15 && span.TotalMinutes > 0) { MessageBox.Show("You have an appointment within 15 minutes."); break; } } MainScreenForm MyMainScreenForm = new MainScreenForm(); this.Hide(); MyMainScreenForm.Show(); } else { try { //logs the login information //saves for me at: C:\Users\joshu\Google Drive\Visual Studio Projects\C969 Scheduling Software Project_05312019\C969 Scheduling Software Project\bin\Debug\C969SchedulingSoftwareProjectLogin.txt FileStream outp = new FileStream(fileName, FileMode.Append, FileAccess.Write); fileWriter = new StreamWriter(outp); fileWriter.WriteLine("Time of login: "******". Current Logged in user: "******". Login was not a success!"); fileWriter.Close(); } catch (Exception) { MessageBox.Show("Cannot write to local file"); } //login error information to the user MessageBox.Show(ErrorMessage, FormType, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); UsernameTextBox.Clear(); PasswordTextBox.Clear(); return; } } catch (Exception) { throw; } }
private void AddNew() { UsernameTextBox.Clear(); PasswordTextBox.Clear(); EditUser(true); }
//comment public void InputUsername(string username) { UsernameTextBox.Clear(); UsernameTextBox.SendKeys(username); }
private void LoginButton_Click(object sender, RoutedEventArgs e) { var sInput = UsernameTextBox.Text; var sPassword = PasswordTextBox.Password; if (sInput == null || sInput.Equals("")) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); } else { if (sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator"))) { MetroWindow adminShow = new Administrator.Administrator(); adminShow.Owner = this; adminShow.Show(); this.Hide(); } else if (!SSS_Library.DataServices.StringHandler.CheckIfStringANumber(sInput) || !sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator"))) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); PasswordTextBox.Clear(); UsernameTextBox.Clear(); UsernameTextBox.Focus(); } else { _userId = Convert.ToInt32(sInput); var userProfile = _userProfileTableAdapter.GetData().FindByuser_id(_userId); if (userProfile == null) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); } else { if (userProfile.resetPassword) { CreatePassword(userProfile); } else { var doILogin = CheckPassword(userProfile, sPassword); if (doILogin) { //coordinator role = 2 if (userProfile.user_roles_id == 2) { MetroWindow coordinatorShow = new Coordinator(_userId); coordinatorShow.Owner = this; coordinatorShow.Show(); this.Hide(); } //student role = 4 else if (userProfile.user_roles_id == 4) { MetroWindow studentShow = new Student(_userId); studentShow.Owner = this; studentShow.Show(); this.Hide(); } //tutor role = 3 else if (userProfile.user_roles_id == 3) { MetroWindow tutorShow = new Tutor(_userId); tutorShow.Owner = this; tutorShow.Show(); this.Hide(); } } } } } } }
private void UsernameTextBox_Click(object sender, EventArgs e) { UsernameTextBox.Clear(); }
private void SaveButton_Click(object sender, EventArgs e) { if (!UsernameTextBox.Text.Trim().Equals(string.Empty) && !OldPasswordTextBox.Text.Trim().Equals(string.Empty) && !NewPasswordTextBox.Text.Trim().Equals(string.Empty) && !RepeatPasswordTextBox.Text.Trim().Equals(string.Empty)) { userData = XmlDataManager.XmlUserDataReader("userdata.xml"); string unchangeUsername = userData.Username; // old Username string UserAttribut = userData.UserAttribut; userData1 = XmlDataManager.XmlUserDataReader("XMLSystemAdmin.xml"); string UserAttribut1 = userData1.UserAttribut; if (!(UserAttribut.Equals("SuperAdmin"))) { // return the UserId from the database int UserId = databaseManager.ReturnUserID(unchangeUsername, OldPasswordTextBox.Text); string newUsername = UsernameTextBox.Text; // new Username string oldPassword = OldPasswordTextBox.Text; // old Password string newPassword = NewPasswordTextBox.Text; // new Password string repeatPassword = RepeatPasswordTextBox.Text; // new Password //Edit the UserData as simple user. databaseManager.EditAccountUser(UserId, newUsername, oldPassword, newPassword, repeatPassword); UsernameTextBox.Clear(); OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); RepeatPasswordTextBox.Clear(); AdminUI adminUI = new AdminUI(Online_User); this.Close(); adminUI.Show(); } else { string AdminPassword = userData1.Password; if ((OldPasswordTextBox.Text).Equals(AdminPassword)) { if (File.Exists("XMLSystemAdmin.xml")) { userData.Username = UsernameTextBox.Text.Trim(); userData.Password = NewPasswordTextBox.Text.Trim(); userData.UserAttribut = UserAttribut; XmlDataManager.XmlDataWriter(userData, "XMLSystemAdmin.xml"); MessageBox.Show("SuperAdmin Data changed successful"); AdminUI adminUI = new AdminUI(Online_User); this.Close(); adminUI.Show(); } else { MessageBox.Show("XMLSystemAdmin.xml File not found!"); } } else { MessageBox.Show("Wrong Password. Please give a correct password!"); } } } else { MessageBox.Show("Fill all Fields"); } }
private void AddUserButton_Click(object sender, EventArgs e) { AddUserButton.Enabled = false; UsernameTextBox.Enabled = false; PasswordTextBox.Enabled = false; YesNoToggleSwitch.Enabled = false; ControlBox = false; AddUserButton.Text = _configuration.Localization.PleaseWait; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { User user = new User { Username = UsernameTextBox.Text }; if (!YesNoToggleSwitch.Value) { user.Type = "offline"; if (_userManager.Accounts.ContainsKey(user.Username)) { _userManager.Accounts[user.Username] = user; } else { _userManager.Accounts.Add(user.Username, user); } _userManager.SelectedUsername = user.Username; SaveUsers(); UpdateUsers(); return; } AuthManager auth = new AuthManager { Email = UsernameTextBox.Text, Password = PasswordTextBox.Text }; try { auth.Login(); user.Type = auth.IsLegacy ? "legacy" : "mojang"; user.AccessToken = auth.AccessToken; user.ClientToken = auth.ClientToken; user.Uuid = auth.Uuid; user.UserProperties = auth.UserProperties; if (_userManager.Accounts.ContainsKey(user.Username)) { _userManager.Accounts[user.Username] = user; } else { _userManager.Accounts.Add(user.Username, user); } _userManager.SelectedUsername = user.Username; } catch (WebException ex) { if (ex.Status != WebExceptionStatus.ProtocolError) { return; } RadMessageBox.Show(_configuration.Localization.IncorrectLoginOrPassword, _configuration.Localization.Error, MessageBoxButtons.OK, RadMessageIcon.Error); return; } Invoke(new Action(() => { SaveUsers(); UpdateUsers(); UsernameTextBox.Clear(); PasswordTextBox.Clear(); })); }; bgw.RunWorkerCompleted += delegate { UsernameTextBox.Enabled = true; YesNoToggleSwitch.Enabled = true; ControlBox = true; AddUserButton.Text = _configuration.Localization.AddNewUserButton; YesNoToggleSwitch_ValueChanged(this, EventArgs.Empty); }; bgw.RunWorkerAsync(); }
private void Login1_Activated(object sender, EventArgs e) { PasswordTextBox.Clear(); UsernameTextBox.Clear(); UsernameTextBox.Focus(); }