示例#1
0
        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="id">部门ID</param>
        /// <returns></returns>
        public JsonResult DeleteDept(string id)
        {
            int  deptId = int.Parse(id);
            Dept dept   = db.GetModel(deptId);

            if (dept.Dept2.ToList().Count() > 0)
            {
                return(Json("No"));
            }
            List <Employee> emps = db.GetDeptEmp(deptId);

            foreach (Employee emp in emps)
            {
                emp.DeptId = null;
            }
            db.Delete(deptId);
            return(Json("Yes"));
        }