/// <summary>
        /// 获取部门的树型结构
        /// </summary>
        /// <param name="toList">部门列表</param>
        /// <param name="to">部门</param>
        public void getTree(List <TBL_ORGANIZATION> toList, TBL_ORGANIZATION to)
        {
            //获取子集节点
            List <TBL_ORGANIZATION> coList = toList.Where(o => o.parentid == to.organizationid).ToList <TBL_ORGANIZATION>();

            if (coList.Count > 0)
            {
                to.children = coList;
                foreach (TBL_ORGANIZATION toc in coList)
                {
                    getTree(toList, toc);
                }
            }
        }
        private void update(HttpContext context)
        {
            string           json = "";
            TBL_ORGANIZATION to   = new TBL_ORGANIZATION();

            to.organizationid   = context.Request["organizationid"];;
            to.organizationname = context.Request["organizationname"];
            to.organizationtype = context.Request["organizationtype"];
            string oldname = context.Request["oldName"];

            //to.parentid = context.Request["parentid"];
            //to.orglevel = context.Request["orglevel"];

            try
            {
                List <TBL_ORGANIZATION> orgList = oBLL.GetList("  organizationname='" + to.organizationname + "' and  organizationname<>'" + oldname + "' ").ToList <TBL_ORGANIZATION>();

                if (orgList.Count > 0)
                {
                    json = "{IsSuccess:'false',Message:'部门名称已经存在!'}";
                }
                else
                {
                    if (oBLL.Update(to))
                    {
                        json = "{IsSuccess:'true',Message:'保存成功!'}";
                    }
                    else
                    {
                        json = "{IsSuccess:'true',Message:'保存失败!'}";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'服务器交互失败!'}";
            }
            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.Response.End();
        }
        private void add(HttpContext context)
        {
            string           json = "";
            TBL_ORGANIZATION to   = new TBL_ORGANIZATION();

            to.organizationid   = System.Guid.NewGuid().ToString().ToUpper();
            to.organizationname = context.Request["organizationname"];
            to.organizationtype = context.Request["organizationtype"];
            to.parentid         = context.Request["parentid"];
            to.orglevel         = context.Request["orglevel"];

            try
            {
                List <TBL_ORGANIZATION> orgList = oBLL.GetList("  organizationname='" + to.organizationname + "' ").ToList <TBL_ORGANIZATION>();

                if (orgList.Count > 0)
                {
                    json = "{IsSuccess:'false',Message:'部门名称已经存在!'}";
                }
                else
                {
                    if (oBLL.Insert(to))
                    {
                        //为专业主管部门创建资金账户
                        if (to.organizationtype == "B933AF9E-B57E-40F5-9284-E24BE8EA21FF")
                        {
                            TBL_CAPITALACCOUNT tca = new TBL_CAPITALACCOUNT();
                            tca.capitalaccountid   = System.Guid.NewGuid().ToString().ToUpper();
                            tca.capitalaccounttype = "E483C545-362D-47CF-AEE3-4E3B22E9F277";
                            tca.organizationid     = to.organizationid;
                            tca.balance            = 0;
                            cBLL.Insert(tca);
                        }

                        //为材料使用单位创建资金账户
                        if (to.organizationtype == "FFA21F13-BD0C-4312-BDAB-952C78DC39EE")
                        {
                            TBL_CAPITALACCOUNT tca = new TBL_CAPITALACCOUNT();
                            tca.capitalaccountid   = System.Guid.NewGuid().ToString().ToUpper();
                            tca.capitalaccounttype = "9BF8F1BE-9074-47B1-9123-B3486B65871D";
                            tca.organizationid     = to.organizationid;
                            tca.balance            = 0;
                            cBLL.Insert(tca);
                        }


                        json = "{IsSuccess:'true',Message:'保存成功!',id:'" + to.organizationid + "'}";
                    }
                    else
                    {
                        json = "{IsSuccess:'false',Message:'保存失败!'}";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'服务器交互失败!'}";
            }
            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.Response.End();
        }