private Liquidacion parse(List <Object> unRegistro) { int idLiquidacion = (int)unRegistro.ElementAt(0); int periodo = (int)unRegistro.ElementAt(1); String lugarPago = (String)unRegistro.ElementAt(2); double total = Convert.ToDouble(unRegistro.ElementAt(3)); int idEmpleado = (int)unRegistro.ElementAt(4); IEmpleadoDAO empleadoDao = new EmpleadoDaoImpl(); Empleado empleado = empleadoDao.leerPorId(idEmpleado); Liquidacion liquidacion = new Liquidacion(empleado, periodo, lugarPago); liquidacion.IdLiquidacion = idLiquidacion; ILineaLiquidacionDao lineaLiquidacionDao = new LineaLiquidacionDaoImpl(); foreach (LineaLiquidacion linea in lineaLiquidacionDao.listarTodos()) { if (linea.idLiquidacion == liquidacion.IdLiquidacion) { liquidacion.LineasLiquidacion.Add(linea); } } return(liquidacion); }
private Compra parse(List <Object> unRegistro) { int idCompra = (int)unRegistro.ElementAt(0); DateTime fechaCompra = (DateTime)unRegistro.ElementAt(1); double total = Convert.ToDouble(unRegistro.ElementAt(2)); EstadoCompra estado; Enum.TryParse <EstadoCompra>(unRegistro.ElementAt(3).ToString(), true, out estado); int idProveedor = (int)unRegistro.ElementAt(4); IProveedorDAO proveedorDAO = new ProveedorDaoImpl(); Proveedor proveedor = proveedorDAO.leerPorId(idProveedor); int idEmpleado = (int)unRegistro.ElementAt(5); IEmpleadoDAO empleadoDao = new EmpleadoDaoImpl(); Empleado empleado = empleadoDao.leerPorId(idEmpleado); Compra compra = new Compra(); compra.IdCompra = idCompra; compra.fechaCompra = fechaCompra; compra.estado = estado; compra.agregarEmpleado(empleado); compra.agregarProveedor(proveedor); //falta agregar las lineas de compra. ILineaCompraDao lineaCompraDao = new LineaCompraDaoImpl(); List <LineaCompra> lineasComprasRegistradasParaUnaVenta = new List <LineaCompra>(); foreach (LineaCompra lc in lineaCompraDao.listarTodos()) { if (lc.IdCompra == compra.IdCompra) { LineaCompra lineaCompra = new LineaCompra(); lineaCompra.material = lc.material; lineaCompra.cantidad = lc.cantidad; lineaCompra.IdLineaCompra = lc.IdLineaCompra; lineaCompra.IdCompra = lc.IdCompra; lineasComprasRegistradasParaUnaVenta.Add(lineaCompra); Console.WriteLine(lineaCompra.IdLineaCompra); } } compra.lineasDeCompra = lineasComprasRegistradasParaUnaVenta; //Console.WriteLine(compra.lineasDeCompra.Last().material.Descripcion); return(compra); }
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); }