Example #1
0
 private void AddToIndirectBudget(string cbsCode, string inputUser)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         foreach (System.Linq.IGrouping <string, string> grouping in (from m in entities.Bud_IndirectBudget
                                                                      select m.ProjectId into prjId
                                                                      group prjId by prjId).ToList <System.Linq.IGrouping <string, string> >())
         {
             string         key            = grouping.Key;
             IndirectBudget indirectBudget = IndirectBudget.Create(Guid.NewGuid().ToString(), key, cbsCode, 0M, 0M, inputUser, DateTime.Now, string.Empty);
             indirectBudget.Add(indirectBudget);
         }
     }
 }
Example #2
0
 public void Update(IndirectBudget indirectBudget)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_IndirectBudget budget = (from m in entities.Bud_IndirectBudget
                                      where (m.ProjectId == indirectBudget.ProjectId) && (m.CBSCode == indirectBudget.CBSCode)
                                      select m).FirstOrDefault <Bud_IndirectBudget>();
         if (budget == null)
         {
             throw new Exception("此项目的间接成本预算不存在!");
         }
         budget.BudgetAmount  = indirectBudget.BudgetAmount;
         budget.AccountAmount = indirectBudget.AccountAmount;
         budget.State         = indirectBudget.State;
         entities.SaveChanges();
     }
 }
Example #3
0
 public void Add(IndirectBudget indirectBudget)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_IndirectBudget budget = new Bud_IndirectBudget {
             Id            = indirectBudget.Id,
             BudgetAmount  = indirectBudget.BudgetAmount,
             AccountAmount = indirectBudget.AccountAmount,
             CBSCode       = indirectBudget.CBSCode,
             ProjectId     = indirectBudget.ProjectId,
             State         = indirectBudget.State,
             Note          = indirectBudget.Note,
             InputUser     = indirectBudget.InputUser,
             InputDate     = this.InputDate
         };
         entities.AddToBud_IndirectBudget(budget);
         entities.SaveChanges();
     }
 }
Example #4
0
        public static bool Del(List <string> ids)
        {
            bool           flag       = false;
            CostAccounting accounting = new CostAccounting();

            if (accounting.IsDelAll(ids))
            {
                using (pm2Entities entities = new pm2Entities())
                {
                    using (List <string> .Enumerator enumerator = ids.GetEnumerator())
                    {
                        string id;
                        while (enumerator.MoveNext())
                        {
                            id = enumerator.Current;
                            Bud_CostAccounting entity = (from m in entities.Bud_CostAccounting
                                                         where (m.Id == id) && (m.CBSCode.Length >= 6)
                                                         select m).FirstOrDefault <Bud_CostAccounting>();
                            if (entity != null)
                            {
                                bool   flag3   = true;
                                string cBSCode = entity.CBSCode;
                                if (entity.Type == "D")
                                {
                                    flag3 = ConstructResource.IsExistCBSCode(cBSCode);
                                }
                                else
                                {
                                    flag3 = IndirectBudget.IsExistCBSCode(cBSCode) || OrganizationBudget.IsExistCBSCode(cBSCode);
                                }
                                if (!flag3)
                                {
                                    entities.DeleteObject(entity);
                                    entities.SaveChanges();
                                    flag = true;
                                }
                            }
                        }
                    }
                }
            }
            return(flag);
        }
Example #5
0
        protected bool IsDelAll(List <string> ids)
        {
            bool flag = true;

            using (pm2Entities entities = new pm2Entities())
            {
                using (List <string> .Enumerator enumerator = ids.GetEnumerator())
                {
                    string id;
                    while (enumerator.MoveNext())
                    {
                        id = enumerator.Current;
                        Bud_CostAccounting accounting = (from m in entities.Bud_CostAccounting
                                                         where (m.Id == id) && (m.CBSCode.Length >= 6)
                                                         select m).FirstOrDefault <Bud_CostAccounting>();
                        if (accounting != null)
                        {
                            bool   flag2   = true;
                            string cBSCode = accounting.CBSCode;
                            if (accounting.Type == "D")
                            {
                                flag2 = ConstructResource.IsExistCBSCode(cBSCode);
                            }
                            else
                            {
                                flag2 = IndirectBudget.IsExistCBSCode(cBSCode) || OrganizationBudget.IsExistCBSCode(cBSCode);
                            }
                            if (flag2)
                            {
                                return(false);
                            }
                        }
                    }
                    return(flag);
                }
            }
        }
Example #6
0
 public void CommitEvent(object key)
 {
     IndirectBudget.SwapData(key.ToString(), "1");
 }
Example #7
0
 public void SuperDelete(object key)
 {
     IndirectBudget.SwapData(key.ToString(), "2");
 }