private void btnNewPassword_Click(object sender, EventArgs e) { if (txtSelectedUser.Text != null) { //Check Condition Password mush have 1 Lowcase 1 Uppercase 1 Number and Length more than 8 if (txtNewPassword.Text != txtUpdateConfirmPW.Text) { lbStripStatus.Text = "Your new password does not match!"; return; } else if (!(txtNewPassword.Text.Any(char.IsLower) && txtNewPassword.Text.Any(char.IsUpper) && txtNewPassword.Text.Any(char.IsDigit) && (txtNewPassword.Text.Length > 8))) { lbStripStatus.Text = "Password must have minimum 1 Uppercase, 1 Lowercase , 1 Number and 8 characters"; return; } AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), cbUserLevel.Text); //Update selected user with new password ONLY IF current logged in user is an admin int rowAffrected = _ws.UpdatePassword(txtNewPassword.Text, (int)userLevel, CurrentUser.UserLevel); if (rowAffrected > 0) { statusStrip.Text = "Password has been updated"; MessageBox.Show("\"" + txtSelectedUser.Text + "\"" + " password has been updated!"); } RefreshUserList(); } }
private void addUserButton_Click(object sender, EventArgs e) { AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelComboBox.Text); int affectedRows = userLogic.AddNewUser(usernameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); RefreshUserList(); }
private void addUserBtn_Click(object sender, EventArgs e) { //TODO for assignment: MAKE SURE PASSWORD VALIDATION IS GOOD AND NO FIELDS ARE LEFT EMPTY //Note: Combobox holds a list of strings, so we convert that string to the actual enum value it reperesents AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelCombo.Text); //we pass all the values to AddNewUser. We can cast enums to ints to get their numeric value userLogic.AddNewUser(usernameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); RefreshUserList(); }
//Add user button private void addUserButton_Click(object sender, EventArgs e) { //get enum back out of datasource of combo box........ AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelComboBox.Text); int affectedRows = userLogic.AddNewUser(userNameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); //if affectedRows > 0, success! RefreshUserList(); }
private void btnAddUser_Click(object sender, EventArgs e) { DataTable userData = _ws.GetListofUsers(); if (txtUserName.Text == "" && txtPassword.Text == "" && txtAddConfirmPW.Text == "" && txtEmail.Text == "") { lbStripStatus.Text = "Missing some information"; MessageBox.Show("Please fill all form"); return; } else if (txtPassword.Text != txtAddConfirmPW.Text) { lbStripStatus.Text = "Your password does not match"; MessageBox.Show("Password dose not match"); return; } else if (!(txtPassword.Text.Any(char.IsLower) && txtPassword.Text.Any(char.IsUpper) && txtPassword.Text.Any(char.IsDigit) && (txtPassword.Text.Length > 8))) { lbStripStatus.Text = "Password must have minimum 1 Uppercase, 1 Lowercase , 1 Number and 8 characters"; MessageBox.Show("Password have condition"); return; } for (int i = 0; i < userData.Rows.Count; i++) { if (userData.Rows[i]["UserName"].ToString() == txtUserName.Text) { lbStripStatus.Text = "User Name has already"; MessageBox.Show("User Name has already!"); return; } } //TODO for assignment: MAKE SURE PASSWORD VALIDATION IS GOOD AND NO FIELDS ARE LEFT EMPTY //NOTE: Combobox holds a list of strings, so we convert that string to the actural enum value it repersents AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), cbUserLevel.Text); //We pass all the Values to AddNewUser. We can cafst enums to ints to get their numeric value //userLogic.AddNewUser(txtUserName.Text, txtPassword.Text, cbUserLevel.SelectedIndex + 1, txtEmail.Text); _ws.InsertNewUser(txtUserName.Text, txtPassword.Text, (int)userLevel, txtEmail.Text); RefreshUserList(); }