Ejemplo n.º 1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            UserLogic logic     = new UserLogic();
            bool      isUpdated = false;

            if (string.IsNullOrEmpty(tbxEmail.Text) || string.IsNullOrEmpty(tbxFirstname.Text) ||
                string.IsNullOrEmpty(tbxLastname.Text) || string.IsNullOrEmpty(tbxAddress.Text) ||
                string.IsNullOrEmpty(tbxZipcode.Text) || string.IsNullOrEmpty(tbxPlace.Text))
            {
                lblMessage.Text = "Je mag de persoonsgegevens niet leeglaten.";
                isUpdated       = false;
            }
            else
            {
                if (tbxEmail.Text.IndexOf("@") == -1 || tbxEmail.Text.IndexOf(".") == -1)
                {
                    lblMessage.Text = "E-mailadres is ongeldig";
                    isUpdated       = false;
                }
                else
                {
                    if (string.IsNullOrEmpty(tbxPassword.Text) && string.IsNullOrEmpty(tbxRepeat.Text))
                    {
                        User u = new User(tbxEmail.Text);
                        u.SetUserID = id;
                        u.Firstname = tbxFirstname.Text;
                        u.Lastname  = tbxLastname.Text;
                        u.Address   = tbxAddress.Text;
                        u.Zipcode   = tbxZipcode.Text;
                        u.Place     = tbxPlace.Text;
                        logic.AddRoleToUser(u, CB_Roles.SelectedItem.ToString());
                        isUpdated = logic.UpdateUserWithNoPass(u);
                    }
                    else
                    {
                        User u = new User(tbxEmail.Text, tbxPassword.Text);
                        u.SetUserID = id;
                        u.Firstname = tbxFirstname.Text;
                        u.Lastname  = tbxLastname.Text;
                        u.Address   = tbxAddress.Text;
                        u.Zipcode   = tbxZipcode.Text;
                        u.Place     = tbxPlace.Text;
                        logic.AddRoleToUser(u, CB_Roles.SelectedItem.ToString());
                        isUpdated = logic.UpdateUserWithPass(u);
                    }
                }
            }

            if (isUpdated == true)
            {
                MessageBox.Show("Gegevens upgedate.");
                UserOverview overview = new UserOverview(userEmail);
                this.Hide();
                overview.Show();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a role to a user
        /// </summary>

        public void AddRoleToUser(User U)
        {
            if (CB_Roles.SelectedIndex > -1)
            {
                UserLogic Logic = new UserLogic();
                if (Logic.AddRoleToUser(U, CB_Roles.SelectedItem.ToString()) == true)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("Failed to add the role to the user");
                }
            }
        }