public Factura[] ProcesarLineas(string[] lineas) { string[] temp; string[] nombres, precios; Factura[] facturas = new Factura[lineas.Length]; //Peniente hacer refactoring for (int i = 1; i < lineas.Length; i++) //Empezamos en 1 para saltarnos el encabezado de la tabla { temp = Utilitario.SepararCadena(lineas[i], SEPARADOR_REGISTROS); //temp[0] Fecha nombres = ProcesarRegistro(temp[1], SEPARADOR_NOMBRES); precios = ProcesarRegistro(temp[2], SEPARADOR_PRECIOS); Debug.Log(i + " " + nombres.Length); facturas[i] = new Factura(nombres.Length); facturas[i].AgregarProductos(nombres, precios); facturas[i].Numero_factura = Utilitario.ConvertirEntero(temp[5]); //temp[3] Medio de pago //temp[4] Estado actual //temp[5] Numero factura } return(facturas); }
public void AgregarProductos(string[] nombres, string[] precios) { float precio; int cantidad; string[] precio_cantidad; for (int i = 0; i < nombres.Length; i++) { precio_cantidad = Utilitario.SepararCadena(precios[i], LectorArchivo.SEPARADOR_CANTIDAD); precio = Utilitario.ConvertirFlotante(precio_cantidad[0]); cantidad = Utilitario.ConvertirEntero(precio_cantidad[1]); if (precio > 0 && cantidad > 0) { AgregarProducto(nombres[i], precio, cantidad); } else { Console.WriteLine("Error al leer el dato:" + nombres[i]);//Cambiar por una exepcion } } }