public List<MaterialOP> ObtieneMateriales() { List<MaterialOP> lstMateriales = new List<MaterialOP>(); try { ObrasPublicasEntities objContext = new ObrasPublicasEntities(); var lstMaterialesTmp = objContext.OP_MATERIAL; foreach (var objMaterialTmp in lstMaterialesTmp) { MaterialOP objMaterialOP = new MaterialOP(); objMaterialOP.IdMaterial = objMaterialTmp.coMaterial; objMaterialOP.Nombre = objMaterialTmp.noMaterial; lstMateriales.Add(objMaterialOP); } } catch (Exception ex) { throw new Exception(ex.ToString()); } return lstMateriales; }
public EntregaMaterialOP ObtieneEntregaXId(int pIntIdProyecto, int pIntIdEntrega) { EntregaMaterialOP objEntregaMaterialOP = null; try { ObrasPublicasEntities objContext = new ObrasPublicasEntities(); var objResult = objContext.sp_gop_get_ent_mat_x_id(pIntIdProyecto,pIntIdEntrega).ToList(); List<sp_gop_get_ent_mat_x_id_Result> lstEntregaTmp = objResult; //var lstEntregasTmp = (from ent in objContext.OP_ENTREGA_MATERIAL // join prov in objContextIntegrado.MA_PROVEEDOR on ent.coProveedor equals prov.IdProveedor // join emp in objContextIntegrado.MA_PERSONAJURIDICA on prov.IdPersona equals emp.idPersona // join mat in objContext.OP_MATERIAL on ent.coMaterial equals mat.coMaterial // where( ent.coEntrega == pIntIdEntrega) // select new { ent, prov, emp, mat }).ToList(); //where(ent.coEntrega == pIntIdProyecto) if (lstEntregaTmp != null && lstEntregaTmp.Count() == 1) { foreach (var objEntregaTmp in lstEntregaTmp) { objEntregaMaterialOP = new EntregaMaterialOP(); objEntregaMaterialOP.IdEntrega = objEntregaTmp.coEntrega; ProyectoInversion objProyectoInversion = new ProyectoInversion(); if (objEntregaTmp.coProyecto.HasValue) { objProyectoInversion.IdProyecto = objEntregaTmp.coProyecto.Value; } objProyectoInversion.Nombre = objEntregaTmp.noNombre; objEntregaMaterialOP.Proyecto = objProyectoInversion; Proveedor objProveedor = new Proveedor(); objProveedor.IdProveedor = objEntregaTmp.coProveedor; objProveedor.RazonSocial = objEntregaTmp.RazonSocial; objEntregaMaterialOP.Proveedor = objProveedor; if (objEntregaTmp.nuCantidad.HasValue) { objEntregaMaterialOP.Cantidad = objEntregaTmp.nuCantidad.Value; } if (objEntregaTmp.feEntregaEfectiva.HasValue) { objEntregaMaterialOP.FecEntregaEfec = objEntregaTmp.feEntregaEfectiva.Value; } if (objEntregaTmp.feEntregaProgramada.HasValue) { objEntregaMaterialOP.FecEntregaProg = objEntregaTmp.feEntregaProgramada.Value; } MaterialOP objMaterial = new MaterialOP(); objMaterial.IdMaterial = objEntregaTmp.coMaterial; objMaterial.Nombre = objEntregaTmp.noMaterial; objEntregaMaterialOP.Material = objMaterial; objEntregaMaterialOP.Observaciones = objEntregaTmp.txObservaciones; objEntregaMaterialOP.TipoEntrega = objEntregaTmp.noTipoEntrega; break; } } } catch (Exception ex) { throw new Exception(ex.ToString()); } return objEntregaMaterialOP; }