//Muestra la lista de Items public IEnumerable <ItemDescripcion> ListaItems() { Conexion conn = new Conexion(); List <ItemDescripcion> listItems = new List <ItemDescripcion>(); try { SqlCommand comando = new SqlCommand(); SqlDataReader leerFilas = null; comando.Connection = conn.AbrirConexion(); comando.CommandText = "Listar_Item_Desc"; comando.CommandType = CommandType.StoredProcedure; leerFilas = comando.ExecuteReader(); while (leerFilas.Read()) { ItemDescripcion items = new ItemDescripcion(); items.ItemId = Convert.ToInt32(leerFilas["ITEM_ID"]); items.ItemEstilo = leerFilas["ITEM_STYLE"].ToString().TrimEnd(); items.Descripcion = leerFilas["DESCRIPTION"].ToString().TrimEnd(); listItems.Add(items); } leerFilas.Close(); } finally { conn.CerrarConexion(); conn.Dispose(); } return(listItems); }
//Permite consultar los detalles de un Item Desc public ItemDescripcion ConsultarListaItemDesc(int?id) { Conexion conex = new Conexion(); ItemDescripcion itemDesc = new ItemDescripcion(); try { SqlCommand coma = new SqlCommand(); SqlDataReader leer = null; coma.Connection = conex.AbrirConexion(); coma.CommandText = "Listar_EstiloDesc_Por_Id"; coma.CommandType = CommandType.StoredProcedure; coma.Parameters.AddWithValue("@Id", id); leer = coma.ExecuteReader(); while (leer.Read()) { string descripcion = leer["DESCRIPTION"].ToString(); itemDesc.ItemId = Convert.ToInt32(leer["ITEM_ID"]); itemDesc.ItemEstilo = leer["ITEM_STYLE"].ToString().TrimEnd(); itemDesc.Descripcion = descripcion.TrimEnd(' '); } } finally { conex.CerrarConexion(); conex.Dispose(); } return(itemDesc); }
//Permite crear un nuevo Item descripcion public void AgregarItemDescripcion(ItemDescripcion itemDesc) { comando.Connection = conn.AbrirConexion(); comando.CommandText = "Agregar_Item_Desc"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Style", itemDesc.ItemEstilo); comando.Parameters.AddWithValue("@Descripcion", itemDesc.Descripcion); comando.ExecuteNonQuery(); conn.CerrarConexion(); }
//Permite actualiza la informacion de un estilo public void ActualizarItemDesc(ItemDescripcion itemDesc) { Conexion conn = new Conexion(); try { SqlCommand comando = new SqlCommand(); comando.Connection = conn.AbrirConexion(); comando.CommandText = "Actualizar_Items_Desc"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Id", itemDesc.ItemId); comando.Parameters.AddWithValue("@Item", itemDesc.ItemEstilo); comando.Parameters.AddWithValue("@ItemDesc", itemDesc.Descripcion); comando.ExecuteNonQuery(); } finally { conn.CerrarConexion(); conn.Dispose(); } }