Example #1
0
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid)
                {
                    MercadoUDi_DataSetTableAdapters.UserTableAdapter tau =
                        new MercadoUDi_DataSetTableAdapters.UserTableAdapter();

                    string password = "";

                    if (Session["Username"].ToString() != txt_Username.Text)
                    {
                        if (Session["User_PasswordRegister"].ToString() != txt_Password.Text)
                        {
                            password = Encrypt(txt_Password.Text);
                        }
                        else
                        {
                            password = Session["User_PasswordRegister"].ToString();
                        }

                        Session["uName"]   = txt_Username.Text;
                        Session["uEmail"]  = txt_Email.Text;
                        Session["uStatus"] = DropDownList_Status.SelectedItem.Text;

                        if (DropDownList_UserType.SelectedItem.Text == "Administrator")
                        {
                            Session["uType"] = 1;
                        }
                        else
                        {
                            Session["uType"] = 2;
                        }

                        string UserCard = txt_UserCard.Text;

                        tau.Update(Session["uName"].ToString(), Session["uEmail"].ToString(), password, Session["uStatus"].ToString(),
                                   Convert.ToInt32(Session["uType"].ToString()), UserCard, id_User);

                        string script = @"alert('This User has been deleted!');
                            window.location.href='Remove_Users.aspx';";

                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", script, true);

                        //talog.Insert("Update User", (string)Session["Username"], System.DateTime.Now);
                    }
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
Example #2
0
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid)
                {
                    MercadoUDi_DataSetTableAdapters.UserTableAdapter tau =
                        new MercadoUDi_DataSetTableAdapters.UserTableAdapter();

                    string password = "";

                    if (Session["User_PasswordRegisterConfig"].ToString() != txt_Password.Text)
                    {
                        password = Encrypt(txt_Password.Text);
                    }
                    else
                    {
                        password = Session["User_PasswordRegisterConfig"].ToString();
                    }

                    Session["uName_Config"]  = txt_Username.Text;
                    Session["uEmail_Config"] = txt_Email.Text;

                    string UserCard = txt_UserCard.Text;

                    tau.Update(Session["uName_Config"].ToString(),
                               Session["uEmail_Config"].ToString(),
                               password,
                               Session["User_Status"].ToString(),
                               Convert.ToInt32(Session["User_Type"].ToString()),
                               UserCard, id_User);

                    string script = @"alert('You have updated your information personal..');
                                window.location.href='DefaultAdmin.aspx';";

                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", script, true);

                    //talog.Insert("The user updated it personal information byself...", (string)Session["Username"], System.DateTime.Now);
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Id_User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                if (Convert.ToInt32(Session["User_Type"].ToString()) != 2)
                {
                    Response.Redirect("DefaultAdmin.aspx");
                }
                else
                {
                    id_User = Convert.ToInt32(Session["Id_User"].ToString());

                    if (!IsPostBack)
                    {
                        if (Session["Id_User"] != null)
                        {
                            MercadoUDi_DataSetTableAdapters.UserTableAdapter tau =
                                new MercadoUDi_DataSetTableAdapters.UserTableAdapter();

                            res = tau.GetDataBy_IdUser(id_User);

                            txt_Username.Text        = res[0].UserName;
                            txt_Email.Text           = res[0].UserEmail;
                            txt_Password.Text        = res[0].UserPassword;
                            txt_ConfirmPassword.Text = res[0].UserPassword;

                            if (res[0].UserCard.ToString() != " ")
                            {
                                txt_UserCard.Text = res[0].UserCard.ToString();
                            }
                            else
                            {
                                txt_UserCard.Text = " ";
                            }

                            password = res[0].UserPassword;

                            Session["User_PasswordRegisterConfig"] = res[0].UserPassword;
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Id_User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                if (Convert.ToInt32(Session["User_Type"].ToString()) != 1)
                {
                    Response.Redirect("Default_Client.aspx");
                }
                else
                {
                    id_User = Convert.ToInt32(Session["Id_User_Update"].ToString());

                    if (!IsPostBack)
                    {
                        if (Session["Id_User_Update"] != null)
                        {
                            MercadoUDi_DataSetTableAdapters.UserTableAdapter tau =
                                new MercadoUDi_DataSetTableAdapters.UserTableAdapter();

                            res = tau.GetDataBy_IdUser(id_User);

                            txt_Username.Text        = res[0].UserName;
                            txt_Email.Text           = res[0].UserEmail;
                            txt_Password.Text        = res[0].UserPassword;
                            txt_ConfirmPassword.Text = res[0].UserPassword;

                            if (res[0].UserCard.ToString() != " ")
                            {
                                txt_UserCard.Text = res[0].UserCard.ToString();
                            }
                            else
                            {
                                txt_UserCard.Text = " ";
                            }

                            password = res[0].UserPassword;

                            int id_User_Type = Convert.ToInt32(res[0].UserType.ToString());

                            resType = taut.GetDataBy_Id(id_User_Type);

                            string userType = resType[0].IdUserType.ToString();

                            /*
                             * DropDownList_Status.SelectedValue = res[0].UserStatus.ToString();
                             * DropDownList_UserType.SelectedValue = userType;
                             *
                             * DropDownList_UserType.DataValueField = resType[0].IdUserType.ToString();*/

                            DropDownList_Status.Text   = res[0].UserStatus.ToString();
                            DropDownList_UserType.Text = resType[0].IdUserType.ToString();

                            Session["User_PasswordRegister"] = res[0].UserPassword;
                        }
                    }
                }
            }
        }