Example #1
0
        public static bool Sesion()
        {
            bool response = false;

            try
            {
                using (SqlConnection con = DataBaseManager.OpenSqlDatabase(user, pass, servidor, baseDatos))
                {
                    if (con.State == System.Data.ConnectionState.Open && con.Database.Equals(baseDatos))
                    {
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(response);
        }
Example #2
0
        public static List <MenuEn> ConsultaMenu(UsuariosEn _usuario)
        {
            List <MenuEn> response = new List <MenuEn>();

            try
            {
                using (SqlConnection con = DataBaseManager.OpenSqlDatabase(user, pass, servidor, baseDatos))
                {
                    using (SqlCommand command = con.CreateCommand())
                    {
                        command.CommandText = "sp_consulta_menuxuser";
                        command.CommandType = System.Data.CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_username", _usuario.User_name);



                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                MenuEn tmp = new MenuEn();

                                tmp.Cod_objeto = dr["cod_objeto"].ToString() ?? string.Empty;
                                tmp.Id_menu    = dr["id_menu"] != DBNull.Value ?Convert.ToInt32(dr["id_menu"]) : 0;

                                response.Add(tmp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }
Example #3
0
        public static List <RolEn> ConsultaRoles()
        {
            List <RolEn> response = new List <RolEn>();

            try
            {
                using (SqlConnection con = DataBaseManager.OpenSqlDatabase(user, pass, servidor, baseDatos))
                {
                    using (SqlCommand command = con.CreateCommand())
                    {
                        command.CommandText = "sp_consulta_roles";
                        command.CommandType = System.Data.CommandType.StoredProcedure;


                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                RolEn tmp = new RolEn();

                                tmp.Desc_rol = dr["id_rol"].ToString() ?? string.Empty;
                                tmp.Id_rol   = dr["DESC_ROL"] != DBNull.Value ? Convert.ToInt32(dr["id_rol"]) : 0;

                                response.Add(tmp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }