예제 #1
0
        public S_EP_CBSNode AddEmptyChild(String nodeType = "")
        {
            var child = new Dictionary <string, object>();

            child.SetValue("Name", "新建CBS节点");
            child.SetValue("ID", FormulaHelper.CreateGuid());
            child.SetValue("Code", child.GetValue("ID"));
            child.SetValue("FullCode", this.ModelDic.GetValue("FullCode") + "." + child.GetValue("Code"));
            child.SetValue("FullID", this.ModelDic.GetValue("FullID") + "." + child.GetValue("ID"));
            child.SetValue("ParentID", this.ModelDic.GetValue("ID"));
            child.SetValue("CBSInfoID", this.ModelDic.GetValue("CBSInfoID"));
            child.SetValue("DefineID", "");
            child.SetValue("ProjectInfoID", this.ModelDic.GetValue("ProjectInfoID"));
            child.SetValue("EngineeringInfoID", this.ModelDic.GetValue("EngineeringInfoID"));
            child.SetValue("ContractInfoID", this.ModelDic.GetValue("ContractInfoID"));
            child.SetValue("OrgID", this.ModelDic.GetValue("OrgID"));
            if (String.IsNullOrEmpty(nodeType))
            {
                nodeType = CBSNodeType.Subject.ToString();
            }
            child.SetValue("NodeType", nodeType);
            child.SetValue("CBSType", this.ModelDic.GetValue("CBSType"));
            var maxSortIndex = Convert.ToInt32(this.DB.ExecuteScalar("SELECT ISNULL(MAX(SortIndex),0) FROM S_EP_CBSNode WITH(NOLOCK) WHERE PARENTID='" + this.ModelDic.GetValue("ID") + "'"));
            var sortIndex    = maxSortIndex + 1;

            child.SetValue("SortIndex", sortIndex);
            child.InsertDB(this.DB, "S_EP_CBSNode", child.GetValue("ID"));
            var result = new S_EP_CBSNode(child);

            return(result);
        }
예제 #2
0
        public void AutoSplitProductionValue(string exceptNodeTypes, bool loopDeep = true)
        {
            var sql = @"select *,isnull(ProductionValue,0)-isnull(ProductionSettleValue,0) as RemainProductionValue
            from S_EP_CBSNode with(nolock) where ParentID='{0}' ";

            foreach (var item in exceptNodeTypes.Split(','))
            {
                sql += " and NodeType<>'" + item + "'";
            }
            var dt = this.DB.ExecuteDataTable(String.Format(sql, this.ID));

            if (dt.Rows.Count == 0)
            {
                return;
            }
            var sumValue     = Convert.ToDecimal(dt.Compute(" Sum(RemainProductionValue) ", ""));
            var currentValue = String.IsNullOrEmpty(this.GetValue("ProductionValue")) ? 0m : Convert.ToDecimal(this.GetValue("ProductionValue"));

            foreach (DataRow row in dt.Rows)
            {
                var value      = row["RemainProductionValue"] == DBNull.Value ? 0m : Convert.ToDecimal(row["RemainProductionValue"]);
                var splitValue = value / sumValue * currentValue;
                var item       = FormulaHelper.DataRowToDic(row);
                item.SetValue("ProductionValue", splitValue);
                item.UpdateDB(this.DB, "S_EP_CBSNode", item.GetValue("ID"));
                var cbsNode = new S_EP_CBSNode(item);
                cbsNode.SetUnit(false);
                if (loopDeep)
                {
                    cbsNode.AutoSplitProductionValue(exceptNodeTypes, loopDeep);
                }
            }
        }
예제 #3
0
        public void Push()
        {
            var detailDt = this.DB.ExecuteDataTable(String.Format("SELECT * FROM S_EP_BudgetVersion_Detail WHERE S_EP_BudgetVersionID='{0}'",
                                                                  this.ModelDic.GetValue("ID")));
            var detailList = FormulaHelper.DataTableToListDic(detailDt);

            foreach (var detail in detailList)
            {
                var modifyState = detail.GetValue("ModifyState");
                if (modifyState == ModifyState.Added.ToString())
                {
                    //新增节点
                    var parentNodeDic = this.GetDataDicByID("S_EP_CBSNode", detail.GetValue("CBSParentID"));
                    if (parentNodeDic == null)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("没有找到CBS节点,无法同步新增");
                    }
                    var parentNode = new S_EP_CBSNode(parentNodeDic);
                    var cbsNode    = new Dictionary <string, object>();
                    cbsNode.SetValue("ID", detail.GetValue("CBSID"));
                    cbsNode.SetValue("Code", detail.GetValue("Code"));
                    cbsNode.SetValue("Name", detail.GetValue("Name"));
                    cbsNode.SetValue("BudgetValue", detail.GetValue("TotalValue"));
                    cbsNode.SetValue("SortIndex", detail.GetValue("SortIndex"));
                    parentNode.AddChild(cbsNode);
                }
                else if (modifyState == ModifyState.Removed.ToString())
                {
                    //删除节点
                    this.DB.ExecuteNonQuery(String.Format("DELETE FROM S_EP_CBSNode WHERE ID='{0}'", detail.GetValue("CBSID")));
                }
                else
                {
                    //更新节点
                    var nodeDic = new Dictionary <string, object>();
                    nodeDic.SetValue("ID", detail.GetValue("CBSID"));
                    nodeDic.SetValue("Name", detail.GetValue("Name"));
                    nodeDic.SetValue("BudgetValue", detail.GetValue("TotalValue"));
                    nodeDic.SetValue("UnitPrice", detail.GetValue("UnitPrice"));
                    nodeDic.SetValue("Quantity", detail.GetValue("Quantity"));
                    nodeDic.UpdateDB(this.DB, "S_EP_CBSNode", nodeDic.GetValue("ID"));
                }
            }
            var budgetDic = this.BudgetUnit.ModelDic;

            if (String.IsNullOrEmpty(budgetDic.GetValue("CreateUser")))
            {
                budgetDic.SetValue("CreateUser", this.ModelDic.GetValue("RegisterUserName"));
                budgetDic.SetValue("CreateUserID", this.ModelDic.GetValue("RegisterUser"));
                budgetDic.SetValue("CreateDate", DateTime.Now);
            }
            this.BudgetNode.SummaryBudgetValue();
            budgetDic.SetValue("ModifyUser", this.ModelDic.GetValue("RegisterUserName"));
            budgetDic.SetValue("ModifyUserID", this.ModelDic.GetValue("RegisterUser"));
            budgetDic.SetValue("ModifyDate", DateTime.Now);
            budgetDic.SetValue("TotalBudgetValue", this.ModelDic.GetValue("BudgetValue"));
            budgetDic.UpdateDB(this.DB, "S_EP_BudgetUnit", budgetDic.GetValue("ID"));
            this._SumBudgetToTop(this.BudgetNode.ParentNode);
            this._UpdateChildren(this.BudgetNode.Children);
        }
