コード例 #1
0
ファイル: ConstructTask.cs プロジェクト: zxl881203/src
 public static void AddResource(ConstructTask consTask)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         IList <ConstructResource> resourceList = new List <ConstructResource>();
         resourceList = consTask.ResourceList;
         DelByConsTaskId(consTask.Id, entities);
         using (IEnumerator <ConstructResource> enumerator = resourceList.GetEnumerator())
         {
             ConstructResource consResource;
             while (enumerator.MoveNext())
             {
                 consResource = enumerator.Current;
                 Bud_ConsTaskRes res = new Bud_ConsTaskRes {
                     ConsTaskResId      = consResource.Id,
                     Bud_ConsTask       = entities.Bud_ConsTask.FirstOrDefault <Bud_ConsTask>(c => c.ConsTaskId == consResource.ConsTaskId),
                     Res_Resource       = entities.Res_Resource.FirstOrDefault <Res_Resource>(c => c.ResourceId == consResource.ResourceId),
                     Quantity           = consResource.Quantity,
                     UnitPrice          = consResource.UnitPrice,
                     AccountingQuantity = new decimal?(consResource.Quantity)
                 };
                 entities.AddToBud_ConsTaskRes(res);
             }
         }
         entities.SaveChanges();
     }
 }
コード例 #2
0
ファイル: ConstructResource.cs プロジェクト: zxl881203/src
 public static void Del(string id)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_ConsTaskRes entity = (from m in entities.Bud_ConsTaskRes
                                   where m.ConsTaskResId == id
                                   select m).FirstOrDefault <Bud_ConsTaskRes>();
         if (entity == null)
         {
             throw new Exception("已删除不存在!");
         }
         entities.DeleteObject(entity);
         entities.SaveChanges();
     }
 }
コード例 #3
0
ファイル: ConstructResource.cs プロジェクト: zxl881203/src
 public static void UpdateAccountingQuantityCBSCode(string consTaskResId, decimal accountingQuantity, string CBSCode)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_ConsTaskRes res = (from m in entities.Bud_ConsTaskRes
                                where m.ConsTaskResId == consTaskResId
                                select m).FirstOrDefault <Bud_ConsTaskRes>();
         if (res != null)
         {
             res.AccountingQuantity = new decimal?(accountingQuantity);
             res.CBSCode            = CBSCode;
             entities.SaveChanges();
         }
     }
 }
コード例 #4
0
ファイル: ConstructResource.cs プロジェクト: zxl881203/src
        public static List <ConstructResource> GetAll(string consTaskId, List <string> resourceIds)
        {
            List <ConstructResource> list = new List <ConstructResource>();

            using (pm2Entities entities = new pm2Entities())
            {
                using (List <string> .Enumerator enumerator = resourceIds.GetEnumerator())
                {
                    string resourceId;
                    while (enumerator.MoveNext())
                    {
                        resourceId = enumerator.Current;
                        Bud_ConsTaskRes res = (from m in entities.Bud_ConsTaskRes
                                               where (m.Bud_ConsTask.ConsTaskId == consTaskId) && (m.Res_Resource.ResourceId == resourceId)
                                               select m).FirstOrDefault <Bud_ConsTaskRes>();
                        ConstructResource item = null;
                        if (res != null)
                        {
                            item = new ConstructResource {
                                ResourceId = resourceId,
                                Quantity   = res.Quantity,
                                UnitPrice  = res.UnitPrice,
                                ConsTaskId = consTaskId
                            };
                        }
                        else
                        {
                            item = new ConstructResource {
                                ResourceId = resourceId,
                                Quantity   = 0M,
                                UnitPrice  = 0M,
                                ConsTaskId = consTaskId
                            };
                        }
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
コード例 #5
0
ファイル: ConstructResource.cs プロジェクト: zxl881203/src
 public static void Update(List <ConstructResource> consResList)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         using (List <ConstructResource> .Enumerator enumerator = consResList.GetEnumerator())
         {
             ConstructResource cr;
             while (enumerator.MoveNext())
             {
                 cr = enumerator.Current;
                 Bud_ConsTaskRes res = (from m in entities.Bud_ConsTaskRes
                                        where m.ConsTaskResId == cr.Id
                                        select m).FirstOrDefault <Bud_ConsTaskRes>();
                 if (res == null)
                 {
                     throw new Exception("要修改的记录不存在!");
                 }
                 res.AccountingQuantity = cr.AccountingQuantity;
                 res.CBSCode            = cr.CBScode;
             }
         }
         entities.SaveChanges();
     }
 }
コード例 #6
0
ファイル: ConstructResource.cs プロジェクト: zxl881203/src
 public void Add(ConstructResource consRes)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Res_Resource resource = (from m in entities.Res_Resource
                                  where m.ResourceId == consRes.ResourceId
                                  select m).FirstOrDefault <Res_Resource>();
         Bud_ConsTask task = (from m in entities.Bud_ConsTask
                              where m.ConsTaskId == consRes.ConsTaskId
                              select m).FirstOrDefault <Bud_ConsTask>();
         if ((resource != null) && (task != null))
         {
             Bud_ConsTaskRes res = new Bud_ConsTaskRes {
                 ConsTaskResId = consRes.Id,
                 Quantity      = consRes.Quantity,
                 Bud_ConsTask  = task,
                 Res_Resource  = resource,
                 UnitPrice     = consRes.UnitPrice
             };
             entities.AddToBud_ConsTaskRes(res);
             entities.SaveChanges();
         }
     }
 }
