Exemplo n.º 1
0
        /// <summary>
        /// 根据Id 获取结构信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult GetOrganizationalStructureById(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                OrganizationalStructureModel model = new OrganizationalStructureModel();
                B_ORGANIZATIONALSTRUCTURE    obj   = OrganizationalStructureBll.GetOrganizationalStructureById(id);
                if (obj != null)
                {
                    model.id               = obj.id;
                    model.b_NodeName       = obj.B_NODENAME;
                    model.b_NodeCode       = obj.B_NODECODE;
                    model.b_ParentNodeCode = obj.B_PARENTNODECODE;
                    model.b_NodePersonName = obj.B_NODEPERSONNAME;
                    model.b_NodeLevel      = obj.B_NODELEVEL;
                    model.b_CostCenter     = obj.B_COSTCENTER;
                    model.b_CompanyCode    = obj.B_COMPANYCODE;
                }
                retModel.data = model;
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取组织架构列表
        /// </summary>
        /// <returns></returns>
        public JsonResult GetOrganizationalStructureList()
        {
            var retModel = new JsonReturnModel();

            try
            {
                List <OrganizationalStructureModel> list = new List <OrganizationalStructureModel>();
                //获取组织架构
                List <B_ORGANIZATIONALSTRUCTURE> dataList = OrganizationalStructureBll.GetOrganizationalStructureList();

                //获取树形结构的数据
                List <B_ORGANIZATIONALSTRUCTURE> data = new List <B_ORGANIZATIONALSTRUCTURE>();
                OrganizationalStructureBll.GetChildByParent(inn, "", data, dataList);
                if (data != null && data.Count > 0)
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        OrganizationalStructureModel model = new OrganizationalStructureModel();
                        var item = data[i];
                        model.id               = item.id;
                        model.b_NodeName       = item.B_NODENAME;
                        model.b_NodeCode       = item.B_NODECODE;
                        model.b_ParentNodeCode = item.B_PARENTNODECODE;
                        model.b_NodePersonName = item.B_NODEPERSONNAME;
                        model.b_NodeLevel      = item.B_NODELEVEL;
                        model.b_CostCenter     = string.IsNullOrEmpty(item.B_COSTCENTER) ? "" : item.B_COSTCENTER;
                        model.b_CompanyCode    = string.IsNullOrEmpty(item.B_COMPANYCODE) ? "" : item.B_COMPANYCODE;
                        model.Number           = i + 1;
                        if (!string.IsNullOrEmpty(model.b_ParentNodeCode))
                        {
                            var parentNode = list.Where(x => x.b_NodeCode == model.b_ParentNodeCode).FirstOrDefault();
                            model.ParentNumber = parentNode.Number;
                        }
                        list.Add(model);
                    }
                }
                retModel.data = list;
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存部门信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SaveOrganizationalStructure(OrganizationalStructureModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                var item = inn.newItem("b_OrganizationalStructure", "edit");
                item.setAttribute("id", model.id);
                item.setProperty("b_costcenter", model.b_CostCenter);
                item.setProperty("b_companycode", model.b_CompanyCode);
                var resut = item.apply();
                if (resut.isError())
                {
                    retModel.AddError("errorMessage", resut.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }