Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            entusuario obj = (entusuario)Session["usuario"];

            if (obj != null)
            {
                txtnombre.Text = obj.Nombre + " " + obj.Apellido;
            }
            else
            {
                Response.Redirect("frmLogin.aspx");
            }
        }
Пример #2
0
        public static entusuario Login(String usuario, String password)
        {
            entusuario    obj = null;
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;

            try
            {
                Conexion      cn  = new Conexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("VerificacioUsuario", cnx);
                cmd.Parameters.AddWithValue("@Usuario", usuario);
                cmd.Parameters.AddWithValue("@Password", password);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr  = cmd.ExecuteReader();
                obj = new entusuario();
                dr.Read();
                obj.Apellido  = dr["Apellido"].ToString();
                obj.idUsuario = Convert.ToInt32(dr["idUsuario"].ToString());
                obj.Nombre    = dr["Nombre"].ToString();
                obj.Password  = dr["Password"].ToString();
                obj.Usuario   = dr["Password"].ToString();
                obj.estado    = Convert.ToInt32(dr["estado"].ToString());
                obj.Rol       = Convert.ToInt32(dr["Rol"].ToString());
            }
            catch (Exception e)
            {
                obj = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(obj);
        }
Пример #3
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtusuario.Text != "" && txtpass.Text != "")
            {
                entusuario obj = negusuario.Login(txtusuario.Text, txtpass.Text);

                if (obj != null)
                {
                    if (obj.estado == 0)
                    {
                        lblerror.Text    = "Usuario No Activo";
                        lblerror.Visible = true;
                    }
                    else
                    {
                        if (obj.estado == 1)
                        {
                            if (obj.Rol == 0)
                            {
                                lblerror.Text    = "USUARIO NO TIENE ASIGDO ROL";
                                lblerror.Visible = true;
                            }
                            else
                            {
                                if (obj.Rol == 1)
                                {
                                    Session["usuario"] = obj;
                                    Response.Redirect("a2d1m5i9n7i6s7t0r7a9do4r.aspx");
                                }
                                else
                                {
                                    if (obj.Rol == 2)
                                    {
                                        Session["usuario"] = obj;
                                        Response.Redirect("producto.aspx");
                                    }
                                    else
                                    {
                                        lblerror.Text    = "PONERSE EN CONTACTO CON EL ADMINISTRADOR";
                                        lblerror.Visible = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            lblerror.Text    = "Consulte con el Administrador";
                            lblerror.Visible = true;
                        }
                    }
                }
                else
                {
                    lblerror.Text    = "Usuario o contraseña invalido";
                    lblerror.Visible = true;
                }
            }
            else
            {
                lblerror.Text    = "Falta ingresar campos";
                lblerror.Visible = true;
            }
        }