コード例 #1
0
ファイル: UsuarioDAO.cs プロジェクト: userdapp/DAPP
    public static List <UsuarioVO> Buscar(String uUsr, String uPsw)
    {
        //"select K_TOKEN, F_FECHA_DEN, N_DESC_DENUNCIA from denuncia where K_TOKEN ='" + denToken + "'";

        String sqlConsulta = "select * from usuario where N_Usuario = '" + uUsr + "' and N_Pass = '******'";

        List <UsuarioVO> _lista = new List <UsuarioVO>();

        MySqlCommand _comando = new MySqlCommand(sqlConsulta, BDComun.ObtenerConexion());

        MySqlDataReader _reader = _comando.ExecuteReader();

        while (_reader.Read())
        {
            UsuarioVO usuarioVO = new UsuarioVO();
            usuarioVO.Pass            = _reader.GetString(0);
            usuarioVO.Usr             = _reader.GetString(1);
            usuarioVO.Email           = _reader.GetString(2);
            usuarioVO.Cel             = _reader.GetFloat(3);
            usuarioVO.Tel2            = _reader.GetFloat(4);
            usuarioVO.Tel1            = _reader.GetFloat(5);
            usuarioVO.FechaNacimiento = _reader.GetDateTime(6);
            usuarioVO.NombreUsuario   = _reader.GetString(7);
            usuarioVO.DocIdent        = _reader.GetFloat(8);
            usuarioVO.IdTipoDoc       = _reader.GetString(9);
            usuarioVO.IdUsuario       = _reader.GetString(10);
            usuarioVO.IdEntidad       = _reader.GetString(11);

            _lista.Add(usuarioVO);
        }

        _reader.Close();
        return(_lista);
    }
