public ActionResult GetDepView() { int id = int.Parse(Request.Form["id"]); var viewModel = new Model.ViewModel.Department(); if (id == -1) { viewModel.IsActive = true; viewModel.SN = 255; return PartialView("DepartmentForm", viewModel); } else { var tempModel = new P_DepartmentBLL().GetListBy(p => p.ID == id).FirstOrDefault(); if (tempModel != null) { viewModel.ID = tempModel.ID; viewModel.IsActive = tempModel.IsActive; viewModel.Name = tempModel.Name; viewModel.ParentID = tempModel.ParentID; viewModel.Remark = tempModel.Remark; viewModel.SN = tempModel.SN; viewModel.DispatchSationID = tempModel.DispatchSationID; viewModel.DispatchSubCenterID = tempModel.DispatchSubCenterID; } return PartialView("DepartmentForm", viewModel); } }
public ActionResult GetAllDepart() { var list = new P_DepartmentBLL().GetListBy(d => d.IsActive == true).ToList(); List <Model.EasyUIModel.TreeNode> listTree = Model.P_Department.ToTreeNodes(list); return(Json(listTree, JsonRequestBehavior.AllowGet)); }
public ActionResult DelDepartment() { try { int id = int.Parse(Request.Form["id"]); if (new P_DepartmentBLL().GetListBy(p => p.ParentID == id).ToList().Count > 0) { return(this.JsonResult(Utility.E_JsonResult.Error, "您现在删除的部门正在被使用,请先取消此部门关联!", null, null)); } else { int res = new P_DepartmentBLL().DelBy(p => p.ID == id); if (res > 0) { return(this.JsonResult(Utility.E_JsonResult.OK, "删除成功!", null, null)); } else { return(this.JsonResult(Utility.E_JsonResult.OK, "删除失败!", null, null)); } } } catch (Exception ex) { return(this.JsonResult(Utility.E_JsonResult.Error, "链接数据库失败!" + ex.Message, null, "")); } }
public ActionResult SaveDepartment(Model.ViewModel.Department model) { //先查部门是否存在 如果没有新增 反正修改 if (new P_DepartmentBLL().GetModelWithOutTrace(d => d.ID == model.ID) != null) { int res = new P_DepartmentBLL().Modify(model.ToPOCO(), "Name", "ParentID", "IsActive", "Remark", "SN", "DispatchSationID", "DispatchSubCenterID"); if (res > 0) { return(this.JsonResult(Utility.E_JsonResult.OK, "修改成功!", null, null)); } else { return(this.JsonResult(Utility.E_JsonResult.Error, "修改失败!", null, null)); } } else { int res = new P_DepartmentBLL().Add(model.ToPOCO()); if (res > 0) { return(this.JsonResult(Utility.E_JsonResult.OK, "新增成功!", null, null)); } else { return(this.JsonResult(Utility.E_JsonResult.Error, "新增失败!", null, null)); } } }
public ActionResult GetDepView() { int id = int.Parse(Request.Form["id"]); var viewModel = new Model.ViewModel.Department(); if (id == -1) { viewModel.IsActive = true; viewModel.SN = 255; return(PartialView("DepartmentForm", viewModel)); } else { var tempModel = new P_DepartmentBLL().GetListBy(p => p.ID == id).FirstOrDefault(); if (tempModel != null) { viewModel.ID = tempModel.ID; viewModel.IsActive = tempModel.IsActive; viewModel.Name = tempModel.Name; viewModel.ParentID = tempModel.ParentID; viewModel.Remark = tempModel.Remark; viewModel.SN = tempModel.SN; viewModel.DispatchSationID = tempModel.DispatchSationID; viewModel.DispatchSubCenterID = tempModel.DispatchSubCenterID; } return(PartialView("DepartmentForm", viewModel)); } }
public ActionResult Index(FormCollection form) { //0.接收参数 page=1&rows=5 int pageIndex = int.Parse(form["page"]); int pageSize = int.Parse(form["rows"]); //1.读取数据 var rowCount = 0; var listData = new P_DepartmentBLL().GetDynamicPagedList(pageIndex, pageSize, ref rowCount, d => d.IsActive == true, d => d.ID, d => new { d.ID, d.Name, d.Remark, d.SN, PdepName = d.P_Department2.Name }, true).ToList(); //2.返回数据 return(Json(new Model.EasyUIModel.DataGridModel() { rows = listData, total = rowCount })); }
public ActionResult DelDepartment() { try { int id = int.Parse(Request.Form["id"]); if (new P_DepartmentBLL().GetListBy(p => p.ParentID == id).ToList().Count > 0) { return this.JsonResult(Utility.E_JsonResult.Error, "您现在删除的部门正在被使用,请先取消此部门关联!", null, null); } else { int res = new P_DepartmentBLL().DelBy(p => p.ID == id); if (res > 0) return this.JsonResult(Utility.E_JsonResult.OK, "删除成功!", null, null); else return this.JsonResult(Utility.E_JsonResult.OK, "删除失败!", null, null); } } catch (Exception ex) { return this.JsonResult(Utility.E_JsonResult.Error, "链接数据库失败!" + ex.Message, null, ""); } }
public ActionResult GetAllDepart() { var list = new P_DepartmentBLL().GetListBy(d => d.IsActive == true).ToList(); List<Model.EasyUIModel.TreeNode> listTree = Model.P_Department.ToTreeNodes(list); return Json(listTree, JsonRequestBehavior.AllowGet); }
public ActionResult SaveDepartment(Model.ViewModel.Department model) { //先查部门是否存在 如果没有新增 反正修改 if (new P_DepartmentBLL().GetModelWithOutTrace(d => d.ID == model.ID) != null) { int res = new P_DepartmentBLL().Modify(model.ToPOCO(), "Name", "ParentID", "IsActive", "Remark", "SN", "DispatchSationID", "DispatchSubCenterID"); if (res > 0) return this.JsonResult(Utility.E_JsonResult.OK, "修改成功!", null, null); else return this.JsonResult(Utility.E_JsonResult.Error, "修改失败!", null, null); } else { int res = new P_DepartmentBLL().Add(model.ToPOCO()); if (res > 0) return this.JsonResult(Utility.E_JsonResult.OK, "新增成功!", null, null); else return this.JsonResult(Utility.E_JsonResult.Error, "新增失败!", null, null); } }
public ActionResult Index(FormCollection form) { //0.接收参数 page=1&rows=5 int pageIndex = int.Parse(form["page"]); int pageSize = int.Parse(form["rows"]); //1.读取数据 var rowCount = 0; var listData = new P_DepartmentBLL().GetDynamicPagedList(pageIndex, pageSize, ref rowCount, d => d.IsActive == true, d => d.ID, d => new { d.ID, d.Name, d.Remark, d.SN, PdepName = d.P_Department2.Name }, true).ToList(); //2.返回数据 return Json(new Model.EasyUIModel.DataGridModel() { rows = listData, total = rowCount }); }