public List <TODetallePedido> detallesDePedido(String idPedido) { qry = "SELECT * FROM DETALLE_PEDIDO where CODIGO_PEDIDO = @CP;"; comando = new SqlCommand(qry, conexion); comando.Parameters.AddWithValue("@CP", idPedido); List <TODetallePedido> lista = new List <TODetallePedido>(); conexion.Open(); SqlDataReader reader = comando.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { TODetallePedido pedidoD = new TODetallePedido(); pedidoD.CODIGO_PEDIDO = int.Parse(reader[0].ToString()); pedidoD.CODIGO_PLATO = int.Parse(reader[1].ToString()); pedidoD.CANTIDAD_PRODUCTO = int.Parse(reader[2].ToString()); TOPlato plato = new TOPlato(); plato.Codigo = pedidoD.CODIGO_PLATO; pedidoD.plato = new DAOPlato().buscarPlato(plato); lista.Add(pedidoD); } } conexion.Close(); return(lista); }
public TODetallePedido convert(BLDetallePedido BLPedidoD) { TODetallePedido pedidoD = new TODetallePedido(); pedidoD.CANTIDAD_PRODUCTO = BLPedidoD.CANTIDAD_PRODUCTO; pedidoD.CODIGO_PEDIDO = BLPedidoD.CODIGO_PEDIDO; pedidoD.CODIGO_PLATO = BLPedidoD.CODIGO_PLATO; pedidoD.plato = new ManejadorPlatos().convert(BLPedidoD.plato); return(pedidoD); }
public void InsertarDPedido(TODetallePedido pedidoD, String idPedido) { qry = "INSERT INTO DETALLE_PEDIDO(CODIGO_PEDIDO,CODIGO_PLATO,CANTIDAD_PRODUCTO) VALUES(@CP,@CPP,@CPR);"; comando = new SqlCommand(qry, conexion); comando.Parameters.AddWithValue("@CP", pedidoD.CODIGO_PEDIDO); comando.Parameters.AddWithValue("@CPP", pedidoD.CODIGO_PLATO); comando.Parameters.AddWithValue("@CPR", pedidoD.CANTIDAD_PRODUCTO); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); }