Example #1
0
        // 刪除 ===========================================
        public ActionResult DeleteStudent(int id)
        {
            DBconnST dBconnST = new DBconnST();

            dBconnST.DeleteStudentById(id);
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult EditStudent(Student student)
        {
            DBconnST dBconnST = new DBconnST();

            dBconnST.UpdateStudent(student);
            return(RedirectToAction("Index"));
        }
Example #3
0
        // 編輯 ===========================================
        public ActionResult EditStudent(int id)
        {
            DBconnST dBconnST = new DBconnST();
            Student  student  = dBconnST.GetStudentById(id);

            return(View(student));
        }
Example #4
0
        // 首頁(顯示全部) ==================================
        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());
        }
Example #5
0
        public ActionResult CreateStudent(Student student)
        {
            DBconnST dBconnST = new DBconnST();

            try {
                dBconnST.NewStudent(student);
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
            return(RedirectToAction("Index"));
        }