示例#1
0
 public ActionResult SaveExistProject(Project project, string activenodes, string startdate)
 {
     if (ModelState.IsValid)
     {
         if (project.Id == 0)
         {
             if (_projectRepository.FindAll().Any(x => x.ErpCode == project.ErpCode))
             {
                 return Json(new JsonResponse { Success = false, Message = "Erp帐号重复,已有该帐号的工程录入" });
             }
             if (!string.IsNullOrWhiteSpace(project.NumberOf186) && _projectRepository.FindAll().Any(x => x.NumberOf186 == project.NumberOf186))
             {
                 return Json(new JsonResponse { Success = false, Message = "传单编号重复,已有该编号的工程录入" });
             }
             project.Category = _categoryRepostitory.Find(project.CategoryId);
             _projectRepository.Add(project);
             project.TaskLogs = new Collection<TaskLog>();
             project.Documents = new Collection<Document>();
             project.GenerateTaskLog(DateTime.Parse(startdate),activenodes);
             project.GenerateDocument();
             UnitOfWork.Commit();
         }
         UnitOfWork.Commit();
         return Json(new JsonResponse { Success = true,Message = "已录入工程"+project.ErpCode+project.Name});
     }
     return Json(new JsonResponse { Success = false, Message = "不能保存,请检查输入是否正确,或者联系管理员" });
 }
示例#2
0
 public ActionResult CreatExistProject()
 {
     var model = new Project();
     ViewBag.Categories = _categoryRepostitory.FindAll().Where(x => x.ParentId.HasValue);
     return PartialView("_ExistProjectForm", model);
 }
示例#3
0
        public ActionResult Save(Project project)
        {
            if (ModelState.IsValid)
            {
                if (project.Id==0)
                {
                    if (_projectRepository.FindAll().Any(x => x.ErpCode == project.ErpCode))
                    {
                        return Json(new JsonResponse { Success = false, Message = "Erp帐号重复,已有该帐号的工程录入" });
                    }
                    if (!string.IsNullOrWhiteSpace(project.NumberOf186) && _projectRepository.FindAll().Any(x => x.NumberOf186 == project.NumberOf186))
                    {
                        return Json(new JsonResponse { Success = false, Message = "传单编号重复,已有该编号的工程录入" });
                    }
                    project.Category = _categoryRepostitory.Find(project.CategoryId);
                    project.TaskLogs = new Collection<TaskLog>();
                    project.Documents = new Collection<Document>();
                    _projectRepository.Add(project);
                    project.GenerateTaskLog(DateTime.Now.Date);
                    project.GenerateDocument();
                    var startnode = project.TaskLogs.SingleOrDefault(x => x.TaskNode.NodeFlag == 1);
                    startnode.UserId = CurrentUser.UserId;
                    startnode.Kickoff(DateTime.Now);
                    UnitOfWork.Commit();
                }
                else
                {
                   var prj = _projectRepository.Find(project.Id);
                   if (prj.ErpCode != project.ErpCode)
                    {
                        if (_projectRepository.FindAll().Any(x => x.ErpCode == project.ErpCode))
                        {
                            return Json(new JsonResponse { Success = false, Message = "Erp帐号重复,已有该帐号的工程录入" });
                        }
                    }
                    if (prj.NumberOf186 != project.NumberOf186)
                    {
                        if (!string.IsNullOrWhiteSpace(project.NumberOf186) && _projectRepository.FindAll().Any(x => x.NumberOf186 == project.NumberOf186))
                        {
                            return Json(new JsonResponse { Success = false, Message = "传单编号重复,已有该编号的工程录入" });
                        }
                    }

                    TryUpdateModel(prj);
                    UnitOfWork.Commit();
                }

                return Json(new JsonResponse { Success = true, Message = "已录入工程" + project.ErpCode + project.Name });
            }
            return Json(new JsonResponse { Success = false, Message = "不能保存,请检查输入是否正确,或者联系管理员" });
        }
示例#4
0
 //
 // GET: /Project/Create
 public ActionResult Create()
 {
     var model = new Project();
     ViewBag.Categories = _categoryRepostitory.FindAll().Where(x=>x.ParentId.HasValue);
     ViewBag.PMS = _userRepository.FindAll().ToList().Where(x => x.IsInRole("项目主任"));
     return PartialView("_ProjectForm", model);
 }