コード例 #7
0
ファイル: ConstructTask.cs プロジェクト: zxl881203/src
        public void SetResQuantityByConsQuantity(decimal quantity)
        {
            cn.justwin.Domain.BudTask byId = cn.justwin.Domain.BudTask.GetById(this.taskId);
            decimal num = 0M;

            if (byId == null)
            {
                BudModifyTask task2 = this.budModifyTaskSer.GetById(this.taskId);
                if ((task2 != null) && (task2.Quantity != 0M))
                {
                    num = quantity / task2.Quantity;
                }
            }
            else if (byId.Quantity != 0M)
            {
                num = quantity / byId.Quantity;
            }
            using (pm2Entities entities = new pm2Entities())
            {
                List <BudModifyTaskRes> first = (from mt in this.budModifyTaskSer
                                                 join m in this.budModifySer on mt.ModifyId equals m.ModifyId into m
                                                 join mtr in this.budModifyTaskResSer on mt.ModifyTaskId equals mtr.ModifyTaskId into mtr
                                                 where (mt.TaskId == this.taskId) && (m.Flowstate == 1)
                                                 select mtr).ToList <BudModifyTaskRes>();
                List <BudModifyTaskRes> second = (from mt in this.budModifyTaskSer
                                                  join m in this.budModifySer on mt.ModifyId equals m.ModifyId into m
                                                  join mtr in this.budModifyTaskResSer on mt.ModifyTaskId equals mtr.ModifyTaskId into mtr
                                                  where (mt.ModifyTaskId == this.taskId) && (m.Flowstate == 1)
                                                  select mtr).ToList <BudModifyTaskRes>();
                first = first.Union <BudModifyTaskRes>(second).ToList <BudModifyTaskRes>();
                if (byId != null)
                {
                    using (IEnumerator <TaskResource> enumerator = byId.Resources.GetEnumerator())
                    {
                        System.Func <BudModifyTaskRes, bool> predicate = null;
                        TaskResource item;
                        while (enumerator.MoveNext())
                        {
                            item = enumerator.Current;
                            decimal num2 = 0M;
                            num2 = item.Quantity;
                            if (predicate == null)
                            {
                                predicate = list => list.ResourceId == item.Resource.Id;
                            }
                            foreach (BudModifyTaskRes res in first.Where <BudModifyTaskRes>(predicate).ToList <BudModifyTaskRes>())
                            {
                                if (item != null)
                                {
                                    num2 += res.ResourceQuantity;
                                    first.Remove(res);
                                }
                            }
                            for (int i = 0; i < this.ResourceList.Count; i++)
                            {
                                string resourceId = this.resourceList[i].ResourceId;
                                if (resourceId == item.Resource.Id)
                                {
                                    Bud_ConsTaskRes res2 = (from ctr in entities.Bud_ConsTaskRes
                                                            where (ctr.Res_Resource.ResourceId == resourceId) && (ctr.Bud_ConsTask.ConsTaskId == this.Id)
                                                            select ctr).FirstOrDefault <Bud_ConsTaskRes>();
                                    if (res2 != null)
                                    {
                                        if (num > 1M)
                                        {
                                            res2.Quantity           = num2;
                                            res2.AccountingQuantity = new decimal?(num2);
                                        }
                                        else
                                        {
                                            res2.Quantity           = num * num2;
                                            res2.AccountingQuantity = new decimal?(num * num2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                using (List <string> .Enumerator enumerator3 = this.budModifyTaskResSer.GetModifyTasResIds(first).GetEnumerator())
                {
                    System.Func <BudModifyTaskRes, bool> func2 = null;
                    string resId;
                    while (enumerator3.MoveNext())
                    {
                        resId = enumerator3.Current;
                        decimal num4 = 0M;
                        if (func2 == null)
                        {
                            func2 = list => list.ResourceId == resId;
                        }
                        foreach (BudModifyTaskRes res3 in first.Where <BudModifyTaskRes>(func2).ToList <BudModifyTaskRes>())
                        {
                            num4 += res3.ResourceQuantity;
                            first.Remove(res3);
                        }
                        for (int j = 0; j < this.ResourceList.Count; j++)
                        {
                            string resourceId = this.resourceList[j].ResourceId;
                            if (resourceId == resId)
                            {
                                Bud_ConsTaskRes res4 = (from ctr in entities.Bud_ConsTaskRes
                                                        where (ctr.Res_Resource.ResourceId == resourceId) && (ctr.Bud_ConsTask.ConsTaskId == this.Id)
                                                        select ctr).FirstOrDefault <Bud_ConsTaskRes>();
                                if (res4 != null)
                                {
                                    if (num > 1M)
                                    {
                                        res4.Quantity           = num4;
                                        res4.AccountingQuantity = new decimal?(num4);
                                    }
                                    else
                                    {
                                        res4.Quantity           = num * num4;
                                        res4.AccountingQuantity = new decimal?(num * num4);
                                    }
                                }
                            }
                        }
                    }
                }
                entities.SaveChanges();
            }
        }