public ActionResult SaveEmployee(Employee e, string BtnSubmit) { switch (BtnSubmit) { case "Save Employee": //Employee e = new Employee(); //e.FirstName = Request.Form["FName"]; //e.LastName = Request.Form["LName"]; //e.Salary = int.Parse(Request.Form["Salary"]); //SalesERPDAL saleDal = new SalesERPDAL(); //saleDal.SaveEmployee(e); //return Content(e.FirstName + "|" + e.LastName + "|" + e.Salary); if (ModelState.IsValid) { //Employee e = new Employee(); //e.FirstName = Request.Form["FirstName"]; //e.LastName = Request.Form["LastName"]; //e.Salary = int.Parse(Request.Form["Salary"]); SalesERPDAL saleDal = new SalesERPDAL(); saleDal.SaveEmployee(e); return(Content(e.FirstName + "|" + e.LastName + "|" + e.Salary)); } else { CreateEmployeeViewModel vm = new CreateEmployeeViewModel(); vm.FirstName = e.FirstName; vm.LastName = e.LastName; vm.Salary = e.Salary.ToString(); return(View("CreateEmployee", vm)); } case "Cancel": // 有bug,跳转地址错误 return(RedirectToAction("Index")); } return(new EmptyResult()); }
public void SaveEmployee(Employee e) { SalesERPDAL.SaveEmployee(e); }