Example #1
0
        public static ResTypeAttribute GetById(string id)
        {
            ResTypeAttribute attribute = new ResTypeAttribute();

            using (pm2Entities entities = new pm2Entities())
            {
                var type = (from a in entities.Res_Attribute
                            where a.AttributeId == id
                            select new { AttributeId = a.AttributeId, AttributeName = a.AttributeName, InputUser = a.InputUser, InputDate = a.InputDate, ResourceTypeId = a.Res_ResourceType.ResourceTypeId }).FirstOrDefault();
                if (type != null)
                {
                    attribute.Id        = id;
                    attribute.Name      = type.AttributeName;
                    attribute.InputUser = type.InputUser;
                    attribute.InputDate = type.InputDate;
                    ResType byId = ResType.GetById(type.ResourceTypeId);
                    attribute.ResourceType = byId;
                    return(attribute);
                }
                return(null);
            }
        }
Example #2
0
        public static List <ConstructResource> GetByConsTask(string consTaskId, string TaskId)
        {
            List <ConstructResource> list = new List <ConstructResource>();

            using (pm2Entities entities = new pm2Entities())
            {
                using (var enumerator = (from m in entities.Bud_ConsTaskRes
                                         where m.Bud_ConsTask.ConsTaskId == consTaskId
                                         select new { ConsTaskResId = m.ConsTaskResId, ResourceId = m.Res_Resource.ResourceId, Quantity = m.Quantity, UnitPrice = m.UnitPrice, AccountingQuantity = m.AccountingQuantity, ResourceTypeId = m.Res_Resource.Res_ResourceType.ResourceTypeId, CBSCode = m.CBSCode }).ToList().GetEnumerator())
                {
                    var bud_consRes;
                    while (enumerator.MoveNext())
                    {
                        bud_consRes = enumerator.Current;
                        ConstructResource item = null;
                        if (bud_consRes != null)
                        {
                            item = new ConstructResource {
                                Id                 = bud_consRes.ConsTaskResId,
                                ResourceId         = bud_consRes.ResourceId,
                                Quantity           = bud_consRes.Quantity,
                                UnitPrice          = bud_consRes.UnitPrice,
                                ConsTaskId         = consTaskId,
                                AccountingQuantity = bud_consRes.AccountingQuantity
                            };
                        }
                        Bud_TaskResource resource3 = (from btr in entities.Bud_TaskResource
                                                      where (btr.Bud_Task.TaskId == TaskId) && (btr.Res_Resource.ResourceId == bud_consRes.ResourceId)
                                                      select btr).FirstOrDefault <Bud_TaskResource>();
                        if (resource3 != null)
                        {
                            item.BudQuantity = Convert.ToDecimal(resource3.ResourceQuantity);
                        }
                        else
                        {
                            item.BudQuantity = 0M;
                        }
                        if (bud_consRes.CBSCode != null)
                        {
                            item.CBScode = bud_consRes.CBSCode;
                        }
                        else
                        {
                            ResType byId = ResType.GetById(cn.justwin.Domain.Resource.GetFirstResourceTypeId(bud_consRes.ResourceTypeId));
                            if (byId != null)
                            {
                                if (!string.IsNullOrEmpty(byId.CBSCode))
                                {
                                    item.CBScode = byId.CBSCode;
                                }
                                else
                                {
                                    item.CBScode = string.Empty;
                                }
                            }
                            else
                            {
                                item.CBScode = string.Empty;
                            }
                        }
                        list.Add(item);
                    }
                }
            }
            return(list);
        }