// 刪除 =========================================== public ActionResult DeleteStudent(int id) { DBconnST dBconnST = new DBconnST(); dBconnST.DeleteStudentById(id); return(RedirectToAction("Index")); }
public ActionResult EditStudent(Student student) { DBconnST dBconnST = new DBconnST(); dBconnST.UpdateStudent(student); return(RedirectToAction("Index")); }
// 編輯 =========================================== public ActionResult EditStudent(int id) { DBconnST dBconnST = new DBconnST(); Student student = dBconnST.GetStudentById(id); return(View(student)); }
// 首頁(顯示全部) ================================== public ActionResult Index(String type = "M") { DBconnST dBconnST = new DBconnST(); List <Student> students = dBconnST.GetStudents(); // .排序方法( 一筆資料的代稱 => 要排序的欄位 ).轉換成List(); students = students.Where(student => student.St_Type == type).ToList(); ViewBag.students = students; return(View()); }
public ActionResult CreateStudent(Student student) { DBconnST dBconnST = new DBconnST(); try { dBconnST.NewStudent(student); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(RedirectToAction("Index")); }