internal static List <Venta> GetLista() { List <Venta> listaVenta = new List <Venta>(); using (SqlConnection cnn = ConexionBD.GetConexion()) { cnn.Open(); string strComando = "SELECT * FROM Ventas ORDER BY Fecha desc "; SqlCommand comando = new SqlCommand(strComando, cnn); using (SqlDataReader reader = comando.ExecuteReader()) { while (reader.Read()) { Venta obj = new Venta(); obj.IdVenta = reader.GetInt32(0); obj.idProducto = ProductosBD.GetString(reader.GetInt32(1)); obj.Cantidad = reader.GetInt32(2); obj.Fecha = reader.GetDateTime(3); obj.Importe = reader.GetDecimal(4); listaVenta.Add(obj); } } } return(listaVenta); }
internal static void CargarCombo(ref ComboBox cboProducto) { List <Producto> lista = ProductosBD.GetLista(); Producto prod = new Producto() { DescripcionProducto = "<Seleccione un producto>" }; lista.Insert(0, prod); cboProducto.DataSource = lista; cboProducto.DisplayMember = "DescripcionProducto"; cboProducto.ValueMember = "IdProducto"; }