public ActionResult Edit(ProjectAssignment ProjectAssignment) { ProjectAssignment oProjectAssignment = new ProjectAssignment(); oProjectAssignment.ProjectAssignmentID = System.Convert.ToInt32(ProjectAssignment.ProjectAssignmentID); oProjectAssignment = ProjectAssignmentData.Select_Record(ProjectAssignment); if (ModelState.IsValid) { bool bSucess = false; bSucess = ProjectAssignmentData.Update(oProjectAssignment, ProjectAssignment); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Update"); } } // ComboBox ViewData["ProjectID"] = new SelectList(ProjectAssignment_ProjectData.List(), "ProjectID", "ProjectName", ProjectAssignment.ProjectID); ViewData["EmployeeID"] = new SelectList(ProjectAssignment_EmployeeData.List(), "EmployeeID", "FirstName", ProjectAssignment.EmployeeID); return(View(ProjectAssignment)); }
// GET: /ProjectAssignment/Edit/<id> public ActionResult Edit( Int32?ProjectAssignmentID ) { if ( ProjectAssignmentID == null ) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectAssignment ProjectAssignment = new ProjectAssignment(); ProjectAssignment.ProjectAssignmentID = System.Convert.ToInt32(ProjectAssignmentID); ProjectAssignment = ProjectAssignmentData.Select_Record(ProjectAssignment); if (ProjectAssignment == null) { return(HttpNotFound()); } // ComboBox ViewData["ProjectID"] = new SelectList(ProjectAssignment_ProjectData.List(), "ProjectID", "ProjectName", ProjectAssignment.ProjectID); ViewData["EmployeeID"] = new SelectList(ProjectAssignment_EmployeeData.List(), "EmployeeID", "FirstName", ProjectAssignment.EmployeeID); return(View(ProjectAssignment)); }
public ActionResult DeleteConfirmed( Int32?ProjectAssignmentID ) { ProjectAssignment ProjectAssignment = new ProjectAssignment(); ProjectAssignment.ProjectAssignmentID = System.Convert.ToInt32(ProjectAssignmentID); ProjectAssignment = ProjectAssignmentData.Select_Record(ProjectAssignment); bool bSucess = false; bSucess = ProjectAssignmentData.Delete(ProjectAssignment); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Delete"); } return(null); }
// GET: /ProjectAssignment/Delete/<id> public ActionResult Delete( Int32?ProjectAssignmentID ) { if ( ProjectAssignmentID == null ) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } dtProject = ProjectAssignment_ProjectData.SelectAll(); dtEmployee = ProjectAssignment_EmployeeData.SelectAll(); ProjectAssignment ProjectAssignment = new ProjectAssignment(); ProjectAssignment.ProjectAssignmentID = System.Convert.ToInt32(ProjectAssignmentID); ProjectAssignment = ProjectAssignmentData.Select_Record(ProjectAssignment); ProjectAssignment.Project = new Project() { ProjectID = (Int32)ProjectAssignment.ProjectID , ProjectName = (from DataRow rowProject in dtProject.Rows where ProjectAssignment.ProjectID == (int)rowProject["ProjectID"] select(String) rowProject["ProjectName"]).FirstOrDefault() }; ProjectAssignment.Employee = new Employee() { EmployeeID = (Int32)ProjectAssignment.EmployeeID , FirstName = (from DataRow rowEmployee in dtEmployee.Rows where ProjectAssignment.EmployeeID == (int)rowEmployee["EmployeeID"] select(String) rowEmployee["FirstName"]).FirstOrDefault() }; if (ProjectAssignment == null) { return(HttpNotFound()); } return(View(ProjectAssignment)); }