예제 #1
0
        public ActionResult AddDepartment([DataSourceRequest] DataSourceRequest request, DepartmentModel departmentModel)
        {
            try
            {
                if (departmentModel != null)
                {
                    this.systemDepartmentService = new SystemDepartmentService();

                    var systemDepartment = DataTransfer.Transfer<System_Department>(departmentModel, typeof(DepartmentModel));
                    systemDepartment.CreateTime = DateTime.Now;

                    departmentModel.ID = this.systemDepartmentService.AddDepartment(systemDepartment);

                    if (departmentModel.ID > 0)
                    {
                        return this.Json(new[] { departmentModel }.ToDataSourceResult(request, this.ModelState));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("添加部门时发生错误", exception);
            }

            return this.View();
        }
예제 #2
0
        public ActionResult RemoveDepartment(int id, FormCollection collection)
        {
            try
            {
                this.systemDepartmentService = new SystemDepartmentService();
                this.systemDepartmentService.RemoveDepartmentByID(id);

                return this.RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }
예제 #3
0
        /// <summary>
        /// 查询所有系统部门
        /// </summary>
        /// <param name="request">
        /// 数据源请求信息对象
        /// </param>
        /// <returns>
        /// 执行方法结果
        /// </returns>
        /// <exception cref="Exception">
        /// 执行方法异常
        /// </exception>
        public ActionResult QueryAllDepartment([DataSourceRequest] DataSourceRequest request)
        {
            try
            {
                this.systemDepartmentService = new SystemDepartmentService();

                var list = this.systemDepartmentService.QueryAll();
                if (list != null)
                {
                    var modelList = new List<DepartmentModel>();

                    foreach (var backstageDepartment in list)
                    {
                        modelList.Add(DataTransfer.Transfer<DepartmentModel>(backstageDepartment, typeof(System_Department)));
                    }

                    return this.Json(modelList.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("查询所有部门时发生错误", exception);
            }

            return this.View();
        }
예제 #4
0
        public JsonResult QueryDepartmentSelectListItems()
        {
            try
            {
                this.systemDepartmentService = new SystemDepartmentService();

                var list = this.systemDepartmentService.QueryAll();
                if (list != null)
                {
                    return this.Json(list, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("查询部门选择列表出现错误", exception);
            }

            return this.Json(null);
        }
예제 #5
0
        public ActionResult ModifyDepartment([DataSourceRequest] DataSourceRequest request, DepartmentModel departmentModel)
        {
            if (departmentModel != null && this.ModelState.IsValid)
            {
                try
                {
                    this.systemDepartmentService = new SystemDepartmentService();

                    var backstageDepartment = DataTransfer.Transfer<System_Department>(
                        departmentModel,
                        typeof(DepartmentModel));

                    this.systemDepartmentService.ModifyDepartment(backstageDepartment);
                }
                catch (Exception exception)
                {
                    throw new Exception("删除部门时发生错误", exception);
                }
            }

            return this.Json(new[] { departmentModel }.ToDataSourceResult(request, this.ModelState));
        }