protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                UserProfileTableAdapter userProfileTableAdapter = new UserProfileTableAdapter();
                UserProfile             userProfile             = userProfileTableAdapter.GetUserProfileByUsername(txtEmail.Text.Trim(), "ACTIVE");

                UserRoleTableAdapter userRoleTableAdapter = new UserRoleTableAdapter();
                UserRole             userRole             = userRoleTableAdapter.GetUserRoleByID(userProfile.ID);


                if (userProfile.UserRoleID == 1)
                {
                    Session["Login"]    = userProfile.ID;
                    Session["Name"]     = userProfile.Name;
                    Session["Role"]     = userProfile.UserRoleID;
                    Session["RoleName"] = userRole.RoleName;

                    Response.Redirect("~/passwordresetcode.aspx");
                }
                else
                {
                    ShowErrorMessage(GetGlobalResourceObject("UserResource", "pleasecontactadmin").ToString());
                }
            }
        }
Exemplo n.º 2
0
        private void SignIn()
        {
            UserProfileTableAdapter userProfileTableAdapter = new UserProfileTableAdapter();
            UserProfile userProfile = userProfileTableAdapter.GetUserProfileByUsername(txtEmail.Text.Trim(), "ACTIVE");

            UserRoleTableAdapter userRoleTableAdapter = new UserRoleTableAdapter();
            UserRole userRole = userRoleTableAdapter.GetUserRoleByID(userProfile.ID);

            if (IsValidData())
            {
                if (userProfile.Username == txtEmail.Text.Trim())
                {
                    if (userProfile.Password == txtPassword.Text.Trim())
                    {
                        if (chbRememberMe.Checked)
                        {
                            Session["Login"] = userProfile.ID;
                            Session["Name"] = userProfile.Name;
                            Session["Role"] = userProfile.UserRoleID;
                            Session["RoleName"] = userRole.RoleName;

                            Response.Cookies["Username"].Value = txtEmail.Text.Trim();
                            Response.Cookies["Password"].Value = txtPassword.Text.Trim();
                            Response.Cookies["Username"].Expires = DateTime.Now.AddDays(1);
                            Response.Cookies["Password"].Expires = DateTime.Now.AddDays(1);
                            Response.Redirect("~/default.aspx");
                        }
                        else
                        {
                            Session["Login"] = userProfile.ID;
                            Session["Name"] = userProfile.Name;
                            Session["Role"] = userProfile.UserRoleID;
                            Session["RoleName"] = userRole.RoleName;

                            Response.Cookies["Username"].Expires = DateTime.Now.AddDays(-1);
                            Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);

                            if(userProfile.DepartmentID == 5 && userProfile.UserRoleID == 7)
                            {
                                Response.Redirect("~/Invoices/newinvoice.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/default.aspx");
                            }
                        }
                    }
                    else
                    {
                        ShowErrorMessage(GetGlobalResourceObject("UserResource", "wrongpassword").ToString());
                    }
                }
                else
                {
                    ShowErrorMessage(GetGlobalResourceObject("UserResource", "wrongusername").ToString());
                }

            }
        }
Exemplo n.º 3
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");
                }
            }
        }