/// <summary> /// 保存员工档案 /// </summary> /// <param name="staff">需要保存的员工档案</param> /// <returns>是否成功</returns> public bool SaveStaff(Staff staff) { //throw new NotImplementedException(); IStaffDAL dAL = new StaffDAL(); if (dAL.QueryById(staff.Id) != null) { if (dAL.Update(staff) > 0) { return(true); } else { return(false); } } else { if (dAL.Add(staff) > 0) { return(true); } else { return(false); } } }
public ActionResult Edit(Staff staff) { if (ModelState.IsValid) { //Update staff record to database staffContext.Update(staff); TempData["SuccessMessage"] = "Status for " + staff.StaffName + " successfully updated."; return(RedirectToAction("Index")); } else { //Input validation fails, return to the view //to display error message TempData["ErrorMessage"] = "Error, please try again."; return(View(staff)); } }
public ActionResult Edit(Staff staff) { // Get branch list for drop-down list // in case of the need to return to Edit.cshtml view ViewData["BranchList"] = GetAllBranches(); if (ModelState.IsValid) { // Update staff record to database staffContext.Update(staff); return(RedirectToAction("Index")); } else { // Input validation fails, return to the view // to display error message return(View(staff)); } }
public void Update(Staff staff) { StaffDAL.Update(staff); }