public ActionResult Edit(Timesheet Timesheet) { Timesheet oTimesheet = new Timesheet(); oTimesheet.TimesheetID = System.Convert.ToInt32(Timesheet.TimesheetID); oTimesheet = TimesheetData.Select_Record(Timesheet); if (ModelState.IsValid) { bool bSucess = false; bSucess = TimesheetData.Update(oTimesheet, Timesheet); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Update"); } } // ComboBox ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName", Timesheet.EmployeeID); ViewData["ProjectID"] = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName", Timesheet.ProjectID); return(View(Timesheet)); }
public ActionResult Create([Bind(Include = "EmployeeID" + "," + "ProjectID" + "," + "EntryDate" + "," + "StartTime" + "," + "EndTime" + "," + "TotTime" + "," + "Remarks" )] Timesheet Timesheet) { if (ModelState.IsValid) { bool bSucess = false; bSucess = TimesheetData.Add(Timesheet); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Insert"); } } // ComboBox ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName", Timesheet.EmployeeID); ViewData["ProjectID"] = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName", Timesheet.ProjectID); return(View(Timesheet)); }
// GET: /Timesheet/Edit/<id> public ActionResult Edit( Int32?TimesheetID ) { if ( TimesheetID == null ) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Timesheet Timesheet = new Timesheet(); Timesheet.TimesheetID = System.Convert.ToInt32(TimesheetID); Timesheet = TimesheetData.Select_Record(Timesheet); if (Timesheet == null) { return(HttpNotFound()); } // ComboBox ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName", Timesheet.EmployeeID); ViewData["ProjectID"] = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName", Timesheet.ProjectID); return(View(Timesheet)); }
// GET: /Timesheet/Create public ActionResult Create() { // ComboBox ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName"); ViewData["ProjectID"] = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName"); return(View()); }