private void BtnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormLoggedUser.Role.UserRoleId == 2)
                {
                    MessageBox.Show("You don't have permision to create users", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    usr.Name     = txtNameCreate.Text;
                    usr.LastName = txtLastNameCreate.Text;
                    usr.Email    = txtEmailCreate.Text;
                    usr.Username = txtUsernameCreate.Text;
                    usr.InsBy    = FormLoggedUser.Id;
                    usr.Password = Sec.Hash(usr.Username, txtPasswordCreate.Text);
                    usr._role    = getRoleCreate();
                    usr.RoleID   = usr._role.UserRoleId;


                    UsersValidation  usrval = new UsersValidation();
                    ValidationResult vres   = usrval.Validate(usr);

                    if (vres.IsValid == false)
                    {
                        foreach (ValidationFailure item in vres.Errors)
                        {
                            errors += $"{item.ErrorMessage} + \n";
                        }
                        MessageBox.Show(errors);
                    }

                    int error = usrbll.Add(usr);

                    if (error == 0)
                    {
                        this.Close();
                    }

                    else if (error == 1)
                    {
                        MessageBox.Show("This username alreay exists, please if this user is deactivated you can update it");
                    }
                    else if (error == -1)
                    {
                        throw new Exception();
                    }
                }
            }

            catch (FormatException)
            {
                MessageBox.Show("User is not valid");
            }

            catch (Exception)
            {
                MessageBox.Show("User is not inserted please contact your administrator");
            }
        }
        private void BtnUpdateAccount_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormLoggedUser.Role.UserRoleId == 2)
                {
                    MessageBox.Show("You don't have permision to update users", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    usr = new User();

                    usr.Name     = txtNameEdit.Text;
                    usr.LastName = txtLastNameEdit.Text;
                    usr.Email    = txtEmailEdit.Text;
                    usr.Username = txtUsernameEdit.Text;

                    if ("Yes" == txtIsActiveEdit.Text || "yes" == txtIsActiveEdit.Text)
                    {
                        usr.IsActive = true;
                    }
                    else if (txtIsActiveEdit.Text.ToLower() == "no")
                    {
                        usr.IsActive = false;
                    }
                    else
                    {
                        MessageBox.Show("IsActive field is not valid please answer with 'yes' or 'no'", "USER UPDATED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        throw new Exception();
                    }



                    usr.InsBy  = FormLoggedUser.Id;
                    usr._role  = getRoleUpdate();
                    usr.RoleID = usr._role.UserRoleId;


                    usrval.validateUpdateUser();
                    ValidationResult vres = usrval.Validate(usr);



                    if (vres.IsValid == false)
                    {
                        errors = "";
                        foreach (ValidationFailure item in vres.Errors)
                        {
                            errors += $"       {item.ErrorMessage}        \n \n";
                        }

                        MessageBox.Show(errors, "ERROR WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    else
                    {
                        usrbll = new UserBLL();
                        if (usrbll.Update(usr) == 0)
                        {
                            MessageBox.Show("User updated succesfuly", "USER UPDATED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }



            catch (Exception)
            {
            }
        }