Example #1
0
        /// <summary>
        /// 增加子节点
        /// </summary>
        /// <param name="child">子节点对象</param>
        public S_C_CBS_Budget AddChild(S_C_CBS_Budget child)
        {
            var user     = FormulaHelper.GetUserInfo();
            var entities = this.GetDbContext <ProjectEntities>();

            if (entities.Entry <S_C_CBS_Budget>(child).State != System.Data.EntityState.Added &&
                entities.Entry <S_C_CBS_Budget>(child).State != System.Data.EntityState.Detached)
            {
                throw new Formula.Exceptions.BusinessException("非新增状态的CBS对象,无法调用AddChild方法");
            }
            if (String.IsNullOrEmpty(child.ID))
            {
                child.ID = FormulaHelper.CreateGuid();
            }
            child.ParentID      = this.ID;
            child.FullID        = this.FullID + "." + child.ID;
            child.ProjectInfoID = this.ProjectInfoID;
            child.S_C_CBS       = this.S_C_CBS;
            child.CBSID         = this.S_C_CBS.ID;
            child.CBSFullID     = this.S_C_CBS.FullID;

            if (child.UnitPrice == null)
            {
                child.UnitPrice = this.UnitPrice;
            }
            if (child.Quantity == null)
            {
                child.Quantity = this.Quantity;
            }
            if (child.TotalValue == null)
            {
                if (child.Quantity.HasValue && child.UnitPrice.HasValue)
                {
                    child.TotalValue = child.Quantity.Value * child.UnitPrice.Value;
                }
            }

            this.S_C_CBS.S_C_CBS_Budget.Add(child);
            this.Children.Add(child);
            this.AllChildren.Add(child);
            return(child);
        }
Example #2
0
        /// <summary>
        /// 增加卷册
        /// </summary>
        /// <param name="budget"></param>
        /// <returns></returns>
        public S_C_CBS_Budget AddBudget(S_C_CBS_Budget budget)
        {
            var entities = this.GetDbContext <ProjectEntities>();

            if (entities.Entry <S_C_CBS_Budget>(budget).State != System.Data.EntityState.Added &&
                entities.Entry <S_C_CBS_Budget>(budget).State != System.Data.EntityState.Detached)
            {
                throw new Formula.Exceptions.BusinessException("非新增状态的S_C_CBS_Budget对象,无法调用AddBudget方法");
            }
            if (String.IsNullOrEmpty(budget.ID))
            {
                budget.ID = FormulaHelper.CreateGuid();
            }
            budget.ProjectInfoID = this.ProjectInfoID;
            budget.CBSFullID     = this.FullID;
            budget.CBSID         = this.ID;
            budget.S_C_CBS       = this;
            if (string.IsNullOrEmpty(budget.ParentID))
            {
                budget.ParentID = string.Empty;
                budget.FullID   = budget.ID;
            }
            if (budget.UnitPrice == null)
            {
                budget.UnitPrice = this.UnitPrice;
            }
            if (budget.Quantity == null)
            {
                budget.Quantity = this.Quantity;
            }
            if (budget.TotalValue == null)
            {
                if (budget.Quantity.HasValue && budget.UnitPrice.HasValue)
                {
                    budget.TotalValue = budget.Quantity.Value * budget.UnitPrice.Value;
                }
            }
            this.S_C_CBS_Budget.Add(budget);
            entities.S_C_CBS_Budget.Add(budget);
            return(budget);
        }