示例#1
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);
            }
        }