public IActionResult UpdateOrRemove(string Submits, tbProject project) { try { tbProject pro = context.tbProject.SingleOrDefault(c => c.ProjectCode.Equals(project.ProjectCode)); if (pro != null) { if (Submits.Equals("Update")) // Update { if (ModelState.IsValid) { pro.ClientName = project.ClientName; pro.ProjectName = project.ProjectName; pro.StartDate = project.StartDate; pro.EndDate = project.EndDate; pro.Cost = project.Cost; context.SaveChanges(); return(RedirectToAction("Index")); } } else //remove { context.tbProject.Remove(pro); context.SaveChanges(); return(RedirectToAction("Index")); } } } catch (Exception e) { ViewBag.Msg = e.Message; } return(View()); }
public ActionResult acceptProposal(string id) { int prjpropID = Convert.ToInt16(id); tbProjProposal projProposal = db.tbProjProposals.Where(p => p.prjpropID == prjpropID).FirstOrDefault(); tbProject proj = db.tbProjects.Where(p => p.projID == projProposal.projID).FirstOrDefault(); tbProjWorkroom model = new tbProjWorkroom(); model.projID = projProposal.projID; model.tbAwardedProj = new tbAwardedProj(); model.tbAwardedProj.projID = model.projID; model.tbAwardedProj.raID = projProposal.raID; model.tbAwardedProj.prjpropID = projProposal.prjpropID; int awModCount = Convert.ToInt32(projProposal.tbRequirementEngineer.tbClient.awardedProjects); awModCount++; projProposal.tbRequirementEngineer.tbClient.awardedProjects = Convert.ToString(awModCount); proj.status = "Analysis"; db.tbProjWorkrooms.Add(model); db.SaveChanges(); int wrID = model.wrID; TempData["page"] = "messages"; return(RedirectToAction("Messages", new { id = wrID })); }
public ViewResult UpdateOrRemove(int id) { // Where phải thêm SingleofDefault tbProject computer = context.tbProject.SingleOrDefault(c => c.ProjectCode.Equals(id)); return(View(computer)); }
public ActionResult submitProposalProj(string id, int?page) { int pageNo = page ?? 1; int projID = Convert.ToInt16(id); string username = Session["RA"].ToString(); var uName = WebSecurity.CurrentUserName; var raID = db.tbClients.Where(u => u.tbUser.tbUserCredential.username.Equals(username)).FirstOrDefault().tbRequirementEngineers.FirstOrDefault().raID; proposalViewModel model = new proposalViewModel(); tbProject proj = db.tbProjects.Find(projID); model.tbProject = proj; model.tbProjProposals = proj.tbProjProposals.ToPagedList(pageNo, 5); var prop = proj.tbProjProposals.Where(p => p.raID == raID).FirstOrDefault(); if (prop == null) { return(View(model)); } else { return(RedirectToAction("viewProposal", new { id = prop.projID })); } }
public ActionResult viewBidsProj(string id, int?page) { int projID = Convert.ToInt16(id); int pageNo = page ?? 1; proposalViewModel model = new proposalViewModel(); tbProject Project = db.tbProjects.Where(m => m.projID.Equals(projID)).FirstOrDefault(); model.tbProject = Project; model.tbProjProposals = Project.tbProjProposals.Reverse().ToPagedList <tbProjProposal>(pageNo, 8); TempData["page"] = "projects"; return(View(model)); }
public ActionResult Submission(int id, String[] modIds) { ViewBag.wrID = id; int count = modIds.Count(); int wrID = Convert.ToInt16(id); int moduleID = 0; String name = "Modules"; tbProjWorkroom wroom = db.tbProjWorkrooms.Find(wrID); tbProject project = wroom.tbAwardedProj.tbProject; for (int i = 0; i < count; i++) { moduleID = Convert.ToInt16(modIds[i]); var mod = db.tbModules.Find(moduleID); mod.status = "Analyzed"; name = mod.title; db.SaveChanges(); } int chk = 0; foreach (tbModule module in project.tbModules) { if (module.status.Equals("Analyzed")) { chk++; } } if (project.tbModules.Count == chk) { project.status = "Analyzed"; } db.SaveChanges(); if (modIds.Count() > 1) { TempData["message"] = "Modules are Submitted to " + project.tbPM.tbUser.firstName + " for review."; } else if (modIds.Count() == 1) { TempData["message"] = name + " is Submitted to " + project.tbPM.tbUser.firstName + " for review."; } return(RedirectToAction("Submission", new { id = wrID })); }
public IActionResult CreateNewProject(tbProject project) { try { if (ModelState.IsValid) { context.tbProject.Add(project); context.SaveChanges(); return(RedirectToAction("Index", "tbProject")); } else { ViewBag.Msg = "Fail"; } } catch (Exception e) { ViewBag.Msg = e.Message; } return(View()); }