Example #1
0
        public static decimal GetTypePrice(string taskId, string priceType, string resourceTypeId)
        {
            System.Func <ResPrice, bool> predicate = null;
            decimal num = 0M;

            if (BudTask.GetById(taskId) != null)
            {
                foreach (TaskResource resource in BudTask.GetResourcesByTaskId(taskId))
                {
                    System.Func <ResPrice, bool> func = null;
                    string  resourceId = resource.Resource.Id;
                    decimal quantity   = resource.Quantity;
                    decimal num3       = resource.Price;
                    if (GetFirstResourceType(GetById(resourceId).ResourceType.Id) == resourceTypeId)
                    {
                        if (func == null)
                        {
                            func = m => m.ResourceId == resourceId;
                        }
                        if (predicate == null)
                        {
                            predicate = m => m.PriceTypeId == priceType;
                        }
                        List <ResPrice> list2 = ResPrice.GetAll().Where <ResPrice>(func).Where <ResPrice>(predicate).ToList <ResPrice>();
                        if (list2.Count > 0)
                        {
                            foreach (ResPrice price in list2)
                            {
                                num += price.PriceValue * quantity;
                            }
                        }
                        else
                        {
                            num += num3 * quantity;
                        }
                    }
                }
            }
            return(num);
        }
Example #2
0
 public static void GetResTypeTotal(string taskId, string priceType, DataTable dtrcj)
 {
     if (BudTask.GetById(taskId) != null)
     {
         foreach (TaskResource resource in BudTask.GetResourcesByTaskId(taskId))
         {
             string  resourceId        = resource.Resource.Id;
             decimal quantity          = resource.Quantity;
             decimal price             = resource.Price;
             string  firstResourceType = GetFirstResourceType(GetById(resourceId).ResourceType.Id);
             decimal num3 = 0M;
             if (string.IsNullOrEmpty(priceType))
             {
                 num3 = price * quantity;
             }
             else
             {
                 using (pm2Entities entities = new pm2Entities())
                 {
                     using (List <ResPrice> .Enumerator enumerator2 = (from m in entities.Res_Price
                                                                       where (m.ResourceId == resourceId) && (m.PriceTypeId == priceType)
                                                                       select new ResPrice {
                         PriceValue = m.PriceValue
                     }).ToList <ResPrice>().GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             ResPrice current = enumerator2.Current;
                             num3 = price * quantity;
                         }
                     }
                 }
             }
             object obj2 = dtrcj.Rows[0][firstResourceType];
             obj2 = (obj2 == null) ? 0 : obj2;
             dtrcj.Rows[0][firstResourceType] = Convert.ToInt32(obj2) + num3;
         }
     }
 }
Example #3
0
        public static IList <ResPrice> GetAll()
        {
            List <ResPrice> list = new List <ResPrice>();

            using (pm2Entities entities = new pm2Entities())
            {
                var list2 = (from m in entities.Res_Price select new { ResourceId = m.ResourceId, PriceValue = m.PriceValue, PriceTypeId = m.Res_PriceType.PriceTypeId }).ToList();
                if (list2.Count > 0)
                {
                    foreach (var typed in list2)
                    {
                        ResPrice item = new ResPrice {
                            ResourceId  = typed.ResourceId,
                            PriceValue  = typed.PriceValue,
                            PriceTypeId = typed.PriceTypeId
                        };
                        list.Add(item);
                    }
                    return(list);
                }
                return(null);
            }
        }