private Venta parse(List <Object> unRegistro) { int idVenta = (int)unRegistro.ElementAt(0); DateTime fechaVenta = DateTime.Parse(unRegistro.ElementAt(1).ToString()); double iva = Convert.ToDouble(unRegistro.ElementAt(2)); double importeTotal = Convert.ToDouble(unRegistro.ElementAt(3)); int idCliente = (int)unRegistro.ElementAt(4); int idEmpleado = (int)unRegistro.ElementAt(5); int idPedido = (int)unRegistro.ElementAt(6); Venta nuevaVenta = new Venta(); nuevaVenta.IdVenta = idVenta; nuevaVenta.fechaDeVenta = fechaVenta; nuevaVenta.iva = iva; IClienteDAO clienteDao = new ClienteDaoImpl(); nuevaVenta.agregarCliente(clienteDao.leerPorId(idCliente)); IEmpleadoDAO emleadoDao = new EmpleadoDaoImpl(); nuevaVenta.agregarEmpleado(emleadoDao.leerPorId(idEmpleado)); IPedidoDao pedidoDao = new PedidoDaoImpl(); Pedido pedidoRegistrado = pedidoDao.leerPorId(idPedido); nuevaVenta.pedido = pedidoRegistrado; nuevaVenta.materialesNecesarios = pedidoRegistrado.ListaDeMateriales; nuevaVenta.costosExtras = pedidoRegistrado.costosExtras; IProductoDao productoDao = new ProductoDaoImpl(); //agregar lineas de venta foreach (LineaPedido lineaPedido in pedidoRegistrado.lineasDePedido) { int idLineaVenta = 1; int cantidadVenta = lineaPedido.cantidad; Producto producto = productoDao.leerPorId(lineaPedido.producto.IdProducto); LineaVenta lineaVenta = new LineaVenta(cantidadVenta, producto); nuevaVenta.lineasDeVenta.Add(lineaVenta); } //agregar listaMateriales nuevaVenta.materialesNecesarios = pedidoRegistrado.ListaDeMateriales; //agregar listaCostos nuevaVenta.costosExtras = pedidoRegistrado.costosExtras; return(nuevaVenta); }
public void eliminar(int id) { int idProducto = leerPorId(id).producto.IdProducto; string query = string.Format("delete from linea_pedido where id_linea_pedido = {0}", id); db.borrarRegistro(query); IProductoDao productoDao = new ProductoDaoImpl(); productoDao.eliminar(idProducto); }
public void actualizar(LineaPedido t) { IProductoDao productoDao = new ProductoDaoImpl(); productoDao.actualizar(t.producto); string query = string.Format("update linea_pedido set descripcion = \'{0}\', cantidad={1}, pedido_id_pedido={2}, producto_id_producto={3} where id_linea_pedido = {4};", t.producto.descripcion, t.cantidad, t.IdPedido, t.producto.IdProducto, t.IdLineaPedido); db.ejectuarQuery(query); }
public void registrar(LineaPedido t) { IProductoDao productoDao = new ProductoDaoImpl(); productoDao.registrar(t.producto); int idProducto = productoDao.listarTodos().Last().IdProducto; string query = string.Format("insert into linea_pedido (descripcion, cantidad, pedido_id_pedido, producto_id_producto) values (\'{0}\', {1},{2},{3});", t.producto.descripcion, t.cantidad, t.IdPedido, idProducto); db.ejectuarQuery(query); }
private LineaPedido parse(List <Object> unRegistro) { int idLineaPedido = (int)unRegistro.ElementAt(0); string descripcion = (string)unRegistro.ElementAt(1); int cantidad = (int)unRegistro.ElementAt(2); int idPedido = (int)unRegistro.ElementAt(3); int idProducto = (int)unRegistro.ElementAt(4); IProductoDao productoDao = new ProductoDaoImpl(); LineaPedido linea = new LineaPedido(); linea.IdLineaPedido = idLineaPedido; linea.cantidad = cantidad; linea.IdPedido = idPedido; linea.producto = productoDao.leerPorId(idProducto); return(linea); }