Beispiel #1
0
 public ActionResult Delete(int Id)
 {
     ErrorResult result = new ErrorResult();
     List<Sys_Dept> listDept = new Sys_DeptDAL().GetList(Id);
     if (listDept != null && listDept.Count > 0)
     {
         result.Flag = false;
         result.Message = "此部门下面有子部门或者人员";
         return Json(result);
     }
     List<Sys_User> listUser = new Sys_UserDAL().GetList(Id);
     if (listUser != null && listUser.Count > 0)
     {
         result.Flag = false;
         result.Message = "此部门下面有子部门或者人员";
         return Json(result);
     }
     result = new Sys_DeptDAL().Delete(Id);
     return Json(result);
 }
Beispiel #2
0
 public ActionResult GetTreeTest()
 {
     List<Sys_Dept> list = new Sys_DeptDAL().GetList();
     List<TreeObj> listObj = new List<TreeObj>();
     TreeObj modelRoot = new TreeObj();
     modelRoot.id = 0;
     modelRoot.pId = -1;
     modelRoot.name = "Root";
     modelRoot.open = true;
     listObj.Add(modelRoot);
     if (list != null && list.Count > 0)
     {
         foreach (var item in list)
         {
             TreeObj model = new TreeObj();
             model.id = item.Id;
             model.pId = item.ParentId;
             model.name = item.DeptName;
             model.open = true;
             listObj.Add(model);
         }
     }
     return Json(listObj, JsonRequestBehavior.AllowGet);
 }
Beispiel #3
0
        public string GetTree()
        {
            string json = "[";
            List<Sys_Dept> list = new Sys_DeptDAL().GetList(0);
            //if (list != null && list.Count > 0)
            //{
            foreach (var item in list)
            {
                json += "{";
                json += "\"id\":" + item.Id + ",";
                json += "\"pid\":\"" + item.DeptName + "\",";
                json += "\"name\":\"" + item.ParentId + "\",";
                if (GetTreeByParentId(item.Id) != "")
                {
                    json = json + GetTreeByParentId(item.Id);
                }
                json += "},";

            }
            json = json.Substring(0, json.Length - 1);
            json += "]";
            //}
            return json;
        }
Beispiel #4
0
 public ActionResult GetModel(int Id)
 {
     Sys_Dept model = new Sys_DeptDAL().GetModel(Id);
     return Json(model, JsonRequestBehavior.AllowGet);
 }
Beispiel #5
0
 public ActionResult Update(Sys_Dept entity)
 {
     ErrorResult result = new Sys_DeptDAL().Update(entity);
     return Json(result);
 }
Beispiel #6
0
 public ActionResult Add(Sys_Dept entity)
 {
     entity.DeptLever = 0;
     ErrorResult result = new Sys_DeptDAL().Insert(entity);
     return Json(result);
 }