private LineasLotes GetModeloSalida(string lote, int?loteid) { LineasLotes result = null; var salidaObj = _db.AlbaranesLin.Include("Albaranes").FirstOrDefault(f => f.lote == lote && f.tabla == loteid && f.empresa == _context.Empresa); if (salidaObj != null) { result = new LineasLotes { Cuenta = salidaObj.Albaranes.fkclientes, Fecha = salidaObj.Albaranes.fechadocumento, Precio = salidaObj.importe, Referencia = salidaObj.Albaranes.referencia, Codigodocumento = salidaObj.Albaranes.id.ToString(), Largo = salidaObj.largo, Ancho = salidaObj.ancho, Grueso = salidaObj.grueso, Metros = salidaObj.metros }; var sumacantidad = _db.AlbaranesLin.Where(f => f.lote == lote && f.tabla == loteid && f.empresa == _context.Empresa).Sum(f => f.cantidad); result.Cantidad = sumacantidad; } else { var transformacionObj = _db.Transformacionessalidalin.Include("Transformaciones").FirstOrDefault(f => f.lote == lote && f.tabla == loteid && f.empresa == _context.Empresa); if (transformacionObj != null) { result = new LineasLotes { Cuenta = transformacionObj.Transformaciones.fkproveedores, Fecha = transformacionObj.Transformaciones.fechadocumento, Precio = 0, Referencia = transformacionObj.Transformaciones.referencia, Codigodocumento = transformacionObj.Transformaciones.id.ToString(), Cantidad = transformacionObj.cantidad, Largo = transformacionObj.largo, Ancho = transformacionObj.ancho, Grueso = transformacionObj.grueso, Metros = transformacionObj.metros }; } } return(result); }
private LineasLotes GetModeloEntrada(string lote, int?loteid) { LineasLotes result = null; var entradaObj = _db.AlbaranesComprasLin.Include("AlbaranesCompras").FirstOrDefault(f => f.lote == lote && f.tabla == loteid && f.empresa == _context.Empresa); if (entradaObj != null) { result = new LineasLotes { Cuenta = entradaObj.AlbaranesCompras.fkproveedores, Fecha = entradaObj.AlbaranesCompras.fechadocumento, Precio = entradaObj.importe, Referencia = entradaObj.AlbaranesCompras.referencia, Codigodocumento = entradaObj.AlbaranesCompras.id.ToString(), Cantidad = entradaObj.cantidad, Largo = entradaObj.largo, Ancho = entradaObj.ancho, Grueso = entradaObj.grueso, Metros = entradaObj.metros //Preciovaloracion = entradaObj.preciovaloracion }; } else { var transformacionObj = _db.Transformacionesentradalin.Include("Transformaciones").FirstOrDefault(f => f.lote == lote && f.tabla == loteid && f.empresa == _context.Empresa); if (transformacionObj != null) { result = new LineasLotes { Cuenta = transformacionObj.Transformaciones.fkproveedores, Fecha = transformacionObj.Transformaciones.fechadocumento, Precio = transformacionObj.precio, Referencia = transformacionObj.Transformaciones.referencia, Codigodocumento = transformacionObj.Transformaciones.id.ToString(), Cantidad = transformacionObj.cantidad, Largo = transformacionObj.largo, Ancho = transformacionObj.ancho, Grueso = transformacionObj.grueso, Metros = transformacionObj.metros }; } } return(result); }