Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private bool ishaveChildField(string id, int projectId, int departmentId, int nickId)
        {
            bool isExsitChild = false;
            var  d            = base.XMFinancialFieldService.GetXMFinancialFieldByParentID(int.Parse(id));

            if (projectId != 0 || nickId != 0)
            {
                XMIncludeFields include = null;
                if (projectId != 0)
                {
                    include = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(projectId);
                }
                if (nickId != 0)
                {
                    include = base.XMIncludeFieldsService.GetXMIncludeFieldsListByNickID(nickId);
                }
                //var include = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(projectId);
                if (d.Count() > 0)
                {
                    if (include != null)
                    {
                        foreach (XMFinancialField f in d)
                        {
                            foreach (string str2 in include.Fields.Split(','))
                            {
                                if (str2 == f.Id.ToString())
                                {
                                    isExsitChild = true;
                                }
                            }
                        }
                    }
                }
            }
            if (departmentId != 0)
            {
                var include = base.XMIncludeFieldsService.GetXMIncludeFieldsListByDepartmentID(departmentId);
                if (d.Count() > 0)
                {
                    if (include != null)
                    {
                        foreach (XMFinancialField f in d)
                        {
                            foreach (string str3 in include.Fields.Split(','))
                            {
                                if (str3 == f.Id.ToString())
                                {
                                    isExsitChild = true;
                                }
                            }
                        }
                    }
                }
            }
            return(isExsitChild);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新数据
        /// </summary>
        private void UpdateData()
        {
            XMIncludeFields xmNickInclude = null;

            if (ProjectId != 0)
            {
                xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(ProjectId);
                if (xmNickInclude == null)
                {
                    base.ShowMessage("请先设置预算字段!");
                    return;
                }
            }

            if (NickID != 0)
            {
                xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByNickID(NickID);
                if (xmNickInclude == null)
                {
                    base.ShowMessage("请先设置预算字段!");
                    return;
                }
            }

            //更新数据
            if (xmNickInclude != null && !string.IsNullOrEmpty(xmNickInclude.Fields))
            {
                string[] parm = xmNickInclude.Fields.Split(',');
                string   pID  = "";           //父节点ID
                string   cID  = "";           //子节点ID
                if (parm != null && parm.Count() > 0)
                {
                    foreach (string id in parm)
                    {
                        var f = base.XMFinancialFieldService.GetXMFinancialFieldById(int.Parse(id));
                        if (f != null)
                        {
                            if (f.ParentID == 0)
                            {
                                pID += f.Id + ",";
                            }
                            else
                            {
                                cID += f.Id + ",";
                            }
                        }
                    }
                }

                if (pID != "" && pID.Length > 0)
                {
                    pID = pID.Substring(0, pID.Length - 1);
                }
                if (cID != "" && cID.Length > 0)
                {
                    cID = cID.Substring(0, cID.Length - 1);
                }
                string[] p = pID.Split(',');
                string[] c = cID.Split(',');
                foreach (string str in p)
                {
                    bool isexsitChild = false;          //是否存在子节点
                    //循环更新12个月
                    for (int i = 1; i <= 12; i++)
                    {
                        decimal total = 0;
                        HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail cost = null;
                        if (ProjectId != 0)
                        {
                            cost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(str), ProjectId, DateTime.Now.Year);
                        }
                        if (NickID != 0)
                        {
                            cost = XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(str), NickID, DateTime.Now.Year);
                        }
                        //var cost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(str), ProjectId, DateTime.Now.Year);
                        if (cost != null)
                        {
                            var f = base.XMFinancialFieldService.GetXMFinancialFieldByParentID(int.Parse(str));
                            if (f != null && f.Count() > 0)
                            {
                                foreach (string str1 in c)
                                {
                                    foreach (XMFinancialField field in f)
                                    {
                                        if (str1 == field.Id.ToString())
                                        {
                                            isexsitChild = true;
                                            HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail d = null;
                                            if (ProjectId != 0)
                                            {
                                                d = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(str), ProjectId, DateTime.Now.Year);
                                            }
                                            if (NickID != 0)
                                            {
                                                d = XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(str), NickID, DateTime.Now.Year);
                                            }
                                            //var d = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(str1), ProjectId, DateTime.Now.Year);
                                            if (d != null)
                                            {
                                                switch (i)
                                                {
                                                case 1:
                                                    total += d.OneMonthCost.Value;
                                                    break;

                                                case 2:
                                                    total += d.TwoMonthCost.Value;
                                                    break;

                                                case 3:
                                                    total += d.ThreeMonthCost.Value;
                                                    break;

                                                case 4:
                                                    total += d.FourMonthCost.Value;
                                                    break;

                                                case 5:
                                                    total += d.FiveMonthCost.Value;
                                                    break;

                                                case 6:
                                                    total += d.SixMonthCost.Value;
                                                    break;

                                                case 7:
                                                    total += d.SevenMonthCost.Value;
                                                    break;

                                                case 8:
                                                    total += d.EightMonthCost.Value;
                                                    break;

                                                case 9:
                                                    total += d.NineMonthCost.Value;
                                                    break;

                                                case 10:
                                                    total += d.TenMonthCost.Value;
                                                    break;

                                                case 11:
                                                    total += d.ElevenMonthCost.Value;
                                                    break;

                                                case 12:
                                                    total += d.TwelMonthCost.Value;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (isexsitChild)
                                {
                                    switch (i)
                                    {
                                    case 1:
                                        cost.OneMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 2:
                                        cost.TwoMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 3:
                                        cost.ThreeMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 4:
                                        cost.FourMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 5:
                                        cost.FiveMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 6:
                                        cost.SixMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 7:
                                        cost.SevenMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 8:
                                        cost.EightMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 9:
                                        cost.NineMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 10:
                                        cost.TenMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 11:
                                        cost.ElevenMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;

                                    case 12:
                                        cost.TwelMonthCost = total;
                                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(cost);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        //绑定gridview 控件
        private void BindGrid()
        {
            int           no     = 1;
            int           change = 0;
            StringBuilder str    = new StringBuilder();
            string        year   = ddlYear.SelectedValue;

            if (string.IsNullOrEmpty(this.ProjectId.ToString()))
            {
                base.ShowMessage("项目ID不能为空!");
                return;
            }
            string          includefields = "";
            XMIncludeFields xmNickInclude = null;

            if (this.ProjectId != 0)
            {
                xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(this.ProjectId);
            }
            if (this.NickID != 0)
            {
                xmNickInclude = XMIncludeFieldsService.GetXMIncludeFieldsListByNickID(this.NickID);
            }
            //var xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(this.ProjectId);
            if (xmNickInclude != null && !string.IsNullOrEmpty(xmNickInclude.Fields))
            {
                includefields = xmNickInclude.Fields;
            }
            else
            {
                change = 0;
                ScriptManager.RegisterStartupScript(this.grdvClients, this.Page.GetType(), "BindGrid", "ChangeOverflow('" + change + "')", true);//ajax
                grdvClients.DataSource = "";
                grdvClients.DataBind();
                base.ShowMessage("请先设置项目的预算字段!");
                return;
            }
            List <HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail> List = new List <HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail>();

            string[] parm = includefields.Split(',');
            string   pID  = "";           //父节点ID
            string   cID  = "";           //子节点ID

            if (parm != null && parm.Count() > 0)
            {
                foreach (string id in parm)
                {
                    var f = base.XMFinancialFieldService.GetXMFinancialFieldById(int.Parse(id));
                    if (f != null)
                    {
                        if (f.ParentID == 0)
                        {
                            pID += f.Id + ",";
                        }
                        else
                        {
                            cID += f.Id + ",";
                        }
                    }
                }
            }
            if (pID != "" && pID.Length > 0)
            {
                pID = pID.Substring(0, pID.Length - 1);
            }
            if (cID != "" && cID.Length > 0)
            {
                cID = cID.Substring(0, cID.Length - 1);
            }
            string[] p = pID.Split(',');
            string[] c = cID.Split(',');

            if (p != null && p.Length > 0)
            {
                for (int j = 0; j < p.Count(); j++)
                {
                    if (no == 1)
                    {
                        str.Append("<table   style='height: 5px;width:100%;border-style:solid' rules='all'>");
                        str.Append("<tr  style='font-weight:bold;height:30px;background-color:#EEEEEE'>");
                        str.Append("<th  nowrap='noWrap' align='center' style='width:120px;white-space:nowrap;cursor:pointer;' scope='col'>项目</th>");
                        str.Append("<th  nowrap='noWrap' align='center' style='width:60px;white-space:nowrap;cursor:pointer;' scope='col'>1-12月累计</th>");
                        str.Append("<th  nowrap='noWrap' align='center' style='width:70px;white-space:nowrap;cursor:pointer;' scope='col'>占毛利比</th>");

                        str.Append("</tr>");
                    }
                    str.Append("<tr class='GridRow' align='center' style='background-color:#EAEAEA;height:5px;height:5px;' oldcolor=#EAEAEA'>");
                    str.Append("<td style='width:120px;font-size:18px;'>" + getFieldNameByFieldID(p[j]) + "</td>");
                    str.Append("<td style='width:60px;text-align:center'>" + getSumAllCost(p[j]) + "</td>");
                    if (YYYJCost != 0)
                    {
                        str.Append("<td style='width:70px;text-align:center'>" + Math.Round(getSumAllCost(p[j]) / YYYJCost, 2) * 100 + "%" + "</td>");
                    }
                    else
                    {
                        str.Append("<td style='width:70px;text-align:center'>" + 0 + "%" + "</td>");
                    }
                    str.Append("</tr>");
                    HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail pCost = null;
                    if (this.ProjectId != 0)
                    {
                        pCost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(p[j]), ProjectId, int.Parse(ddlYear.SelectedValue));
                    }
                    if (this.NickID != 0)
                    {
                        pCost = XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(p[j]), NickID, int.Parse(ddlYear.SelectedValue));
                    }
                    //var pCost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(p[j]), ProjectId, int.Parse(ddlYear.SelectedValue));
                    if (pCost != null && pCost.FieldName != "")
                    {
                        List.Add(pCost);
                    }
                    //字段管理中该字段已经删除,应清理该条数据
                    if (pCost != null && pCost.FieldName == "")
                    {
                        pCost.IsEnable   = true;
                        pCost.UpdateDate = DateTime.Now;
                        pCost.UpdateID   = HozestERPContext.Current.User.CustomerID;
                        base.XMProjectCostDetailService.UpdateXMProjectCostDetail(pCost);
                    }
                    if (HasChild(p[j]))
                    {
                        string newStr = childFieldIDs(p[j]);
                        if (!string.IsNullOrEmpty(newStr))
                        {
                            foreach (string childID in c)
                            {
                                foreach (string str1 in newStr.Split(','))
                                {
                                    if (childID == str1)               //存在该子节点
                                    {
                                        str.Append("<tr class='GridRow' align='center' style='background-color:#FFFFFF;height:5px;height:5px;' oldcolor=#FFFFFF'>");
                                        str.Append("<td style='width:120px;text-align:right'>" + getFieldNameByFieldID(childID) + "</td>");
                                        str.Append("<td style='width:60px;text-align:center'>" + getSumAllCost(childID) + "</td>");
                                        if (YYYJCost != 0)
                                        {
                                            str.Append("<td style='width:70px;text-align:center'>" + Math.Round(getSumAllCost(childID) / YYYJCost, 2) * 100 + "%" + "</td>");
                                        }
                                        else
                                        {
                                            str.Append("<td style='width:70px;text-align:center'>" + 0 + "%" + "</td>");
                                        }
                                        HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail childCost = null;
                                        if (this.ProjectId != 0)
                                        {
                                            childCost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(p[j]), ProjectId, int.Parse(ddlYear.SelectedValue));
                                        }
                                        if (this.NickID != 0)
                                        {
                                            childCost = XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(p[j]), NickID, int.Parse(ddlYear.SelectedValue));
                                        }
                                        //var childCost = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(childID), ProjectId, int.Parse(ddlYear.SelectedValue));
                                        if (childCost != null && childCost.FieldName != "")
                                        {
                                            List.Add(childCost);
                                        }
                                        if (childCost != null && childCost.FieldName == "")
                                        {
                                            childCost.IsEnable   = true;
                                            childCost.UpdateDate = DateTime.Now;
                                            childCost.UpdateID   = HozestERPContext.Current.User.CustomerID;
                                            base.XMProjectCostDetailService.UpdateXMProjectCostDetail(childCost);
                                        }
                                        //字段管理中该字段已经删除,应该删除该条数据
                                        if (childCost != null && childCost.FieldName == "")
                                        {
                                            childCost.IsEnable   = true;
                                            childCost.UpdateDate = DateTime.Now;
                                            childCost.UpdateID   = HozestERPContext.Current.User.CustomerID;
                                            base.XMProjectCostDetailService.UpdateXMProjectCostDetail(childCost);
                                        }
                                    }
                                }
                            }
                            str.Append("</tr>");
                        }
                    }
                    no++;
                }
                if (List.Count > 0)
                {
                    change = 1;
                    str.Append("<tr class='GridRow' style='background-color:#F7F7F7'><td style='height:10px;' colspan='9'></td></tr></table>");
                    TableStr = str.ToString();
                }
                ScriptManager.RegisterStartupScript(this.grdvClients, this.Page.GetType(), "BindGrid", "ChangeOverflow('" + change + "')", true);//ajax
                grdvClients.DataSource = List;
                grdvClients.DataBind();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //
            if (checkIsAudit())
            {
                base.ShowMessage("请先反审核后在添加字段!");
                BindrptParentField();
                return;
            }
            string IDs = hdfSelectAllID.Value;

            if (string.IsNullOrEmpty(IDs))
            {
                base.ShowMessage("请选择字段");
                BindrptParentField();
                return;
            }

            string departmentID = this.DepartmentId.ToString();

            if (!string.IsNullOrEmpty(IDs) && this.ProjectId != 0)
            {
                string newStr = SortByDisplayOrder(IDs);
                hdfIDs.Value = IDs;
                var includeField = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(this.ProjectId);
                //新增
                if (includeField == null)
                {
                    XMIncludeFields info = new XMIncludeFields();
                    info.ProjectId  = this.ProjectId;
                    info.Fields     = newStr;
                    info.CreateId   = HozestERPContext.Current.User.CustomerID;
                    info.Createdate = DateTime.Now;
                    info.UpdateId   = HozestERPContext.Current.User.CustomerID;
                    info.Updatetime = DateTime.Now;
                    base.XMIncludeFieldsService.InsertXMIncludeFields(info);

                    //自动插入字段数据
                    autoSaveData(IDs, this.ProjectId, 0, 0);
                }
                else
                {
                    includeField.Fields     = newStr;
                    includeField.UpdateId   = HozestERPContext.Current.User.CustomerID;
                    includeField.Updatetime = DateTime.Now;
                    base.XMIncludeFieldsService.UpdateXMIncludeFields(includeField);
                    autoSaveData(IDs, this.ProjectId, 0, 0);
                }

                //项目字段更新后需要更新项目导入模板
                UpdateImportProjectTemplate();
                base.ShowMessage("操作成功!");
            }

            if (!string.IsNullOrEmpty(IDs) && this.DepartmentId != 0)
            {
                hdfIDs.Value = IDs;
                string newStr       = SortByDisplayOrder(IDs);
                var    fieldInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByDepartmentID(this.DepartmentId);
                if (fieldInclude == null)
                {
                    XMIncludeFields info = new XMIncludeFields();
                    info.DepartmentId = this.DepartmentId;
                    info.Fields       = newStr;
                    info.CreateId     = HozestERPContext.Current.User.CustomerID;
                    info.Createdate   = DateTime.Now;
                    info.UpdateId     = HozestERPContext.Current.User.CustomerID;
                    info.Updatetime   = DateTime.Now;
                    base.XMIncludeFieldsService.InsertXMIncludeFields(info);
                    //自动插入字段数据

                    autoSaveData(IDs, 0, this.DepartmentId, 0);
                }
                else
                {
                    fieldInclude.Fields     = newStr;
                    fieldInclude.UpdateId   = HozestERPContext.Current.User.CustomerID;
                    fieldInclude.Updatetime = DateTime.Now;
                    base.XMIncludeFieldsService.UpdateXMIncludeFields(fieldInclude);

                    autoSaveData(IDs, 0, this.DepartmentId, 0);
                }
                UpdateB2BOrB2CCostTemplate();
                base.ShowMessage("操作成功!");
            }

            if (!string.IsNullOrEmpty(IDs) && this.NickID != 0)
            {
                hdfIDs.Value = IDs;
                string newStr       = SortByDisplayOrder(IDs);
                var    fieldInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByNickID(this.NickID);
                if (fieldInclude == null)
                {
                    XMIncludeFields info = new XMIncludeFields();
                    info.NickId     = this.NickID;
                    info.Fields     = newStr;
                    info.CreateId   = HozestERPContext.Current.User.CustomerID;
                    info.Createdate = DateTime.Now;
                    info.UpdateId   = HozestERPContext.Current.User.CustomerID;
                    info.Updatetime = DateTime.Now;
                    base.XMIncludeFieldsService.InsertXMIncludeFields(info);
                    //自动插入字段数据

                    autoSaveData(IDs, 0, 0, this.NickID);
                }
                else
                {
                    fieldInclude.Fields     = newStr;
                    fieldInclude.UpdateId   = HozestERPContext.Current.User.CustomerID;
                    fieldInclude.Updatetime = DateTime.Now;
                    base.XMIncludeFieldsService.UpdateXMIncludeFields(fieldInclude);

                    autoSaveData(IDs, 0, 0, this.NickID);
                }

                base.ShowMessage("操作成功!");
            }

            if (this.DepartmentId != 0 && this.DepartmentId == 507)
            {
                BindManagerDepartFinanceField(this.DepartmentId);
            }
            else
            {
                BindrptParentField();
            }
        }
Esempio n. 5
0
        private void GetFieldCostList()
        {
            StringBuilder str = new StringBuilder();

            if (this.ProjectID != 0 || this.NickID != 0)                       //如果是项目
            {
                string includefields = "";
                //获取项目所属字段集合字符串
                XMIncludeFields xmNickInclude = null;
                if (this.ProjectID != 0)
                {
                    xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(this.ProjectID);
                }
                if (this.NickID != 0)
                {
                    xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByNickID(this.NickID);
                }
                //var xmNickInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByProjectID(this.ProjectID);
                if (xmNickInclude != null && !string.IsNullOrEmpty(xmNickInclude.Fields))
                {
                    includefields = xmNickInclude.Fields;
                }

                string[] parm = includefields.Split(',');
                string   pID  = "";           //父节点ID
                string   cID  = "";           //子节点ID
                if (parm != null && parm.Count() > 0)
                {
                    foreach (string id in parm)
                    {
                        var f = base.XMFinancialFieldService.GetXMFinancialFieldById(int.Parse(id));
                        if (f != null)
                        {
                            if (f.ParentID == 0)
                            {
                                pID += f.Id + ",";
                            }
                            else
                            {
                                cID += f.Id + ",";
                            }
                        }
                    }
                }

                if (pID != "" && pID.Length > 0)
                {
                    pID = pID.Substring(0, pID.Length - 1);
                }
                if (cID != "" && cID.Length > 0)
                {
                    cID = cID.Substring(0, cID.Length - 1);
                }
                string[] p = pID.Split(',');
                string[] c = cID.Split(',');
                str.Append("<table  border='1'  rules='all' width='480px'  id='tb1'>");
                str.Append("<tr  align='center' style='height:5px;height:5px;'>");

                if (p != null && p.Length > 0)
                {
                    for (int j = 0; j < p.Count(); j++)
                    {
                        decimal cost = 0;               //字段数值
                        HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail field = null;
                        if (this.ProjectID != 0)
                        {
                            field = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(p[j]), this.ProjectID, Year);
                        }
                        if (this.NickID != 0)
                        {
                            field = base.XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(p[j]), this.NickID, Year);
                        }
                        //HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail field = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(p[j]), this.ProjectID, Year);
                        //添加父节点
                        str.Append("<td style='width:40%;font-size:18px;text-align:left;'>" + field.FieldName + "</td>");
                        //遍历所有月份获取相应月份的数值
                        switch (Month)
                        {
                        case 1:
                            cost = field.OneMonthCost.Value;
                            break;

                        case 2:
                            cost = field.TwoMonthCost.Value;
                            break;

                        case 3:
                            cost = field.ThreeMonthCost.Value;
                            break;

                        case 4:
                            cost = field.FourMonthCost.Value;
                            break;

                        case 5:
                            cost = field.FiveMonthCost.Value;
                            break;

                        case 6:
                            cost = field.SixMonthCost.Value;
                            break;

                        case 7:
                            cost = field.SevenMonthCost.Value;
                            break;

                        case 8:
                            cost = field.EightMonthCost.Value;
                            break;

                        case 9:
                            cost = field.NineMonthCost.Value;
                            break;

                        case 10:
                            cost = field.TenMonthCost.Value;
                            break;

                        case 11:
                            cost = field.ElevenMonthCost.Value;
                            break;

                        case 12:
                            cost = field.TwelMonthCost.Value;
                            break;
                        }
                        bool isexsit = false;
                        if (this.ProjectID != 0)
                        {
                            isexsit = ishaveChildField(field.FinancialFieldID.ToString(), ProjectID, 0, 0);
                        }
                        if (this.NickID != 0)
                        {
                            isexsit = ishaveChildField(field.FinancialFieldID.ToString(), 0, 0, this.NickID);
                        }
                        //bool isexsit = ishaveChildField(field.FinancialFieldID.ToString(), ProjectID, 0,0);
                        bool isAuto = isAutoCalCulateField(field.FinancialFieldID.ToString());
                        if (isexsit || isAuto)
                        {
                            str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + field.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" disabled=\"disabled\" name=\"dd\" id='txtCost_" + field.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + field.FieldName + "'/></td></tr>");
                        }
                        else
                        {
                            str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + field.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" name=\"dd\" id='txtCost_" + field.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + field.FieldName + "'/></td></tr>");
                        }
                        if (HasChild(p[j]))
                        {
                            string newStr = childFieldIDs(p[j]);
                            foreach (string childID in c)
                            {
                                foreach (string str1 in newStr.Split(','))
                                {
                                    if (childID == str1)               //存在该子节点
                                    {
                                        HozestERP.BusinessLogic.ManageBusiness.XMProjectCostDetail f = null;
                                        if (this.ProjectID != 0)
                                        {
                                            f = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(childID), this.ProjectID, Year);
                                        }
                                        if (this.NickID != 0)
                                        {
                                            f = base.XMProjectCostDetailService.GetXMProjectCostDataByNick(int.Parse(childID), this.NickID, Year);
                                        }
                                        //var f = base.XMProjectCostDetailService.GetXMProjectCostDataByParm(int.Parse(childID), this.ProjectID, Year);
                                        switch (Month)
                                        {
                                        case 1:
                                            cost = f.OneMonthCost.Value;
                                            break;

                                        case 2:
                                            cost = f.TwoMonthCost.Value;
                                            break;

                                        case 3:
                                            cost = f.ThreeMonthCost.Value;
                                            break;

                                        case 4:
                                            cost = f.FourMonthCost.Value;
                                            break;

                                        case 5:
                                            cost = f.FiveMonthCost.Value;
                                            break;

                                        case 6:
                                            cost = f.SixMonthCost.Value;
                                            break;

                                        case 7:
                                            cost = f.SevenMonthCost.Value;
                                            break;

                                        case 8:
                                            cost = f.EightMonthCost.Value;
                                            break;

                                        case 9:
                                            cost = f.NineMonthCost.Value;
                                            break;

                                        case 10:
                                            cost = f.TenMonthCost.Value;
                                            break;

                                        case 11:
                                            cost = f.ElevenMonthCost.Value;
                                            break;

                                        case 12:
                                            cost = f.TwelMonthCost.Value;
                                            break;
                                        }
                                        str.Append("<tr align='center' style='height:5px;height:5px;'>");
                                        str.Append("<td style='width:40%;font-size:18px;text-align:right;font-size:13px;'>" + f.FieldName + "</td>");
                                        str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + f.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" name=\"dd\" id='txtCost_" + f.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + f.FieldName + "'/></td>");
                                        str.Append("</tr>");
                                    }
                                }
                            }
                        }
                    }
                    str.Append("</table>");
                    TableStr = str.ToString();
                }
            }
            else if (this.DepartmentID != 0)
            {
                string includefields = "";
                //获取项目所属字段集合字符串
                var xmOtherInclude = base.XMIncludeFieldsService.GetXMIncludeFieldsListByDepartmentID(this.DepartmentID);
                if (xmOtherInclude != null && !string.IsNullOrEmpty(xmOtherInclude.Fields))
                {
                    includefields = xmOtherInclude.Fields;
                }

                string[] parm = includefields.Split(',');
                string   pID  = "";           //父节点ID
                string   cID  = "";           //子节点ID
                if (parm != null && parm.Count() > 0)
                {
                    foreach (string id in parm)
                    {
                        var f = base.XMFinancialFieldService.GetXMFinancialFieldById(int.Parse(id));
                        if (f != null)
                        {
                            if (f.ParentID == 0)
                            {
                                pID += f.Id + ",";
                            }
                            else
                            {
                                cID += f.Id + ",";
                            }
                        }
                    }
                }

                if (pID != "" && pID.Length > 0)
                {
                    pID = pID.Substring(0, pID.Length - 1);
                }
                if (cID != "" && cID.Length > 0)
                {
                    cID = cID.Substring(0, cID.Length - 1);
                }
                string[] p = pID.Split(',');
                string[] c = cID.Split(',');
                str.Append("<table  border='1'  rules='all' width='480px'  id='tb1'>");
                str.Append("<tr  align='center' style='background-color:" + "" + ";height:5px;height:5px;' oldcolor='" + "" + "'>");

                if (p != null && p.Length > 0)
                {
                    for (int j = 0; j < p.Count(); j++)
                    {
                        decimal cost = 0;               //字段数值
                        HozestERP.BusinessLogic.ManageBusiness.XMOtherCostDetail otherField = base.XMOtherCostDetailService.GetXMOtherCostDataByParm(int.Parse(p[j]), this.DepartmentID, Year);
                        //添加父节点
                        str.Append("<td style='width:40%;font-size:18px;text-align:left;background-color:EAEAEA'>" + otherField.FieldName + "</td>");
                        //遍历所有月份获取相应月份的数值
                        switch (Month)
                        {
                        case 1:
                            cost = otherField.OneMonthCost.Value;
                            break;

                        case 2:
                            cost = otherField.TwoMonthCost.Value;
                            break;

                        case 3:
                            cost = otherField.ThreeMonthCost.Value;
                            break;

                        case 4:
                            cost = otherField.FourMonthCost.Value;
                            break;

                        case 5:
                            cost = otherField.FiveMonthCost.Value;
                            break;

                        case 6:
                            cost = otherField.SixMonthCost.Value;
                            break;

                        case 7:
                            cost = otherField.SevenMonthCost.Value;
                            break;

                        case 8:
                            cost = otherField.EightMonthCost.Value;
                            break;

                        case 9:
                            cost = otherField.NineMonthCost.Value;
                            break;

                        case 10:
                            cost = otherField.TenMonthCost.Value;
                            break;

                        case 11:
                            cost = otherField.ElevenMonthCost.Value;
                            break;

                        case 12:
                            cost = otherField.TwelMonthCost.Value;
                            break;
                        }
                        // 有子节点的不能编辑 和 (毛利,增值税,营业税附加,税前利润,所得税,直接净利润 字段无法输入,进行自动计算)
                        bool isexsit = ishaveChildField(otherField.FinancialFieldID.ToString(), 0, DepartmentID, 0);
                        bool isAuto  = isAutoCalCulateField(otherField.FinancialFieldID.ToString());
                        if (isexsit || isAuto)
                        {
                            str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + otherField.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" disabled=\"disabled\" name=\"dd\" id='txtCost_" + otherField.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + otherField.FieldName + "'/></td></tr>");
                        }
                        else
                        {
                            str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + otherField.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" name=\"dd\" id='txtCost_" + otherField.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + otherField.FieldName + "'/></td></tr>");
                        }
                        if (HasChild(p[j]))
                        {
                            string newStr = childFieldIDs(p[j]);
                            foreach (string childID in c)
                            {
                                foreach (string str1 in newStr.Split(','))
                                {
                                    if (childID == str1)               //存在该子节点
                                    {
                                        var f = base.XMOtherCostDetailService.GetXMOtherCostDataByParm(int.Parse(childID), this.DepartmentID, Year);
                                        switch (Month)
                                        {
                                        case 1:
                                            cost = f.OneMonthCost.Value;
                                            break;

                                        case 2:
                                            cost = f.TwoMonthCost.Value;
                                            break;

                                        case 3:
                                            cost = f.ThreeMonthCost.Value;
                                            break;

                                        case 4:
                                            cost = f.FourMonthCost.Value;
                                            break;

                                        case 5:
                                            cost = f.FiveMonthCost.Value;
                                            break;

                                        case 6:
                                            cost = f.SixMonthCost.Value;
                                            break;

                                        case 7:
                                            cost = f.SevenMonthCost.Value;
                                            break;

                                        case 8:
                                            cost = f.EightMonthCost.Value;
                                            break;

                                        case 9:
                                            cost = f.NineMonthCost.Value;
                                            break;

                                        case 10:
                                            cost = f.TenMonthCost.Value;
                                            break;

                                        case 11:
                                            cost = f.ElevenMonthCost.Value;
                                            break;

                                        case 12:
                                            cost = f.TwelMonthCost.Value;
                                            break;
                                        }
                                        str.Append("<tr  align='center' style='background-color:" + "" + ";height:5px;height:5px;' oldcolor='" + "" + "'>");
                                        str.Append("<td style='width:40%;font-size:18px;text-align:right;font-size:13px;background-color:#FFFFFF'>" + f.FieldName + "</td>");
                                        str.Append("<td style='width:50%;text-align:right'> <input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + f.FinancialFieldID + "'/><input type=\"text\"  runat=\"server\" name=\"dd\" id='txtCost_" + f.FinancialFieldID + "'  value='" + cost + "'/><input type=\"hidden\" id=\"hiddID\" runat=\"server\"  value=' " + f.FieldName + "'/></td>");
                                        str.Append("</tr>");
                                    }
                                }
                            }
                            str.Append("</tr>");
                        }
                    }
                    str.Append("</table>");
                    TableStr = str.ToString();
                }
            }
        }