Beispiel #1
0
        /// <summary>
        /// Cancel to add a new user and return to the UserOverviewForm
        /// </summary>

        private void btnCancel_Click(object sender, EventArgs e)
        {
            UserOverview overview = new UserOverview(userEmail);

            overview.Show();
            this.Hide();
        }
Beispiel #2
0
        private void btn_users_Click(object sender, EventArgs e)
        {
            UserLogic            userLogic      = new UserLogic();
            RoleLogic            roleLogic      = new RoleLogic();
            SingleUser           singleUser     = new SingleUser();
            PermissionRepository PermissionRepo = new PermissionRepository(new PermissionContext());

            var AllRoles       = roleLogic.RetrieveAllRoles();
            int pagePermission = 20;

            User user;

            user = new User(email);
            userLogic.GetSingleUser(user);

            bool hasPagePermission = PermissionRepo.CheckPermissionsFromRole(user.RetrieveRoleID(), pagePermission);

            if (hasPagePermission == true)
            {
                this.Hide();
                var users = new UserOverview(email);
                users.Closed += (s, args) => this.Close();
                users.Show();
            }

            else
            {
                MessageBox.Show("U heeft hier de rechten niet voor!");
            }
        }
Beispiel #3
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();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Add a new user to the database
        /// </summary>

        private void btnAdd_Click(object sender, EventArgs e)
        {
            UserLogic      Logic = new UserLogic();
            UserRepository repo  = new UserRepository(new UserContext());

            if (string.IsNullOrEmpty(tbxEmail.Text) || string.IsNullOrEmpty(tbxPassword.Text) || string.IsNullOrEmpty(tbxRepeat.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 geen velden leeg laten!";
            }
            else
            {
                if (tbxEmail.Text.IndexOf("@") == -1 || tbxEmail.Text.IndexOf(".") == -1)
                {
                    lblMessage.Text = "E-mailadres is ongeldig";
                }
                else
                {
                    if (tbxPassword.Text == tbxRepeat.Text)
                    {
                        string password = repo.ComputeHash(tbxPassword.Text, null);
                        User   u        = new User(tbxEmail.Text, password);
                        u.Firstname = tbxFirstname.Text;
                        u.Lastname  = tbxLastname.Text;
                        u.Address   = tbxAddress.Text;
                        u.Zipcode   = tbxZipcode.Text;
                        u.Place     = tbxPlace.Text;

                        Logic.AddUserToSystem(u);
                        AddRoleToUser(u);

                        UserOverview overview = new UserOverview(userEmail);
                        overview.Show();
                        this.Hide();
                    }
                    else
                    {
                        lblMessage.Text = "Wachtwoorden zijn niet gelijk aan elkaar.";
                    }
                }
            }
        }