Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var idUserToEdit = Session["idUserToEdit"];

            try
            {
                if (idUserToEdit == null)
                {
                    Response.Redirect("Users.aspx");
                }
                else
                {
                    Personal user = PersonalController.searchUserById(Convert.ToInt32(idUserToEdit));
                    txtName.Attributes.Add("placeholder", user.nombre);
                    txtLastname.Attributes.Add("placeholder", user.apellido);
                    txtPhone.Attributes.Add("placeholder", user.telefono);
                    txtEmail.Attributes.Add("placeholder", user.correo);
                    txtPassword.Attributes.Add("placeholder", user.password);
                    if (!Page.IsPostBack)
                    {
                        userArea.Text = user.area.ToString();
                        userRole.Text = user.rol.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         var loginId = Session["loginId"];
         if (Session["loginId"] == null)
         {
             Response.Redirect("login.aspx");
         }
         else
         {
             Personal user = PersonalController.searchUserById(Convert.ToInt32(loginId));
             if (user.rol != 0)
             {
                 linkUsers.Visible = false;
                 //Response.Redirect("inventory.aspx");
             }
             lblUser.InnerText   = user.nombre + " " + user.apellido;
             titleDate.InnerText = DateTime.Now.ToString();
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);;
     }
 }
Exemple #3
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            var idUserToEdit = Session["idUserToEdit"];

            try
            {
                Personal user = PersonalController.searchUserById(Convert.ToInt32(idUserToEdit));
                if (!string.IsNullOrEmpty(txtName.Text))
                {
                    user.nombre = txtName.Text;
                }
                if (!string.IsNullOrEmpty(txtLastname.Text))
                {
                    user.apellido = txtLastname.Text;
                }
                if (!string.IsNullOrEmpty(txtPhone.Text))
                {
                    user.telefono = txtPhone.Text;
                }
                if (!string.IsNullOrEmpty(txtEmail.Text))
                {
                    user.correo = txtEmail.Text;
                }
                if (!string.IsNullOrEmpty(txtPassword.Text))
                {
                    user.password = txtPassword.Text;
                }
                user.area = userArea.SelectedValue;
                user.rol  = Convert.ToInt32(userRole.SelectedValue);
                PersonalController.editUser(user);
                Response.Redirect("Users.aspx");
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);
            }
        }