예제 #4
0
        void _SumBudgetToTop(S_EP_CBSNode cbsNode)
        {
            if (cbsNode == null)
            {
                return;
            }

            cbsNode.SummaryBudgetValue();
            if (cbsNode.ParentNode != null)
            {
                _SumBudgetToTop(cbsNode.ParentNode);
            }
            else
            {
                var infoDic = cbsNode.CBSInfo.ModelDic;
                infoDic.SetValue("BudgetValue", cbsNode.ModelDic.GetValue("BudgetValue"));
                infoDic.UpdateDB(this.DB, "S_EP_CBSInfo", infoDic.GetValue("ID"));
            }
        }
예제 #5
0
        public void Push()
        {
            var confirmAdjustInfoDic = this.ModelDic;
            var cbsNodeDic           = this.GetDataDicByID("S_EP_CBSNode", confirmAdjustInfoDic.GetValue("CBSNodeID"));

            if (cbsNodeDic == null)
            {
                throw new BusinessException("无法找到ID为【" + confirmAdjustInfoDic.GetValue("CBSNodeID") + "】的CBSNode");
            }

            string sql = "";
            var    productionSettleValue = new Dictionary <string, object>();

            productionSettleValue.SetValue("ID", FormulaHelper.CreateGuid());
            productionSettleValue.SetValue("CBSInfo", cbsNodeDic.GetValue("CBSInfoID"));
            productionSettleValue.SetValue("CBSNodeID", confirmAdjustInfoDic.GetValue("CBSNodeID"));
            productionSettleValue.SetValue("CBSNodeFullID", cbsNodeDic.GetValue("FullID"));
            productionSettleValue.SetValue("ProductionUnitID", confirmAdjustInfoDic.GetValue("ProductionUnitID"));
            productionSettleValue.SetValue("UnitName", cbsNodeDic.GetValue("Name"));
            productionSettleValue.SetValue("UnitCode", cbsNodeDic.GetValue("Code"));
            //productionSettleValue.SetValue("SettleDataFrom", SettleDataFrom.ConfirmAdjust.ToString());
            productionSettleValue.SetValue("LastScale", "0");
            productionSettleValue.SetValue("LastProductionValue", confirmAdjustInfoDic.GetValue("ProductionSettleValue"));
            productionSettleValue.SetValue("TotalScale", "0");
            productionSettleValue.SetValue("TotalProductionValue", confirmAdjustInfoDic.GetValue("ProductionSettleValueNew"));
            productionSettleValue.SetValue("CurrentProductionValue", confirmAdjustInfoDic.GetValue("ProductionSettleValueAdjust"));
            productionSettleValue.SetValue("ConfirmFormID", "");
            productionSettleValue.SetValue("ConfirmDetailID", "");
            productionSettleValue.SetValue("FactEndDate", confirmAdjustInfoDic.GetValue("OperateDate"));
            productionSettleValue.SetValue("ChargerUser", cbsNodeDic.GetValue("ChargerUser"));
            productionSettleValue.SetValue("ChargerUserName", cbsNodeDic.GetValue("ChargerUserName"));
            productionSettleValue.SetValue("ChargerDept", cbsNodeDic.GetValue("ChargerDept"));
            productionSettleValue.SetValue("ChargerDeptName", cbsNodeDic.GetValue("ChargerDeptName"));
            productionSettleValue.SetValue("ApplyUser", confirmAdjustInfoDic.GetValue("ApplyUser"));
            productionSettleValue.SetValue("ApplyUserName", confirmAdjustInfoDic.GetValue("ApplyUserName"));
            productionSettleValue.SetValue("Company", cbsNodeDic.GetValue("OrgID"));
            var org = this.GetDataDicByID("S_A_Org", cbsNodeDic.GetValue("OrgID"), ConnEnum.Base);

            if (org != null)
            {
                productionSettleValue.SetValue("CompanyName", org.GetValue("Name"));
            }
            productionSettleValue.SetValue("FinishProgressNodeID", "");
            sql = productionSettleValue.CreateInsertSql(this.DB, "S_EP_ProductionSettleValue", productionSettleValue.GetValue("ID"));

            #region 更新ProductionUnit的产值信息 更新cbsNode的产值信息
            //更新ProductionUnit的产值信息
            var productionUnit = this.GetDataDicByID("S_EP_ProductionUnit", confirmAdjustInfoDic.GetValue("ProductionUnitID"));
            if (productionUnit != null)
            {
                decimal tmp1 = 0;
                decimal.TryParse(productionUnit.GetValue("ProductionSettleValue"), out tmp1);
                decimal tmp2 = 0;
                decimal.TryParse(confirmAdjustInfoDic.GetValue("ProductionSettleValueAdjust"), out tmp2);
                productionUnit.SetValue("ProductionSettleValue", tmp1 + tmp2);
                sql += productionUnit.CreateUpdateSql(this.DB, "S_EP_ProductionUnit", productionUnit.GetValue("ID"));
            }
            //更新cbsNode的产值信息
            if (cbsNodeDic != null)
            {
                cbsNodeDic.SetValue("ProductionSettleValue", confirmAdjustInfoDic.GetValue("ProductionSettleValueNew"));
                sql += cbsNodeDic.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID"));
            }
            this.DB.ExecuteNonQuery(sql);

            //更新cbsNode上级节点及cbsinfo产值信息
            if (cbsNodeDic != null)
            {
                S_EP_CBSNode cbsNode = new S_EP_CBSNode(cbsNodeDic);
                cbsNode.SumProductionSettleValueToTop();
            }
            #endregion
        }
