Ejemplo n.º 1
0
        protected void FillDataUser()
        {
            Users oUser = new User().GetUser(Convert.ToInt32(Request.QueryString["PersonaId"]));
            if (oUser != null)
            {
                this.ddlRol.SelectedValue = oUser.RolId.ToString();
                if (oUser.Activo == true)
                    this.ddlActivo.SelectedValue = "1";
                else
                    this.ddlActivo.SelectedValue = "0";

                this.btnAddUser.Text = "Actualizar";
            }
            else
            {
                this.lblEstadoUsuario.Text = "USUARIO NO GENERADO";
            }
            this.txtPirulo.Text = "";
        }
Ejemplo n.º 2
0
        protected void btnAddUser_Click(object sender, EventArgs e)
        {
            try
            {
                Users oUser = oUser = new User().GetUser(int.Parse(Request.QueryString["PersonaId"]));

                if (oUser != null)
                {
                    oUser.Activo = this.ddlActivo.SelectedValue == "1" ? true : false;
                    oUser.RolId = Convert.ToInt32(ddlRol.SelectedValue);
                    oUser.Salt = Security.GenerateSalt().ToString();
                    oUser.Password = Security.GetSHA512WithSalt(txtPirulo.Text.Trim(), oUser.Salt);

                    new User().UpdateUser(oUser);
                }
                else
                {
                    oUser = new Users();

                    oUser.Activo = this.ddlActivo.SelectedValue == "1" ? true : false;
                    oUser.RolId = Convert.ToInt32(ddlRol.SelectedValue);
                    oUser.PersonaId = int.Parse(Request.QueryString["PersonaId"]);
                    oUser.Salt = Security.GenerateSalt().ToString();
                    oUser.Password = Security.GetSHA512WithSalt(txtPirulo.Text.Trim(), oUser.Salt);

                    new User().AddUser(oUser);
                }

                this.ClientScript.RegisterStartupScript(this.GetType(), "User", "alert('El usuario fue creado/modificado con exito.');", true);
            }
            catch (Exception ex)
            {
                this.lblErrorUsuario.Text = ex.Message;
            }
        }