Exemplo n.º 1
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            UserProfileTableAdapter userProfileTableAdapter = new UserProfileTableAdapter();
            UserProfile             originalUserProfile     = userProfileTableAdapter.GetUserProfileByID(Convert.ToInt32(Request["UserProfileID"]));

            UserProfile userProfile = new UserProfile();

            if (originalUserProfile.ID != 1)
            {
                if (IsValidData())
                {
                    userProfile.ID           = originalUserProfile.ID;
                    userProfile.Name         = Server.HtmlEncode(txtName.Text.Trim());
                    userProfile.Username     = Server.HtmlEncode(txtUsername.Text.Trim());
                    userProfile.Password     = originalUserProfile.Password;
                    userProfile.DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
                    userProfile.UserRoleID   = Convert.ToInt32(ddlUserRole.SelectedValue);
                    userProfile.Status       = "ACTIVE";
                    if (userProfileTableAdapter.Update(userProfile) > 0)
                    {
                        ltlMessage.Text = "<div class=\"alert alert-success alert-dismissible\"><button type = \"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button> <h4><i class=\"icon fa fa-check\"></i> Alert!</h4> Sucessfully Updated <b>" + txtName.Text.Trim() + "</b>.</div>";
                        Response.Redirect("~/UserProfiles/userprofilelist.aspx");
                    }
                }
            }
            else
            {
                ShowErrorMessage(GetGlobalResourceObject("UserResource", "systemdefaultuser").ToString());
            }
        }
Exemplo n.º 2
0
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            UserProfileTableAdapter userProfileTableAdapter = new UserProfileTableAdapter();
            UserProfile             originalUserProfile     = userProfileTableAdapter.GetUserProfileByUsername(txtUsername.Text.Trim(), "ACTIVE");

            UserProfile userProfile = new UserProfile();

            if (IsValidData())
            {
                userProfile.ID         = originalUserProfile.ID;
                userProfile.Name       = originalUserProfile.Name;
                userProfile.Username   = Server.HtmlEncode(txtUsername.Text.Trim());
                userProfile.Password   = Server.HtmlEncode(txtNewPassword.Text.Trim());
                userProfile.UserRoleID = originalUserProfile.UserRoleID;
                userProfile.Status     = "ACTIVE";

                if (userProfileTableAdapter.Update(userProfile) > 0)
                {
                    ltlMessage.Text = "<div class=\"alert alert-success alert-dismissible\"><button type = \"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button> <h4><i class=\"icon fa fa-check\"></i> Alert!</h4> Sucessfully Change Password.<b>" + originalUserProfile.Username + "</b>.</div>";
                    Response.Redirect("~/signin.aspx");
                }
            }
        }