コード例 #1
0
        //Muestra la lista de colores
        public IEnumerable <CatColores> ListaColores()
        {
            List <CatColores> listColores = new List <CatColores>();

            try
            {
                comando.Connection  = conn.AbrirConexion();
                comando.CommandText = "Listar_Color";
                comando.CommandType = CommandType.StoredProcedure;
                leer = comando.ExecuteReader();
                while (leer.Read())
                {
                    CatColores colores = new CatColores();
                    colores.IdColor          = Convert.ToInt32(leer["ID_COLOR"]);
                    colores.CodigoColor      = leer["CODIGO_COLOR"].ToString().TrimEnd();
                    colores.DescripcionColor = leer["DESCRIPCION"].ToString().TrimEnd();
                    colores.DescripcionColor.TrimStart();
                    listColores.Add(colores);
                }
                leer.Close();
            }
            finally
            {
                conn.CerrarConexion();
                conn.Dispose();
            }

            return(listColores);
        }
コード例 #2
0
        //Permite consultar los detalles de un color
        public CatColores ConsultarListaColores(int?id)
        {
            CatColores colores = new CatColores();

            try
            {
                comando.Connection  = conn.AbrirConexion();
                comando.CommandText = "Listar_Color_Por_Id";
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@Id", id);
                leer = comando.ExecuteReader();
                while (leer.Read())
                {
                    colores.IdColor          = Convert.ToInt32(leer["ID_COLOR"]);
                    colores.CodigoColor      = leer["CODIGO_COLOR"].ToString().TrimEnd();
                    colores.DescripcionColor = leer["DESCRIPCION"].ToString().TrimEnd();
                }
            }
            finally
            {
                conn.CerrarConexion();
                conn.Dispose();
            }
            return(colores);
        }
コード例 #3
0
        /*public DataTable ListColores()
         * {
         *  DataTable tabla = new DataTable();
         *  comando.Connection = conn.AbrirConexion();
         *  comando.CommandText = "Listar_Color";
         *  comando.CommandType = CommandType.StoredProcedure;
         *  leer = comando.ExecuteReader();
         *  tabla.Load(leer);
         *  leer.Close();
         *  conn.CerrarConexion();
         *  return tabla;
         *
         * }*/

        //Permite crear un nuevo color
        public void AgregarColores(CatColores colores)
        {
            comando.Connection  = conn.AbrirConexion();
            comando.CommandText = "AgregarColor";
            comando.CommandType = CommandType.StoredProcedure;

            comando.Parameters.AddWithValue("@ColorStyle", colores.CodigoColor);
            comando.Parameters.AddWithValue("@ColorDesc", colores.DescripcionColor);

            comando.ExecuteNonQuery();
            conn.CerrarConexion();
        }
コード例 #4
0
 //Permite actualiza la informacion de un color
 public void ActualizarColores(CatColores colores)
 {
     try
     {
         comando.Connection  = conn.AbrirConexion();
         comando.CommandText = "Actualizar_Colores";
         comando.CommandType = CommandType.StoredProcedure;
         comando.Parameters.AddWithValue("@Id", colores.IdColor);
         comando.Parameters.AddWithValue("@ColorStyle", colores.CodigoColor);
         comando.Parameters.AddWithValue("@ColorDesc", colores.DescripcionColor);
         comando.ExecuteNonQuery();
     }
     finally
     {
         conn.CerrarConexion();
         conn.Dispose();
     }
 }