예제 #6
0
        public void Push()
        {
            var cbsDic = this.GetDataDicByID("S_EP_CBSNode", this.ModelDic.GetValue("CBSNode"));

            if (cbsDic == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到对应的产值节点,无法补贴产值");
            }
            cbsDic.SetValue("ProductionValue", this.ModelDic.GetValue("ProductionValue"));
            var cbsNode        = new S_EP_CBSNode(cbsDic);
            var defineChildren = cbsNode.DefineNode.ChildrenNode.Where(c => c.ModelDic.GetValue("NodeType") != CBSNodeType.Communal.ToString() &&
                                                                       c.ModelDic.GetValue("NodeType") != CBSNodeType.Reserved.ToString()).ToList();

            if (defineChildren.Count > 0)
            {
                //判定结构定义中是否有子节点,如果有才能够对子节点进行操作
                var detailRows = this.DB.ExecuteDataTable(String.Format("select * from S_EP_ProductionSubsidyApply_Detail where S_EP_ProductionSubsidyApplyID='{0}'"
                                                                        , this.ModelDic.GetValue("ID")));
                foreach (DataRow detailRow in detailRows.Rows)
                {
                    var detail = FormulaHelper.DataRowToDic(detailRow);
                    #region  步更新产值CBS节点明细
                    var child = this.GetDataDicByID("S_EP_CBSNode", detail.GetValue("CBSID"));
                    if (child == null)
                    {
                        continue;
                    }
                    else
                    {
                        child.SetValue("Name", detail.GetValue("Name"));
                        if (!String.IsNullOrEmpty(detail.GetValue("Code")))
                        {
                            child.SetValue("Code", detail.GetValue("Code"));
                        }
                        child.SetValue("RelateID", detail.GetValue("RelateID"));
                        child.SetValue("ChargerDept", detail.GetValue("ChargerDept"));
                        child.SetValue("ChargerDeptName", detail.GetValue("ChargerDeptName"));
                        child.SetValue("ChargerUser", detail.GetValue("ChargerUser"));
                        child.SetValue("ChargerUserName", detail.GetValue("ChargerUserName"));
                        child.SetValue("ProductionValue", detail.GetValue("ProductionValueNew"));
                        child.UpdateDB(this.DB, "S_EP_CBSNode", child.GetValue("ID"));
                        this.DB.ExecuteNonQuery(String.Format("update S_EP_ProductionUnit set ProductionValue={0} where CBSNodeID='{1}'",
                                                              String.IsNullOrEmpty(detail.GetValue("ProductionValueNew")) ? "0" : detail.GetValue("ProductionValueNew"), child.GetValue("ID")));
                        var childNode = new S_EP_CBSNode(child);
                        childNode.SetUnit();
                        var changeValue = String.IsNullOrEmpty(detail.GetValue("AdjustValue")) ? 0m : Convert.ToDecimal(detail.GetValue("AdjustValue"));
                        childNode.AutoSplitProductionValueToReversed(changeValue);
                    }
                    #endregion
                    setChangeLoad(detail);
                }
            }
            if (cbsNode.DefineNode.ChildrenNode.Count(c => c.ModelDic.GetValue("NodeType") == CBSNodeType.Reserved.ToString()) > 0)
            {
                //当节点定义中有预留节点时,才能进行预留
                #region 更新预留产值节点
                var reserverNode = cbsNode.Children.FirstOrDefault(c => c.ModelDic.GetValue("NodeType") == CBSNodeType.Reserved.ToString());
                if (reserverNode == null)
                {
                    if (!String.IsNullOrEmpty(this.ModelDic.GetValue("ProductionReserveValue")) && Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue")) > 0)
                    {
                        var revDic = new Dictionary <string, object>();
                        revDic.SetValue("Name", "产值预留");
                        revDic.SetValue("Code", "Reserves");
                        revDic.SetValue("NodeType", CBSNodeType.Reserved.ToString());
                        var defineNode = cbsNode.Children.FirstOrDefault(c => c.GetValue("NodeType") == CBSNodeType.Reserved.ToString());
                        revDic.SetValue("DefineID", defineNode.GetValue("ID"));
                        revDic.SetValue("ProductionValue", Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue")));
                        revDic.SetValue("RelateID", cbsDic.GetValue("ID") + CBSNodeType.Reserved.ToString());
                        reserverNode = new S_EP_CBSNode(revDic);
                        cbsNode.AddChild(reserverNode);
                    }
                }
                else
                {
                    reserverNode.ModelDic.SetValue("ProductionValue",
                                                   String.IsNullOrEmpty(this.ModelDic.GetValue("ProductionReserveValue")) ? 0m :
                                                   Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue")));
                    reserverNode.ModelDic.UpdateDB(this.DB, "S_EP_CBSNode", reserverNode.ModelDic.GetValue("ID"));
                }
                #endregion

                //如果有预留节点,当前节点的计划产值等于所有子节点计划产值汇总
                //因为所有的计划产值必须在分解的时候全部分解完毕,如果暂不分解完成的,必须存放在预留节点内
                //没有预留节点说明不能预留
                cbsNode.SumProductionValue();
            }
            else
            {
                cbsDic.SetValue("ProductionValue", this.ModelDic.GetValue("ProductionValue"));
                cbsDic.UpdateDB(this.DB, "S_EP_CBSNode", cbsDic.GetValue("ID"));
            }
            cbsNode.SumProductionValueToTop();
            setChangeLoad(cbsDic);

            foreach (var ancestor in cbsNode.Ancestors)
            {
                setChangeLoad(ancestor.ModelDic);
            }
        }
예제 #7
0
        public void AutoSplitProductionValueToReversed(decimal changeValue, bool igoreReserved = false, bool loopDeep = true)
        {
            var       sql = String.Format(@"select * from S_EP_CBSNode with(nolock) where ParentID='{0}' and NodeType='{1}'  ", this.GetValue("ID"), CBSNodeType.Reserved.ToString());
            DataTable dt  = new DataTable();

            #region 判定是否直接将变更金额分解至子节点
            var splitToChildren = false;
            if (igoreReserved)
            {
                splitToChildren = true;
            }
            else
            {
                dt = this.DB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    splitToChildren = true;
                }
            }
            #endregion

            if (splitToChildren)
            {
                //说明没有定义预留节点
                sql = String.Format(@"select S_EP_CBSNode.*,isnull(ReservedValue,0) as ReservedValue,
isnull(ProductionValue,0)- ISNULL(ReservedValue,0) SplitProductionValue,
isnull(ProductionValue,0)- ISNULL(ReservedValue,0) -ISNULL(ProductionSettleValue,0) as RemainProductionValue from S_EP_CBSNode
left join (select Sum(ProductionValue) as ReservedValue,ParentID from S_EP_CBSNode
where NodeType='{1}' group by ParentID) ReservedInfo on ReservedInfo.ParentID=S_EP_CBSNode.ID
where NodeType<>'{2}' and  S_EP_CBSNode.ParentID= '{0}' 
and AccountNodeType like '%Production%' and NodeType<>'{1}' order by SortIndex",
                                    this.GetValue("ID"), CBSNodeType.Reserved.ToString(), CBSNodeType.Communal.ToString());
                var children  = this.DB.ExecuteDataTable(sql);
                var obj       = children.Compute(" Sum(RemainProductionValue) ", "");
                var sumRemain = 0m;
                if (obj != null && obj != DBNull.Value)
                {
                    sumRemain = Convert.ToDecimal(obj);
                }
                if (sumRemain == 0)
                {
                    return;
                }
                foreach (DataRow item in children.Rows)
                {
                    var cbsDic          = FormulaHelper.DataRowToDic(item);
                    var remainValue     = String.IsNullOrEmpty(cbsDic.GetValue("RemainProductionValue")) ? 0m : Convert.ToDecimal(cbsDic.GetValue("RemainProductionValue"));
                    var addValue        = changeValue * remainValue / sumRemain;
                    var productionValue = String.IsNullOrEmpty(cbsDic.GetValue("ProductionValue")) ? 0m : Convert.ToDecimal(cbsDic.GetValue("ProductionValue"));
                    var newValue        = productionValue + addValue;
                    cbsDic.SetValue("ProductionValue", newValue);
                    cbsDic.UpdateDB(this.DB, "S_EP_CBSNode", cbsDic.GetValue("ID"));
                    var cbsNode = new S_EP_CBSNode(cbsDic);
                    if (loopDeep)
                    {
                        cbsNode.AutoSplitProductionValueToReversed(addValue, igoreReserved, loopDeep);
                    }
                }
            }
            else
            {
                var reservedNodeDic = FormulaHelper.DataRowToDic(dt.Rows[0]);
                var productionValue = String.IsNullOrEmpty(reservedNodeDic.GetValue("ProductionValue")) ? 0 : Convert.ToDecimal(reservedNodeDic.GetValue("ProductionValue"));
                var sumValue        = productionValue + changeValue;
                reservedNodeDic.SetValue("ProductionValue", sumValue);
                reservedNodeDic.UpdateDB(this.DB, "S_EP_CBSNode", reservedNodeDic.GetValue("ID"));
            }
        }
예제 #8
0
 public void AddChild(S_EP_CBSNode childNode)
 {
     this.AddChild(childNode.ModelDic);
 }
예제 #9
0
        public void Push()
        {
            var cbsNodeDic = this.GetDataDicByID("S_EP_CBSNode", this.GetValue("CBSNode"));

            if (cbsNodeDic == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到指定的CBS节点,无法确认产值");
            }
            var cbsNode = new S_EP_CBSNode(cbsNodeDic);

            if (String.IsNullOrEmpty(this.GetValue("SettleDate")))
            {
                throw new Formula.Exceptions.BusinessValidationException("没有产值确认日期,无法申请");
            }
            var productionDt = this.DB.ExecuteDataTable(String.Format("SELECT * FROM S_EP_ProductionUnit WHERE CBSNodeID='{0}'", cbsNodeDic.GetValue("ID")));

            if (productionDt.Rows.Count == 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到指定的产值单元,无法确认产值");
            }
            var productionDic = FormulaHelper.DataRowToDic(productionDt.Rows[0]);

            if (!String.IsNullOrEmpty(this.GetValue("ProgressNode")))
            {
                var pNode = this.GetDataDicByID("S_EP_ProductionUnit_ProgressNode", this.GetValue("ProgressNode"));
                pNode.SetValue("State", "Finish");
                pNode.SetValue("FactEndDate", Convert.ToDateTime(this.GetValue("SettleDate")));
                pNode.UpdateDB(this.DB, "S_EP_ProductionUnit_ProgressNode", pNode.GetValue("ID"));
            }


            var detailSettleInfo = this.DB.ExecuteDataTable(String.Format("select * from S_EP_ProductionSettleApply_DetailInfo where S_EP_ProductionSettleApplyID='{0}'", this.GetValue("ID")));

            if (detailSettleInfo.Rows.Count == 0)
            {
                #region 没有明细节点,结算的产值节点是最末级节点或不需要结算到下级明细
                var settleInfo = new Dictionary <string, object>();
                settleInfo.SetValue("CBSInfo", this.GetValue("RootInfo"));
                settleInfo.SetValue("CBSNodeID", cbsNodeDic.GetValue("ID"));
                settleInfo.SetValue("CBSNodeFullID", cbsNodeDic.GetValue("FullID"));
                settleInfo.SetValue("ProductionUnitID", productionDic.GetValue("ID"));
                settleInfo.SetValue("UnitName", productionDic.GetValue("Name"));
                settleInfo.SetValue("UnitCode", productionDic.GetValue("Code"));
                var lastValue = String.IsNullOrEmpty(this.GetValue("LastTotalSettleValue")) ? 0 : Convert.ToDecimal(this.GetValue("LastTotalSettleValue"));
                var planValue = String.IsNullOrEmpty(this.GetValue("ProductionValue")) ? 0 : Convert.ToDecimal(this.GetValue("ProductionValue"));
                if (planValue > 0)
                {
                    settleInfo.SetValue("LastScale", Math.Round(lastValue / planValue * 100, 2));
                }
                else
                {
                    settleInfo.SetValue("LastScale", 0);
                }
                settleInfo.SetValue("LastProductionValue", String.IsNullOrEmpty(this.GetValue("LastTotalSettleValue")) ? 0 : Convert.ToDecimal(this.GetValue("LastTotalSettleValue")));
                settleInfo.SetValue("TotalScale", String.IsNullOrEmpty(this.GetValue("TotalScale")) ? 0 : Convert.ToDecimal(this.GetValue("TotalScale")));
                settleInfo.SetValue("TotalProductionValue", String.IsNullOrEmpty(this.GetValue("TotalSettleValue")) ? 0 : Convert.ToDecimal(this.GetValue("TotalSettleValue")));
                settleInfo.SetValue("CurrentProductionValue", String.IsNullOrEmpty(this.GetValue("CurrentSettleValue")) ? 0 : Convert.ToDecimal(this.GetValue("CurrentSettleValue")));
                settleInfo.SetValue("ConfirmFormID", this.GetValue("ID"));
                settleInfo.SetValue("FactEndDate", this.GetValue("SettleDate"));
                settleInfo.SetValue("ChargerUser", cbsNodeDic.GetValue("ChargerUser"));
                settleInfo.SetValue("ChargerUserName", cbsNodeDic.GetValue("ChargerUserName"));
                settleInfo.SetValue("ChargerDept", cbsNodeDic.GetValue("ChargerUserDept"));
                settleInfo.SetValue("ChargerDeptName", cbsNodeDic.GetValue("ChargerUserDeptName"));
                settleInfo.SetValue("ApplyUser", this.GetValue("ApplyUser"));
                settleInfo.SetValue("ApplyUserName", this.GetValue("ApplyUserName"));
                settleInfo.SetValue("Company", "");
                settleInfo.SetValue("CompanyName", "");
                settleInfo.SetValue("FinishProgressNodeID", this.GetValue("ProgressNode"));
                settleInfo.SetValue("ID", FormulaHelper.CreateGuid());
                settleInfo.InsertDB(this.DB, "S_EP_ProductionSettleValue");
                #endregion
            }
            else
            {
                foreach (DataRow detailInfo in detailSettleInfo.Rows)
                {
                    var item = new Dictionary <string, object>();
                    if (detailInfo["Data"] == DBNull.Value || String.IsNullOrEmpty(detailInfo["Data"].ToString()))
                    {
                        item = FormulaHelper.DataRowToDic(detailInfo);
                    }
                    else
                    {
                        item = JsonHelper.ToObject(detailInfo["Data"].ToString());
                        item.SetValue("ID", detailInfo["ID"]);
                    }
                    var keys = item.Keys.Where(c => c.Split('_').Length == 2 && c.Split('_')[1] == "Value").ToList();
                    if (keys.Count > 0)
                    {
                        #region
                        foreach (var key in keys)
                        {
                            var keyArray   = key.Split('_');
                            var detailNode = cbsNode.AllChildren.FirstOrDefault(c => c.GetValue("ParentID") == item.GetValue("CBSNodeID") && c.GetValue("DefineID") == keyArray[0]);
                            if (detailNode == null)
                            {
                                continue;
                            }
                            var currentValue = 0m;
                            decimal.TryParse(item.GetValue(key), out currentValue);
                            var settleInfo = new Dictionary <string, object>();
                            settleInfo.SetValue("CBSInfo", this.GetValue("RootInfo"));
                            settleInfo.SetValue("CBSNodeID", detailNode.GetValue("ID"));
                            settleInfo.SetValue("CBSNodeFullID", detailNode.GetValue("FullID"));
                            settleInfo.SetValue("ProductionUnitID", productionDic.GetValue("ID"));
                            settleInfo.SetValue("UnitName", productionDic.GetValue("Name"));
                            settleInfo.SetValue("UnitCode", productionDic.GetValue("Code"));
                            var lastValue = String.IsNullOrEmpty(detailNode.GetValue("ProductionSettleValue")) ? 0 : Convert.ToDecimal(detailNode.GetValue("ProductionSettleValue"));
                            var planValue = String.IsNullOrEmpty(detailNode.GetValue("ProductionValue")) ? 0 : Convert.ToDecimal(detailNode.GetValue("ProductionValue"));
                            if (planValue > 0)
                            {
                                settleInfo.SetValue("LastScale", Math.Round(lastValue / planValue * 100, 2));
                            }
                            else
                            {
                                settleInfo.SetValue("LastScale", 0);
                            }
                            settleInfo.SetValue("LastProductionValue", lastValue);
                            settleInfo.SetValue("TotalScale", String.IsNullOrEmpty(this.GetValue("TotalScale")) ? 0 : Convert.ToDecimal(this.GetValue("TotalScale")));
                            settleInfo.SetValue("CurrentProductionValue", currentValue);
                            settleInfo.SetValue("TotalProductionValue", lastValue + currentValue);
                            settleInfo.SetValue("ConfirmFormID", this.GetValue("ID"));
                            settleInfo.SetValue("FactEndDate", this.GetValue("SettleDate"));
                            settleInfo.SetValue("ChargerUser", cbsNodeDic.GetValue("ChargerUser"));
                            settleInfo.SetValue("ChargerUserName", cbsNodeDic.GetValue("ChargerUserName"));
                            settleInfo.SetValue("ChargerDept", cbsNodeDic.GetValue("ChargerUserDept"));
                            settleInfo.SetValue("ChargerDeptName", cbsNodeDic.GetValue("ChargerUserDeptName"));
                            settleInfo.SetValue("ApplyUser", this.GetValue("ApplyUser"));
                            settleInfo.SetValue("ApplyUserName", this.GetValue("ApplyUserName"));
                            settleInfo.SetValue("Company", "");
                            settleInfo.SetValue("CompanyName", "");
                            settleInfo.SetValue("FinishProgressNodeID", this.GetValue("ProgressNode"));
                            settleInfo.SetValue("ID", FormulaHelper.CreateGuid());
                            settleInfo.InsertDB(this.DB, "S_EP_ProductionSettleValue");
                        }
                        #endregion
                    }
                    else
                    {
                        #region
                        var detailNode = cbsNode.AllChildren.FirstOrDefault(c => c.GetValue("ID") == item.GetValue("CBSNodeID"));
                        if (detailNode == null)
                        {
                            continue;
                        }
                        var currentValue = 0m;
                        decimal.TryParse(item.GetValue("SettleValue"), out currentValue);
                        var settleInfo = new Dictionary <string, object>();
                        settleInfo.SetValue("CBSInfo", this.GetValue("RootInfo"));
                        settleInfo.SetValue("CBSNodeID", detailNode.GetValue("ID"));
                        settleInfo.SetValue("CBSNodeFullID", detailNode.GetValue("FullID"));
                        settleInfo.SetValue("ProductionUnitID", productionDic.GetValue("ID"));
                        settleInfo.SetValue("UnitName", productionDic.GetValue("Name"));
                        settleInfo.SetValue("UnitCode", productionDic.GetValue("Code"));
                        var lastValue = String.IsNullOrEmpty(detailNode.GetValue("ProductionSettleValue")) ? 0 : Convert.ToDecimal(detailNode.GetValue("ProductionSettleValue"));
                        var planValue = String.IsNullOrEmpty(detailNode.GetValue("ProductionValue")) ? 0 : Convert.ToDecimal(detailNode.GetValue("ProductionValue"));
                        if (planValue > 0)
                        {
                            settleInfo.SetValue("LastScale", Math.Round(lastValue / planValue * 100, 2));
                        }
                        else
                        {
                            settleInfo.SetValue("LastScale", 0);
                        }
                        settleInfo.SetValue("LastProductionValue", lastValue);
                        settleInfo.SetValue("TotalScale", String.IsNullOrEmpty(this.GetValue("TotalScale")) ? 0 : Convert.ToDecimal(this.GetValue("TotalScale")));
                        settleInfo.SetValue("CurrentProductionValue", currentValue);
                        settleInfo.SetValue("TotalProductionValue", lastValue + currentValue);
                        settleInfo.SetValue("ConfirmFormID", this.GetValue("ID"));
                        settleInfo.SetValue("FactEndDate", this.GetValue("SettleDate"));
                        settleInfo.SetValue("ChargerUser", cbsNodeDic.GetValue("ChargerUser"));
                        settleInfo.SetValue("ChargerUserName", cbsNodeDic.GetValue("ChargerUserName"));
                        settleInfo.SetValue("ChargerDept", cbsNodeDic.GetValue("ChargerUserDept"));
                        settleInfo.SetValue("ChargerDeptName", cbsNodeDic.GetValue("ChargerUserDeptName"));
                        settleInfo.SetValue("ApplyUser", this.GetValue("ApplyUser"));
                        settleInfo.SetValue("ApplyUserName", this.GetValue("ApplyUserName"));
                        settleInfo.SetValue("Company", "");
                        settleInfo.SetValue("CompanyName", "");
                        settleInfo.SetValue("FinishProgressNodeID", this.GetValue("ProgressNode"));
                        settleInfo.SetValue("ID", FormulaHelper.CreateGuid());
                        settleInfo.InsertDB(this.DB, "S_EP_ProductionSettleValue");
                        #endregion
                    }
                }
            }

            var userInfoList = this.DB.ExecuteDataTable(String.Format("select * from S_EP_ProductionSettleApply_UserInfo where S_EP_ProductionSettleApplyID='{0}'", this.GetValue("ID")));
            foreach (DataRow userInfo in userInfoList.Rows)
            {
                var item = new Dictionary <string, object>();
                if (userInfo["Data"] == DBNull.Value || String.IsNullOrEmpty(userInfo["Data"].ToString()))
                {
                    item = FormulaHelper.DataRowToDic(userInfo);
                }
                else
                {
                    item = JsonHelper.ToObject(userInfo["Data"].ToString());
                    item.SetValue("ID", userInfo["ID"]);
                }
                var keys = item.Keys.Where(c => c.Split('_').Length == 2 && c.Split('_')[1] == "Value").ToList();
                if (keys.Count > 0)
                {
                    foreach (var key in keys)
                    {
                        var defineID   = key.Split('_')[0];
                        var detailNode = cbsNode.AllChildren.FirstOrDefault(c => c.GetValue("ParentID") == item.GetValue("ParentID") && c.GetValue("DefineID") == defineID);
                        if (detailNode == null)
                        {
                            continue;
                        }
                        var userDic = new Dictionary <string, object>();
                        userDic.SetValue("Name", detailNode.GetValue("Name"));
                        userDic.SetValue("Code", detailNode.GetValue("Code"));
                        userDic.SetValue("CBSNodeID", detailNode.GetValue("ID"));
                        userDic.SetValue("CBSInfoID", detailNode.GetValue("CBSInfoID"));
                        userDic.SetValue("CBSFullID", detailNode.GetValue("FullID"));
                        userDic.SetValue("NodeType", detailNode.GetValue("NodeType"));
                        userDic.SetValue("UserID", item.GetValue("UserInfo"));
                        userDic.SetValue("UserName", item.GetValue("UserInfoName"));
                        userDic.SetValue("SettleValue", item.GetValue(key));
                        userDic.SetValue("Role", item.GetValue("Role"));
                        userDic.SetValue("RoleName", item.GetValue("RoleName"));
                        userDic.SetValue("SettleFormID", this.GetValue("ID"));
                        userDic.SetValue("SettleFormCode", "ProductionSettleApply");
                        userDic.InsertDB(this.DB, "S_EP_ProductionUserSettleValue");
                    }
                }
                else
                {
                    var detailNode = cbsNode.AllChildren.FirstOrDefault(c => c.GetValue("ID") == item.GetValue("ParentID"));
                    if (detailNode == null)
                    {
                        continue;
                    }
                    var userDic = new Dictionary <string, object>();
                    userDic.SetValue("Name", detailNode.GetValue("Name"));
                    userDic.SetValue("Code", detailNode.GetValue("Code"));
                    userDic.SetValue("CBSNodeID", detailNode.GetValue("ID"));
                    userDic.SetValue("CBSInfoID", detailNode.GetValue("CBSInfoID"));
                    userDic.SetValue("CBSFullID", detailNode.GetValue("FullID"));
                    userDic.SetValue("NodeType", detailNode.GetValue("NodeType"));
                    userDic.SetValue("UserID", item.GetValue("UserInfo"));
                    userDic.SetValue("UserName", item.GetValue("UserInfoName"));
                    userDic.SetValue("SettleValue", item.GetValue("SettleValue"));
                    userDic.SetValue("Role", item.GetValue("Role"));
                    userDic.SetValue("RoleName", item.GetValue("RoleName"));
                    userDic.SetValue("SettleFormID", this.GetValue("ID"));
                    userDic.SetValue("SettleFormCode", "ProductionSettleApply");
                    userDic.InsertDB(this.DB, "S_EP_ProductionUserSettleValue");
                }
            }


            var sumProductionValue = this.DB.ExecuteScalar(String.Format(@"select isnull(Sum(CurrentProductionValue),0) from S_EP_ProductionSettleValue with(nolock) 
where CBSNodeFullID like '{0}%'", cbsNodeDic.GetValue("FullID")));

            productionDic.SetValue("ProductionSettleValue", sumProductionValue);
            productionDic.UpdateDB(this.DB, "S_EP_ProductionUnit", productionDic.GetValue("ID"));

            this.DB.ExecuteNonQuery(String.Format(@"update S_EP_CBSNode
set ProductionSettleValue=isnull((select Sum(CurrentProductionValue) from S_EP_ProductionSettleValue where CBSNodeFullID like S_EP_CBSNode.FullID+'%'),0) 
where '{0}' like S_EP_CBSNode.FullID+'%'", cbsNodeDic.GetValue("FullID")));

            this.DB.ExecuteNonQuery(String.Format(@"update S_EP_CBSNode
set ProductionSettleValue=isnull((select Sum(CurrentProductionValue) from S_EP_ProductionSettleValue where CBSNodeFullID like S_EP_CBSNode.FullID+'%'),0) 
where S_EP_CBSNode.FullID like +'{0}%'", cbsNodeDic.GetValue("FullID")));
        }
예제 #10
0
        public void Push()
        {
            var confirmAdjustInfoDic = this.ModelDic;
            var productionUnit       = this.GetDataDicByID("S_EP_ProductionUnit", confirmAdjustInfoDic.GetValue("ProductionUnit"));

            if (productionUnit == null)
            {
                throw new BusinessException("无法找到ID为【" + confirmAdjustInfoDic.GetValue("ProductionUnit") + "】的产值单元");
            }
            var cbsNodeDic = this.GetDataDicByID("S_EP_CBSNode", productionUnit.GetValue("CBSNodeID"));

            if (cbsNodeDic == null)
            {
                throw new BusinessException("无法找到ID为【" + productionUnit.GetValue("CBSNodeID") + "】的CBSNode");
            }

            string sql = "";
            var    productionSettleValueDt = this.DB.ExecuteDataTable(
                "select top 1 * from S_EP_ProductionSettleValue where ConfirmDetailID = '" + confirmAdjustInfoDic.GetValue("ConfirmDetailID") + "'");

            var productionSettleValue = FormulaHelper.DataRowToDic(productionSettleValueDt.Rows[0]);

            productionSettleValue.SetValue("TotalScale", confirmAdjustInfoDic.GetValue("CurrentConfirmScaleTotalNew"));
            productionSettleValue.SetValue("TotalProductionValue", confirmAdjustInfoDic.GetValue("CurrentConfirmValueTotalNew"));
            productionSettleValue.SetValue("CurrentProductionValue", confirmAdjustInfoDic.GetValue("CurrentConfirmValueNew"));

            sql = productionSettleValue.CreateUpdateSql(this.DB, "S_EP_ProductionSettleValue", productionSettleValue.GetValue("ID"));

            #region 更新ProductionUnit的产值信息 更新cbsNode的产值信息
            //更新ProductionUnit的产值信息

            decimal tmp1 = 0;
            decimal.TryParse(productionUnit.GetValue("ProductionSettleValue"), out tmp1);
            decimal tmp2 = 0;
            decimal.TryParse(confirmAdjustInfoDic.GetValue("CurrentConfirmValueAdjust"), out tmp2);
            productionUnit.SetValue("ProductionSettleValue", tmp1 + tmp2);
            sql += productionUnit.CreateUpdateSql(this.DB, "S_EP_ProductionUnit", productionUnit.GetValue("ID"));
            //更新cbsNode的产值信息
            cbsNodeDic.SetValue("ProductionSettleValue", productionUnit.GetValue("ProductionSettleValue"));

            sql += cbsNodeDic.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID"));
            this.DB.ExecuteNonQuery(sql);

            //更新cbsNode上级节点及cbsinfo产值信息
            S_EP_CBSNode cbsNode = new S_EP_CBSNode(cbsNodeDic);
            cbsNode.SumProductionSettleValueToTop();
            #endregion

            #region 产值公积,同时向上累加公积部分的金额到计划产值父节点上
            if (this.ModelDic.GetValue("AdjustMethod") == "CommunalAdjust")
            {
                sql = "";
                //新的计划产值
                decimal oldProductionValue = 0;
                decimal.TryParse(confirmAdjustInfoDic.GetValue("PlanProductionValue"), out oldProductionValue);
                decimal currentConfirmValueAdjust = 0;
                decimal.TryParse(confirmAdjustInfoDic.GetValue("CurrentConfirmValueAdjust"), out currentConfirmValueAdjust);

                productionSettleValue.SetValue("PlanProductionValue", oldProductionValue + currentConfirmValueAdjust);
                sql += productionSettleValue.CreateUpdateSql(this.DB, "S_EP_ProductionSettleValue", productionSettleValue.GetValue("ID"));

                //更新产值单元
                productionUnit = this.GetDataDicByID("S_EP_ProductionUnit", confirmAdjustInfoDic.GetValue("ProductionUnit"));
                productionUnit.SetValue("ProductionValue", oldProductionValue + currentConfirmValueAdjust);
                sql += productionUnit.CreateUpdateSql(this.DB, "S_EP_ProductionUnit", productionUnit.GetValue("ID"));

                //更新cbsnode计划产值
                cbsNodeDic.SetValue("ProductionValue", oldProductionValue + currentConfirmValueAdjust);
                sql += cbsNodeDic.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID"));

                this.DB.ExecuteNonQuery(sql);

                S_EP_CBSNode newCbsNode = new S_EP_CBSNode(cbsNodeDic);
                //更新父节点计划产值
                newCbsNode.SumProductionValueToTop();
                //产值公积信息更新
                setChangeLoad(cbsNodeDic);
                foreach (var ancestor in cbsNode.Ancestors)
                {
                    setChangeLoad(ancestor.ModelDic);
                }
            }
            #endregion
        }
예제 #11
0
        public void Push()
        {
            var cbsInfoDic = this.GetDataDicByID("S_EP_CBSInfo", this.ModelDic.GetValue("CBSInfoID"));

            if (cbsInfoDic == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到核算项目,无法变更");
            }
            var cbsInfo      = new S_EP_CBSInfo(cbsInfoDic);
            var defineNodeDt = this.InfrasDB.ExecuteDataTable(String.Format(@"SELECT * FROM S_EP_DefineCBSNode WHERE DefineID='{0}' ",
                                                                            cbsInfoDic.GetValue("CBSDefineInfoID")));

            defineNodeDt.PrimaryKey = new DataColumn[] { defineNodeDt.Columns["ID"] };
            var detailDt   = this.DB.ExecuteDataTable(@"SELECT * FROM S_EP_CBSInfoSchema_CBSNodeInfo 
WHERE S_EP_CBSInfoSchemaID='" + this.ModelDic.GetValue("ID") + "'");
            var sqlCommand = new StringBuilder();

            var addedList = new List <Dictionary <string, object> >();

            foreach (DataRow row in detailDt.Rows)
            {
                if (row["ModifyState"] == null || row["ModifyState"] == DBNull.Value)
                {
                    continue;
                }
                if (row["ModifyState"].ToString() == ModifyState.Added.ToString())
                {
                    var cbsNode = this.GetDataDicByID("S_EP_CBSNode", row["CBSNodeID"].ToString());
                    if (cbsNode != null)
                    {
                        Formula.LogWriter.Error("新增节点时候,CBS节点ID已存在,记录ID 为【" + row["ID"] + "】");
                        continue;
                    }
                    var defineNodeRow = defineNodeDt.Rows.Find(row["CBSDefineID"].ToString());
                    if (defineNodeRow == null)
                    {
                        Formula.LogWriter.Error("新增节点时候,没有找到CBS定义节点,记录ID 为【" + row["ID"] + "】");
                        continue;
                    }
                    var cbsNodeDic = FormulaHelper.DataRowToDic(row);
                    cbsNodeDic.SetValue("ID", row["CBSNodeID"].ToString());
                    cbsNodeDic.SetValue("CBSInfoID", cbsInfoDic.GetValue("ID"));
                    cbsNodeDic.SetValue("ParentID", row["CBSParentID"].ToString());
                    cbsNodeDic.SetValue("DefineID", row["CBSDefineID"].ToString());
                    cbsNodeDic.SetValue("FullID", row["CBSNodeFullID"].ToString());
                    cbsNodeDic.SetValue("NodeType", row["NodeType"].ToString());
                    cbsNodeDic.SetValue("CBSType", cbsInfoDic.GetValue("Type"));
                    if (String.IsNullOrEmpty(cbsNodeDic.GetValue("Code")))
                    {
                        cbsNodeDic.SetValue("Code", cbsInfoDic.GetValue("Code"));
                    }
                    cbsNodeDic.InsertDB(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID"));
                    addedList.Add(cbsNodeDic);

                    cbsInfo.setUnit(cbsNodeDic, row, defineNodeRow);

                    #region 自动增加静态节点
                    var staticDefineNodeList = defineNodeDt.AsEnumerable().Where(c => c["FullID"] != DBNull.Value &&
                                                                                 c["FullID"].ToString().StartsWith(defineNodeRow["FullID"].ToString()) && c["IsDynamic"].ToString() != "true").
                                               OrderBy(c => c["FullID"].ToString()).ToList();
                    foreach (var staticDefineNodeRow in staticDefineNodeList)
                    {
                        var parentCBSNodeRows = addedList.Where(c => c["DefineID"] != DBNull.Value &&
                                                                c["DefineID"].ToString() == staticDefineNodeRow["ParentID"].ToString()).ToList();
                        foreach (var parentNodeRow in parentCBSNodeRows)
                        {
                            var staticNode = addedList.AsEnumerable().FirstOrDefault(c => c["ParentID"] != DBNull.Value &&
                                                                                     c["ParentID"].ToString() == parentNodeRow["ID"].ToString() && c["DefineID"] != DBNull.Value &&
                                                                                     c["DefineID"].ToString() == staticDefineNodeRow["ID"].ToString());
                            if (staticNode == null)
                            {
                                staticNode = new Dictionary <string, object>();
                                var staticDefineNodeDic = FormulaHelper.DataRowToDic(staticDefineNodeRow);
                                var parentCBS           = new S_EP_CBSNode(parentNodeRow);
                                staticNode.SetValue("ID", FormulaHelper.CreateGuid());
                                staticNode.SetValue("DefineID", staticDefineNodeRow["ID"]);
                                staticNode.SetValue("Name", staticDefineNodeRow["Name"]);
                                staticNode.SetValue("Code", staticDefineNodeRow["Code"]);
                                staticNode.SetValue("NodeType", staticDefineNodeRow["NodeType"]);
                                if (staticNode.GetValue("NodeType") == CBSNodeType.Subject.ToString())
                                {
                                    staticNode.SetValue("SubjectID", staticDefineNodeRow["SubjectID"]);
                                    staticNode.SetValue("SubjectType", staticDefineNodeRow["SubjectType"]);
                                    staticNode.SetValue("Code", staticDefineNodeRow["SubjectCode"]);
                                    staticNode.SetValue("SubjectFullCode", staticDefineNodeRow["SubjectFullCode"]);
                                }
                                staticNode.SetValue("CBSType", cbsInfoDic.GetValue("Type"));
                                staticNode.SetValue("ChargerUser", cbsInfoDic.GetValue("ChargerUser"));
                                staticNode.SetValue("ChargerUserName", cbsInfoDic.GetValue("ChargerUserName"));
                                staticNode.SetValue("ChargerDept", cbsInfoDic.GetValue("ChargerDept"));
                                staticNode.SetValue("ChargerDeptName", cbsInfoDic.GetValue("ChargerDeptName"));
                                staticNode.SetValue("ContractInfoID", cbsInfoDic.GetValue("ContractInfoID"));
                                staticNode.SetValue("ProjectInfoID", cbsInfoDic.GetValue("ProjectInfoID"));
                                staticNode.SetValue("EngineeringInfoID", cbsInfoDic.GetValue("EngineeringInfoID"));
                                staticNode.SetValue("ClueInfoID", cbsInfoDic.GetValue("ClueInfoID"));
                                parentCBS.AddChild(staticNode);
                                addedList.Add(staticNode);
                            }
                        }
                    }
                    #endregion
                }
                else if (row["ModifyState"].ToString() == ModifyState.Modified.ToString())
                {
                    #region
                    var cbsNode = this.GetDataDicByID("S_EP_CBSNode", row["CBSNodeID"].ToString());
                    if (cbsNode == null)
                    {
                        continue;
                    }
                    cbsNode.SetValue("Name", row["Name"]);
                    cbsNode.SetValue("Code", row["Code"]);
                    cbsNode.SetValue("ChargerUser", row["ChargerUser"]);
                    cbsNode.SetValue("ChargerUserName", row["ChargerUserName"]);
                    cbsNode.SetValue("ChargerDept", row["ChargerDept"]);
                    cbsNode.SetValue("ChargerDeptName", row["ChargerDeptName"]);
                    cbsNode.SetValue("ContractValue", row["ContractValue"]);
                    cbsNode.SetValue("ContractTaxValue", row["ContractTaxValue"]);
                    cbsNode.SetValue("ContractClearValue", row["ContractClearValue"]);
                    cbsNode.SetValue("TaxRate", row["TaxRate"]);
                    cbsNode.SetValue("DefineID", row["CBSDefineID"]);
                    cbsNode.SetValue("NodeType", row["NodeType"]);
                    sqlCommand.AppendLine(cbsNode.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNode.GetValue("ID")));
                    #endregion

                    var defineNodeRow = defineNodeDt.Rows.Find(row["CBSDefineID"].ToString());
                    if (defineNodeRow == null)
                    {
                        Formula.LogWriter.Error("新增节点时候,没有找到CBS定义节点,记录ID 为【" + row["ID"] + "】");
                        continue;
                    }

                    cbsInfo.setUnit(cbsNode, row, defineNodeRow);
                }
                else if (row["ModifyState"].ToString() == ModifyState.Removed.ToString())
                {
                    var cbsNode = this.GetDataDicByID("S_EP_CBSNode", row["CBSNodeID"].ToString());
                    if (cbsNode == null)
                    {
                        continue;
                    }
                    var node = new S_EP_CBSNode(cbsNode);
                    node.Delete();
                }
            }
            if (!String.IsNullOrEmpty(sqlCommand.ToString()))
            {
                this.DB.ExecuteNonQuery(sqlCommand.ToString());
            }
        }