コード例 #2
0
        public static bool CrearRol(String Nombre, int habilitado, String funcionalidad)
        {
            SqlConnection Conexion = BDComun.ObtenerConexion();

            try
            {
                SqlCommand comando = new SqlCommand("pero_compila.sp_alta_rol", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@nombre", Nombre);
                comando.Parameters.AddWithValue("@habilitado", habilitado);
                comando.Parameters.AddWithValue("@funcionalidad", funcionalidad);

                if (comando.ExecuteNonQuery() > 0)
                {
                    Conexion.Close();
                    return(true);
                }
                else
                {
                    Conexion.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Conexion.Close();
                return(false);
            }
        }
コード例 #3
0
        public static List <Rol> BuscarRol()
        {
            List <Rol> roles = new List <Rol>();

            try
            {
                using (SqlConnection Conexion = BDComun.ObtenerConexion())
                {
                    SqlCommand comando = new SqlCommand("pero_compila.sp_get_roles", Conexion);
                    comando.CommandType = CommandType.StoredProcedure;
                    //se limpian los parámetros
                    //comando.Parameters.Clear();
                    //executamos la consulta SqlDataReader reader = Comando.ExecuteReader();
                    SqlDataReader reader = comando.ExecuteReader();
                    while (reader.Read())
                    {
                        Rol rol = new Rol();
                        rol.Id              = reader.GetInt32(0);
                        rol.Nombre          = reader.GetString(1);
                        rol.funcionalidad   = null;
                        rol.habilitado      = 1;
                        rol.RolesPorUsuario = "";

                        roles.Add(rol);
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(roles);
        }
コード例 #4
0
        public static int insert(int idUsuario, int idHotel)
        {
            SqlConnection Conexion = BDComun.ObtenerConexion();

            try
            {
                SqlCommand comando = new SqlCommand("pero_compila.sp_alta_usuarioXHotel", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@idUsuario", idUsuario);
                comando.Parameters.AddWithValue("@idHotel", idHotel);
                if (comando.ExecuteNonQuery() > 0)
                {
                    Conexion.Close();
                    return(1);
                }
                else
                {
                    Conexion.Close();
                    return(0);
                }
            }
            catch (Exception ex)
            {
                Conexion.Close();
                return(0);
            }
        }
コード例 #5
0
        public static List <Rol> BuscarRolesHabilitadosEInhabilitados()
        {
            List <Rol> roles = new List <Rol>();

            try
            {
                using (SqlConnection Conexion = BDComun.ObtenerConexion())
                {
                    SqlCommand    Comando = new SqlCommand(String.Format("SELECT * from pero_compila.Rol "), Conexion);
                    SqlDataReader reader  = Comando.ExecuteReader();
                    while (reader.Read())
                    {
                        Rol rol = new Rol();
                        rol.Id     = reader.GetInt32(0);
                        rol.Nombre = reader.GetString(1);


                        roles.Add(rol);
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(roles);
        }
コード例 #6
0
    public static List <DenunciaVO> Buscar(String denToken)
    {
        String sqlConsulta = "select K_TOKEN, F_FECHA_DEN, N_DESC_DENUNCIA from denuncia where K_TOKEN ='" + denToken + "'";

        List <DenunciaVO> _lista = new List <DenunciaVO>();


        MySqlCommand _comando = new MySqlCommand(sqlConsulta, BDComun.ObtenerConexion());

        MySqlDataReader _reader = _comando.ExecuteReader();

        while (_reader.Read())
        {
            DenunciaVO denunciaVO = new DenunciaVO();
            denunciaVO.Token         = _reader.GetString(0);
            denunciaVO.FechaDenuncia = _reader.GetDateTime(1);
            // denunciaVO.PrioridadDenuncia = _reader.GetDecimal(2);
            denunciaVO.DescDenuncia = _reader.GetString(2);
            //denunciaVO.IdDenuncia = _reader.GetInt32(5);
            //denunciaVO.IdTipoDenuncia = _reader.GetString(4);

            _lista.Add(denunciaVO);
        }

        _reader.Close();
        return(_lista);
    }
コード例 #7
0
        internal static void PasarAInhabilitado(string p)
        {
            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand Comando = new SqlCommand(String.Format("update pero_compila.Usuario set usuario_estado=0 where usuario_username='******'", p), Conexion);
                Comando.ExecuteNonQuery();


                Conexion.Close();
            }
        }
コード例 #8
0
 public static bool EliminarRol(int idRol)
 {
     try
     {
         SqlConnection Conexion = BDComun.ObtenerConexion();
         SqlCommand    comando  = new SqlCommand("pero_compila.sp_baja_rol", Conexion);
         comando.CommandType = CommandType.StoredProcedure;
         //se limpian los parámetros
         comando.Parameters.Clear();
         //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
         //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
         comando.Parameters.AddWithValue("@Id", idRol);
         return(comando.ExecuteNonQuery() > 0 ? true : false);
     }
     catch (Exception ex) { return(false); }
 }
コード例 #9
0
        public static int SacarRolATodosLosUsuarios(int idRol)
        {
            int           reader = 0;
            List <String> roles  = new List <String>();

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand Comando = new SqlCommand(String.Format("delete from pero_compila.RolXUsuario  where rolXUsuario_rol='{0}' ", idRol), Conexion);
                reader = Comando.ExecuteNonQuery();


                Conexion.Close();
            }


            return(reader);
        }
コード例 #10
0
        public int getidRolPorNombre(string nombre)
        {
            int id = 0;

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT rol_id from pero_compila.Rol where rol_nombre like '{0}'", nombre), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();
                while (reader.Read())
                {
                    id = reader.GetInt32(0);
                }

                Conexion.Close();
            }
            return(id);
        }
コード例 #11
0
        public static int RolId(String nombreRol)
        {
            int id = 0;

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                Rol           rol     = new Rol();
                SqlCommand    Comando = new SqlCommand(String.Format("select rol_id from pero_compila.Rol where rol_nombre = '{0}'", nombreRol), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();
                while (reader.Read())
                {
                    id = reader.GetInt32(0);
                }

                Conexion.Close();
            }
            return(id);
        }
コード例 #12
0
        public string getHotel(string user)
        {
            string hotel = "";

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand Comando = new SqlCommand(String.Format("select h.hotel_nombre from pero_compila.Usuario u join pero_compila.UsuarioXHotel uxh on(u.usuario_Id=uxh.usuarioXHotel_usuario) join pero_compila.Hotel h on(h.hotel_Id=uxh.usuarioXHotel_hotel) where  hotel_nombre not like 'null' and  u.usuario_username like'{0}'", user), Conexion);

                SqlDataReader reader = Comando.ExecuteReader();
                while (reader.Read())
                {
                    hotel = reader.GetString(0);
                }

                Conexion.Close();
            }
            return(hotel);
        }
コード例 #13
0
        public static bool Autenticacion(String user, String pass)
        {
            try
            {
                int           Valor_Retornado = 0;
                SqlConnection Conexion        = BDComun.ObtenerConexion();
                SqlCommand    comando         = new SqlCommand("pero_compila.login", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@user", user);
                comando.Parameters.AddWithValue("@pass", pass);              //declaramos el parámetro de retorno

                SqlParameter ValorRetorno = new SqlParameter("@ret", SqlDbType.Int);
                //asignamos el valor de retorno
                ValorRetorno.Direction = ParameterDirection.Output;
                comando.Parameters.Add(ValorRetorno);
                //executamos la consulta
                comando.ExecuteNonQuery();
                // traemos el valor de retorno
                Valor_Retornado = Convert.ToInt32(ValorRetorno.Value);
                //dependiendo del valor de retorno se asigna la variable success
                //si el procedimiento retorna un 1 la operación se realizó con éxito
                //de no ser así se mantiene en false y pr lo tanto falló la operación
                Conexion.Close();
                if (Valor_Retornado == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
                //al ocurrir un error mostramos un mensaje
                //MessageBox.Show(“Error en la operación”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #14
0
        public List <String> getAllRoles()
        {
            List <String> roles = new List <String>();

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT DISTINCT rol_nombre from pero_compila.Rol"), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Nombre = reader.GetString(0);

                    roles.Add(Nombre);
                }
                Conexion.Close();
            }
            return(roles);
        }
コード例 #15
0
ファイル: AccesoAdm.aspx.cs プロジェクト: userdapp/DAPP
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        BDComun.ObtenerConexion();

        usr = txbUsr.Text;
        psw = txbPsw.Text;

        List <UsuarioVO> usuario = UsuarioDAO.Buscar(usr, psw);

        if (usuario.Count > 0 && usuario != null)
        {
            this.pnlEnt.Visible       = true;
            this.pnlAccesoAdm.Visible = false;
        }
        else
        {
            this.pnlAccesoAdm.Visible = true;
        }
    }
コード例 #16
0
        public List <String> getAllFuncionalidades()
        {
            List <String> func = new List <String>();

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT DISTINCT funcionalidad_descripcion from pero_compila.Funcionalidad"), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Funcionalidad f = new Funcionalidad();
                    //f.IdFuncionalidad = reader.GetInt32(0);
                    descripcion = reader.GetString(0);
                    func.Add(descripcion);
                }
                Conexion.Close();
            }
            return(func);
        }
コード例 #17
0
    protected void btnRegistrar_Click(object sender, EventArgs e)
    {
        BDComun.ObtenerConexion();

        // txbIdTipoDen.Text = GenerarRandom();


        denunciaVO.IdTipoDenuncia    = ddlTipoDen.SelectedItem.Value;
        denunciaVO.IdDenuncia        = Convert.ToInt32(txbIdDenuncia.Text);    //debe traer esta info automáticamente
        denunciaVO.DescDenuncia      = txbDescDenuncia.Text;
        denunciaVO.PrioridadDenuncia = Convert.ToInt32(txbPriorDenuncia.Text); //Debe generar esta info automáticamente
        //denunciaVO.FechaDenuncia = Convert.ToDateTime(txbFechaDenuncia.Text);
        denunciaVO.Token = txbToken.Text;

        int resultado = DenunciaDAO.Agregar(denunciaVO);


        if (resultado > 0)
        {
            this.pnlMostrarDenuncia.Visible = true;
            this.pnlInsertarDen.Visible     = false;


            this.lblMostrarToken.Text = txbToken.Text;
        }
        else
        {
            this.pnlInsertarDen.Visible = false;
        }

        /* this.tipoDenuncia = this.txbTipoDenuncia.Text;
         * this.descDenuncia = this.txbDescDenuncia.Text;
         * this.fechaDenuncia = this.txbFechaDenuncia.Text;
         *
         * this.pnlMostrarDenuncia.Visible = true;
         * this.pnlInsertarDen.Visible = false;
         *
         * this.lblTipoDenuncia2.Text = this.tipoDenuncia;
         * this.lblDescDenuncia2.Text = this.descDenuncia;
         * this.lblFechaDenuncia2.Text = this.fechaDenuncia;*/
    }
コード例 #18
0
        public List <String> getHotelPorUsuario(String nombreUser, String rolUsuario)
        {
            {
                List <String> hoteles = new List <String>();

                using (SqlConnection Conexion = BDComun.ObtenerConexion())
                {
                    SqlCommand    Comando = new SqlCommand(String.Format("select distinct H.hotel_direccion FROM pero_compila.Usuario u JOIN pero_compila.UsuarioXHotel uxh ON (u.usuario_ID = uxh.UsuarioXHotel_usuario) JOIN pero_compila.Hotel h ON (h.hotel_id=uxh.UsuarioXHotel_hotel) JOIN pero_compila.RolXUsuario rxu ON(rxu.rolXUsuario_usuario=u.usuario_Id) JOIN pero_compila.Rol r ON(r.rol_Id=rxu.rolXUsuario_rol) WHERE u.usuario_username LIKE '{0}' and h.hotel_estado=1 and hotel_id not like 'null' and r.rol_nombre LIKE '{1}'", nombreUser, rolUsuario), Conexion);
                    SqlDataReader reader  = Comando.ExecuteReader();

                    while (reader.Read())
                    {
                        UsuarioPorHotel = reader.GetString(0);

                        hoteles.Add(UsuarioPorHotel);
                    }
                    Conexion.Close();
                }
                return(hoteles);
            }
        }
コード例 #19
0
 internal bool estaHabilitado(int idRol)
 {
     try
     {
         SqlConnection Conexion = BDComun.ObtenerConexion();
         SqlCommand    Comando  = new SqlCommand(String.Format("SELECT rol_estado from pero_compila.Rol where rol_id='{0}'", idRol), Conexion);
         //comando.Parameters.AddWithValue("@rol_funcionalidades", Func);
         SqlDataReader reader = Comando.ExecuteReader();
         bool          estado = false;
         while (reader.Read())
         {
             estado = reader.GetBoolean(0);
         }
         Conexion.Close();
         return(estado);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #20
0
        public List <String> getRolPorUsuario(String nombreUser)
        {
            {
                List <String> roles = new List <String>();

                using (SqlConnection Conexion = BDComun.ObtenerConexion())
                {
                    SqlCommand    Comando = new SqlCommand(String.Format("select distinct R.rol_nombre FROM pero_compila.Usuario u  JOIN pero_compila.rolXUsuario uxr ON (u.usuario_ID = uxr.rolXUsuario_usuario) JOIN pero_compila.Rol R ON (R.ROL_ID=uxr.rolXUsuario_rol) WHERE u.usuario_username LIKE '{0}' ", nombreUser), Conexion);
                    SqlDataReader reader  = Comando.ExecuteReader();

                    while (reader.Read())
                    {
                        RolesPorUsuario = reader.GetString(0);

                        roles.Add(RolesPorUsuario);
                    }
                    Conexion.Close();
                }
                return(roles);
            }
        }
コード例 #21
0
        public List <Rol> getAllRol()
        {
            List <Rol> roles = new List <Rol>();

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT * from pero_compila.Rol where rol_estado=1"), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Rol r = new Rol();
                    r.Id     = reader.GetInt32(0);
                    r.Nombre = reader.GetString(1);

                    roles.Add(r);
                }
                Conexion.Close();
            }
            return(roles);
        }
コード例 #22
0
    protected void btnConsultarDen_Click(object sender, EventArgs e)
    {
        BDComun.ObtenerConexion();

        denToken = txbConsultarDen.Text;

        List <DenunciaVO> denuncia = DenunciaDAO.Buscar(denToken);

        if (denuncia.Count > 0 && denuncia != null)
        {
            GridViewConsDen.DataSource = denuncia;
            GridViewConsDen.DataBind();
        }

        /*
         * txbToken.Text = denuncia[0].Token; //denunciaVO.Token;
         * txbFechaDenuncia.Text = "hola";//String.Format("{0:MM/dd/yyyy}", denuncia[1].FechaDenuncia);//denunciaVO.FechaDenuncia;
         * txbDescripcion.Text = denuncia[2].DescDenuncia;//denunciaVO.DescDenuncia;*/

        this.pnlMostrarInfoDen.Visible = true;
        this.pnlConsultarDen.Visible   = false;
    }
コード例 #23
0
        //public static bool ModificarRol(int id, String nombre, int habilitado, String Func)
        //{
        //    int Valor_Retornado = 0;
        //    try
        //    {

        //        SqlConnection Conexion = BDComun.ObtenerConexion();
        //        SqlCommand comando = new SqlCommand("pero_compila.sp_update_rol", Conexion);
        //        comando.CommandType = CommandType.StoredProcedure;
        //        //se limpian los parámetros
        //        comando.Parameters.Clear();
        //        //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
        //        //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
        //        comando.Parameters.AddWithValue("@rol_id", id);
        //        comando.Parameters.AddWithValue("@rol_nombre", nombre);
        //        comando.Parameters.AddWithValue("@rol_habilitado", habilitado);
        //        comando.Parameters.AddWithValue("@rol_funcionalidades", Func);


        //        if (comando.ExecuteNonQuery() > 0)
        //        {
        //            return true;
        //        }
        //        else
        //        {
        //            return false;
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //}
        public static bool ModificarRol(int id, String nombre, int habilitado)
        {
            try
            {
                SqlConnection Conexion = BDComun.ObtenerConexion();
                SqlCommand    comando  = new SqlCommand("pero_compila.sp_update_rol", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@id", id);
                comando.Parameters.AddWithValue("@nombre", nombre);
                comando.Parameters.AddWithValue("@habilitado", habilitado);
                //comando.Parameters.AddWithValue("@rol_funcionalidades", Func);
                return(comando.ExecuteNonQuery() > 0 ? true : false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #24
0
        public static int CrearCuenta(String nomUsuario, String contrasenia)
        {
            int resultado = 0;

            try
            {
                SqlConnection Conexion = BDComun.ObtenerConexion();
                SqlCommand    comando  = new SqlCommand("pero_compila.registrarUsuario", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@user", nomUsuario);
                comando.Parameters.AddWithValue("@pass", contrasenia);              //declaramos el parámetro de retorno
                //executamos la consulta
                resultado = comando.ExecuteNonQuery();
                // traemos el valor de retorno

                //dependiendo del valor de retorno se asigna la variable success
                //si el procedimiento retorna un 1 la operación se realizó con éxito
                //de no ser así se mantiene en false y pr lo tanto falló la operación
                Conexion.Close();
                if (resultado == 1)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception)
            {
                return(-1);
                //al ocurrir un error mostramos un mensaje
                //MessageBox.Show(“Error en la operación”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #25
0
        public List <Hotel> getListHoteles()
        {
            List <Hotel> hots = new List <Hotel>();

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                //SqlCommand Comando = new SqlCommand(String.Format(" SELECT DISTINCT hotel_id,hotel_nombre from pero_compila.Hotel where hotel_nombre not like 'null'"), Conexion);
                SqlCommand Comando = new SqlCommand(String.Format("  SELECT DISTINCT hotel_id,hotel_direccion from pero_compila.Hotel where hotel_direccion not like 'null'"), Conexion);

                SqlDataReader reader = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Hotel h = new Hotel();
                    h.Id     = reader.GetInt32(0);
                    h.Nombre = reader.GetString(1);

                    hots.Add(h);
                }
                Conexion.Close();
            }
            return(hots);
        }
コード例 #26
0
        public int getIdFuncionalidadXRol(String rol, int idFunc)
        {
            //  List<int> funcionalidadesIds = new List<int>();
            Rol r     = new Rol();
            int idRol = r.getidRolPorNombre(rol);
            int f     = 0;

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT DISTINCT funcionalidad_Id,funcionalidad_descripcion,fxr.funcionalidadXRol_Id from pero_compila.Funcionalidad f join pero_compila.FuncionalidadXRol fxr on(f.funcionalidad_Id=fxr.funcionalidadXRol_funcionalidad) where fxr.funcionalidadXRol_rol='{0}' and  fxr.funcionalidadXRol_funcionalidad='{1}'", idRol, idFunc), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();

                while (reader.Read())
                {
                    //f.IdFuncionalidad = reader.GetInt32(0);
                    // f.descripcion = reader.GetString(1);
                    f = reader.GetInt32(2);
                    //funcionalidadesIds.Add(f);
                }
                Conexion.Close();
            }
            return(f);
        }
コード例 #27
0
        //LA AGREGUUE YOOO

        public static List <Funcionalidad> getFuncionalidadesXRol(string rol)
        {
            List <Funcionalidad> funcionalidadesRol = new List <Funcionalidad>();
            Rol r     = new Rol();
            int idRol = r.getidRolPorNombre(rol);

            using (SqlConnection Conexion = BDComun.ObtenerConexion())
            {
                SqlCommand    Comando = new SqlCommand(String.Format("SELECT DISTINCT funcionalidad_descripcion from pero_compila.Funcionalidad f join pero_compila.FuncionalidadXRol fxr on(f.funcionalidad_Id=fxr.funcionalidadXRol_funcionalidad) where fxr.funcionalidadXRol_rol='{0}'", idRol), Conexion);
                SqlDataReader reader  = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Funcionalidad f = new Funcionalidad();
                    //  f.IdFuncionalidad = reader.GetInt32(0);
                    f.descripcion = reader.GetString(0);
                    //f.IdRolXFunc = reader.GetInt32(2);
                    funcionalidadesRol.Add(f);
                }
                Conexion.Close();
            }
            return(funcionalidadesRol);
        }
コード例 #28
0
 public static int CrearCuenta(String nomUsuario, String contrasenia)
 {
     try
     {
         Rol           r        = new Rol();
         SqlConnection Conexion = BDComun.ObtenerConexion();
         SqlCommand    comando  = new SqlCommand("pero_compila.registrarUsuario", Conexion);
         comando.CommandType = CommandType.StoredProcedure;
         //se limpian los parámetros
         comando.Parameters.Clear();
         //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
         //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
         comando.Parameters.AddWithValue("@user", nomUsuario);
         comando.Parameters.AddWithValue("@pass", contrasenia);
         //declaramos el parámetro de retorno
         //executamos la consulta
         int id = Convert.ToInt32(comando.ExecuteScalar());
         if (id > 0)
         {
             //comando.CommandText = "Select Max(rol_Id) from [pero_compila].[Rol]";
             //id= Convert.ToInt32(comando.ExecuteScalar());
             //Conexion.Close();
             return(id);
         }
         else
         {
             Conexion.Close();
             return(id);
         }
     }
     catch (Exception ex)
     {
         return(-1);
         //al ocurrir un error mostramos un mensaje
         //MessageBox.Show(“Error en la operación”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #29
0
        public static int insert(String Nombre)
        {
            SqlConnection Conexion = BDComun.ObtenerConexion();

            try
            {
                SqlCommand comando = new SqlCommand("pero_compila.sp_solo_alta_rol", Conexion);
                comando.CommandType = CommandType.StoredProcedure;
                //se limpian los parámetros
                comando.Parameters.Clear();
                //comenzamos a mandar cada uno de los parámetros, deben de enviarse en el
                //tipo de datos que coincida en sql server por ejemplo c# es string en sql server es varchar()
                comando.Parameters.AddWithValue("@nombre", Nombre);
                comando.Parameters.AddWithValue("@habilitado", true);
                //int id = comando.ExecuteNonQuery();
                //int id = Convert.ToInt32(comando.ExecuteScalar());
                int id = Convert.ToInt32(comando.ExecuteScalar());
                if (id > 0)
                {
                    //comando.CommandText = "Select Max(rol_Id) from [pero_compila].[Rol]";
                    //id= Convert.ToInt32(comando.ExecuteScalar());
                    //Conexion.Close();
                    return(id);
                }
                else
                {
                    Conexion.Close();
                    return(id);
                }
            }
            catch (Exception ex)
            {
                // System.Windows.Forms.MessageBox.Show(ex.Message, "ERRROR", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.);
                Conexion.Close();
                return(0);
            }
        }
コード例 #30
0
    public static int Agregar(DenunciaVO denunciaVO)
    {
        int retorno = 0;

        MySqlCommand comando = new MySqlCommand(string.Format("insert into denuncia (K_ID_TIPODEN,K_ID_DENUNCIA,N_DESC_DENUNCIA,N_PRIORIDAD_DEN,F_FECHA_DEN,K_TOKEN) values ('{0}','{1}','{2}','{3}','{4}','{5}')",
                                                              denunciaVO.IdTipoDenuncia, denunciaVO.IdDenuncia, denunciaVO.DescDenuncia, denunciaVO.PrioridadDenuncia, denunciaVO.FechaDenuncia, denunciaVO.Token), BDComun.ObtenerConexion());

        retorno = comando.ExecuteNonQuery();

        return(retorno);
    }