/// <summary> /// 根据Id获取项目 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult GetProjectManageById(string id) { var retModel = new JsonReturnModel(); try { var bootItem = inn.newItem("B_PROJECTMANAGE", "get"); bootItem.setAttribute("id", id); Item result = bootItem.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); return(Json(retModel, JsonRequestBehavior.AllowGet)); } ProjectManageModel model = new ProjectManageModel(); model.id = result.getProperty("id"); model.b_ProjectName = result.getProperty("b_projectname"); model.b_PmtOrPatLeaderId = result.getProperty("b_pmtorpatleaderid"); model.b_PmtOrPatLeader = result.getProperty("b_pmtorpatleader"); model.b_ProjectDirectorId = result.getProperty("b_projectdirectorid"); model.b_ProjectDirector = result.getProperty("b_projectdirector"); model.b_ProjectManagerId = result.getProperty("b_projectmanagerId"); model.b_ProjectManager = result.getProperty("b_projectmanager"); model.b_ProjectRecordNo = result.getProperty("b_projectrecordno"); model.b_IsInUse = result.getProperty("b_isinuse"); model.b_ProjectVP = result.getProperty("b_projectvp"); model.b_ApplicableCompany = result.getProperty("b_applicablecompany"); string b_sort = result.getProperty("b_sort"); b_sort = string.IsNullOrEmpty(b_sort) ? "0" : b_sort; model.b_Sort = int.Parse(b_sort); retModel.data = model; } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存数据 /// </summary> /// <returns></returns> public JsonResult SaveProjectManage(ProjectManageModel model) { var retModel = new JsonReturnModel(); try { //判断输入的项目编号是否存在 if (ProjectManageDA.isExistProjectRecordNo(inn, model.b_ProjectRecordNo, model.id)) { retModel.AddError("errorMessage", "输入的项目编号已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //验证输入的项目名称是否已经存在 if (ProjectManageDA.GetProjectManageByName(inn, model.b_ProjectName, model.id)) { retModel.AddError("errorMessage", "输入的项目名称已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //验证输入的PMT/PAT Leader 是否存在 var itemLeader = IdentityDA.GetIdentityByKeyedName(inn, model.b_PmtOrPatLeader); if (itemLeader.isError()) { retModel.AddError("errorMessage", "输入的PMT/PAT Leader不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_PmtOrPatLeaderId = itemLeader.getProperty("id"); //验证输入的项目经理是否存在 var projectManager = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectManager); if (projectManager.isError()) { retModel.AddError("errorMessage", "输入的项目经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_ProjectManagerId = projectManager.getProperty("id"); //验证输入的项目总监 是否存在 var itemDirector = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectDirector); if (itemDirector.isError()) { retModel.AddError("errorMessage", "输入的项目总监不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_ProjectDirectorId = itemDirector.getProperty("id"); //验证输入的项目VP 是否存在 var itemProjectVp = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectVP); if (itemProjectVp.isError()) { retModel.AddError("errorMessage", "输入的项目VP不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } Item item = null; if (string.IsNullOrEmpty(model.id)) { item = inn.newItem("B_PROJECTMANAGE", "add"); } else { item = inn.newItem("B_PROJECTMANAGE", "edit"); item.setAttribute("id", model.id); } item.setProperty("b_projectrecordno", model.b_ProjectRecordNo); item.setProperty("b_projectname", model.b_ProjectName); item.setProperty("b_pmtorpatleader", model.b_PmtOrPatLeader); item.setProperty("b_projectdirector", model.b_ProjectDirector); item.setProperty("b_projectdirectorid", model.b_ProjectDirectorId); item.setProperty("b_pmtorpatleaderid", model.b_PmtOrPatLeaderId); item.setProperty("b_projectmanagerid", model.b_ProjectManagerId); item.setProperty("b_projectmanager", model.b_ProjectManager); item.setProperty("b_isinuse", model.b_IsInUse); item.setProperty("b_projectvp", model.b_ProjectVP); item.setProperty("b_sort", model.b_Sort.ToString()); item.setProperty("b_applicablecompany", model.b_ApplicableCompany); var result = item.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }