//protected void cvNombre_ServerValidate(object source, ServerValidateEventArgs args)
        //{

        //    args.IsValid = (args.Value.Length >= 3);
        //}

        protected void btnRegistrar_Click1(object sender, EventArgs e)
        {
        
                UsuarioLN usuarios = new UsuarioLN();
                bool confirmacion = usuarios.GuardarUsuario(
                    txtNombre.Text,
                    txtPrimerApellido.Text, 
                    txtSegundoApellido.Text,
                    txtTelefono.Text, 
                    txtCorreo.Text, 
                    txtDireccion.Text,
                    "2", 
                    chkEstado.Checked,
                    chkDisponible.Checked
                    );

                if (confirmacion)
                {
                CorreoLN cl = new CorreoLN();
                cl.EnviarCorreoRegistro((Usuario)UsuarioLN.obtenerUsuario(txtCorreo.Text));
                    this.Response.Redirect("MantenimientoUsuario.aspx?accion=guardado");
                }
                else
                {
                    lblMensaje.Visible = true;
                    lblMensaje.Text = "Ha ocurrido un error, no se puede guardar el usuario";
                }
                    btnRegistrar.Text = "Registrar";
                    Limpiar();
                    txtCorreo.Enabled = true;
        }
Exemplo n.º 2
0
        public ActionResult Registrar(UsuarioViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Registrar", model));
            }

            bool seGuardo = UsuarioLN.GuardarUsuario(
                new UsuarioBE()
            {
                ID_USUARIO  = -1,
                CORREO      = model.CORREO,
                NOMBRES     = model.NOMBRES,
                APELLIDOS   = model.APELLIDOS,
                CONTRASENA  = model.CONTRASENA,
                ID_ROL      = 1,
                FLAG_ESTADO = "1"
            });

            if (seGuardo)
            {
                return(RedirectToAction("Index", "Inicio"));
            }
            else
            {
                ModelState.AddModelError("", "Hubo un problema en la grabación de los datos, intentelo nuevamente");
                return(View());
            }
        }
Exemplo n.º 3
0
        public JsonResult GuardarUsuario(UsuarioBE objUsuario)
        {
            string message  = string.Empty;
            bool   seGuardo = UsuarioLN.GuardarUsuario(objUsuario);

            if (seGuardo)
            {
                message = "Se guardó correctamente";
            }
            else
            {
                message = "Hubo un problema en la grabación de los datos, intentelo nuevamente";
            }

            var jsonResult = Json(new { success = seGuardo, message = message }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }