Exemplo n.º 1
0
 protected void btnRegistrarse_Click(object sender, EventArgs e)
 {
     try
     {
         UsuariosDAL     _DAL            = new UsuariosDAL();
         ft_usuarioModel ft_UsuarioModel = new ft_usuarioModel();
         ft_UsuarioModel.usu_mail     = dfnewusu_mail.Value;
         ft_UsuarioModel.usu_password = dfnewusu_password.Value;
         ft_UsuarioModel.usu_nombre   = dfnewusu_nombre.Value;
         List <ft_usuarioModel> lista = null;
         lista = _DAL.GetUsuarios(ft_UsuarioModel);
         if (lista.Count > 0)
         {
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Close Modal Popup", "alert('El usuario existe, Verifique !!!');", true);
         }
         else
         {
             _DAL.insUsuario(ft_UsuarioModel);
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Close Modal Popup", "alert('Registro, conlcuido !!!');", true);
             FormsAuthentication.RedirectToLoginPage();
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Error", "alert('" + FormateaError(ex.Message) + "');", true);
     }
 }
Exemplo n.º 2
0
        public List <ft_usuarioModel> insUsuario(ft_usuarioModel _Entidad)
        {
            List <ft_usuarioModel> _list = new List <ft_usuarioModel>();

            SqlParameter[] parametros =
            {
                new SqlParameter("@usu_mail",     SqlDbType.VarChar, 100)
                {
                    Value = _Entidad.usu_mail
                },
                new SqlParameter("@usu_nombre",   SqlDbType.VarChar, 200)
                {
                    Value = _Entidad.usu_nombre
                },
                new SqlParameter("@usu_password", SqlDbType.VarChar, 50)
                {
                    Value = _Entidad.usu_password
                }
            };
            try
            {
                using (var reader = base.ExecuteReader(CommandType.StoredProcedure, "InsUsuario", parametros))
                {
                    var dataTable = new DataTable();
                    dataTable.Load(reader);
                    _list = dataTable.ToList <ft_usuarioModel>();
                }
                return(_list);
            }
            catch
            { throw; }
            finally { parametros = null; }
        }
Exemplo n.º 3
0
        protected void btnIniciarSesion_Click(object sender, EventArgs e)
        {
            try
            {
                UsuariosDAL     _DAL            = new UsuariosDAL();
                ft_usuarioModel ft_UsuarioModel = new ft_usuarioModel();
                ft_UsuarioModel.usu_mail     = dfusu_mail.Value;
                ft_UsuarioModel.usu_password = dfusu_password.Value;
                List <ft_usuarioModel> lista = null;
                lista = _DAL.ValidateLogin(ft_UsuarioModel);
                if (lista.Count > 0)
                {
                    susu_nombre           = lista.FirstOrDefault().usu_nombre;
                    Session["usu_nombre"] = lista.FirstOrDefault().usu_nombre;
                    nusu_id           = Convert.ToInt32(lista.FirstOrDefault().usu_id);
                    Session["usu_id"] = lista.FirstOrDefault().usu_id;

                    FormsAuthentication.SetAuthCookie(susu_nombre, true);
                    Response.Redirect(FormsAuthentication.DefaultUrl);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Close Modal Popup", "alert('Usuario o Password, erroneo, Verifique !!!');", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Error", "alert('" + FormateaError(ex.Message) + "');", true);
            }
        }