diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/CoursesController.cs" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/CoursesController.cs" index 30129c44840db8dbdb57eb1d08d53e2ab9731d9c..ecd485204215d9b64149337e609604d76b05ea59 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/CoursesController.cs" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/CoursesController.cs" @@ -23,6 +23,7 @@ public class CoursesController : Controller { return View(res); } + ViewBag.keyword=keyword; var list = res.Where(x => x.CourseName.Contains(keyword)).ToList(); return View(list); } diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/ScoresController.cs" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/ScoresController.cs" index d2cc9f6a0d3f29244cb505e6eeddcb7e5caf6b2e..c41a088dc74f131f34c787f8a18f559f5417d2c6 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/ScoresController.cs" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/ScoresController.cs" @@ -13,7 +13,7 @@ public class ScoresController : Controller } public IActionResult Index(string keyword) { - var list = _db.Scores.ToList(); + var list = _db.Scores.Where(x=>!x.IsDeleted).ToList(); var stus = _db.Students.Where(x=>!x.IsDeleted).ToList(); var cours = _db.Courses.Where(x=>!x.IsDeleted).ToList(); var res = list.Select(x => { @@ -24,11 +24,16 @@ public class ScoresController : Controller x.StudentId, StudentName = tmpStu == null ? "" : tmpStu.StudentName, x.CourseId, - CourseName = tmpCourse == null ? "默认课程" : tmpCourse.CourseName, + CourseName = tmpCourse == null ? "" : tmpCourse.CourseName, x.Score }; }); - return View(res); + if(string.IsNullOrEmpty(keyword)){ + return View(res); + } + ViewBag.keyword=keyword; + var tmpList = res.Where(x=>x.StudentName.Contains(keyword) || x.CourseName.Contains(keyword) || x.Score.ToString().Contains(keyword)); + return View(tmpList); // keyword = string.IsNullOrEmpty(keyword) ? " ": keyword.Trim(); // if (string.IsNullOrEmpty(keyword)) // { @@ -39,8 +44,8 @@ public class ScoresController : Controller } public IActionResult Create() { - var students=_db.Students.ToList(); - var courses=_db.Courses.ToList(); + var students=_db.Students.Where(x=>!x.IsDeleted).ToList(); + var courses=_db.Courses.Where(x=>!x.IsDeleted).ToList(); ViewBag.Students=new SelectList(students,"Id","StudentName"); ViewBag.Courses=new SelectList(courses,"Id","CourseName"); return View(); @@ -58,6 +63,13 @@ public class ScoresController : Controller public IActionResult Edit(int id) { var obj = _db.Scores.FirstOrDefault(x=>x.Id==id); + if(obj==null){ + return NotFound(); + } + var students=_db.Students.Where(x=>!x.IsDeleted).ToList(); + var courses=_db.Courses.Where(x=>!x.IsDeleted).ToList(); + ViewBag.Students=new SelectList(students,"Id","StudentName"); + ViewBag.Courses=new SelectList(courses,"Id","CourseName"); return View(obj); } [HttpPost] @@ -69,6 +81,8 @@ public class ScoresController : Controller } obj.Score=input.Score; obj.StudentId=input.StudentId; + obj.CourseId=input.CourseId; + _db.Scores.Update(obj); _db.SaveChanges(); return RedirectToAction("Index"); } diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/StudentsController.cs" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/StudentsController.cs" index fed9938d7837009503e409ee7325a9f1e4ded6d2..da9792b6e78d91819fb9310cdf209e6d04f19534 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/StudentsController.cs" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Controllers/StudentsController.cs" @@ -57,6 +57,7 @@ public class StudentsController : Controller { return View(res); } + ViewBag.keyword=keyword; var list = res.Where(x => x.StudentCode.Contains(keyword) || x.StudentName.Contains(keyword)); return View(list); } diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Courses/Index.cshtml" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Courses/Index.cshtml" index 49c1e61088707c44cdeb3022ac9e7fa43abc65e3..ea236fba338e7bf4a34ae586d552b07fc17ff8b9 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Courses/Index.cshtml" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Courses/Index.cshtml" @@ -6,7 +6,7 @@
diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Edit.cshtml" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Edit.cshtml" index 57206bcce68564a39bea5ae8e546f6553b45f667..2fa230b2cbaf27ca2050945da701bae2ffdbce52 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Edit.cshtml" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Edit.cshtml" @@ -1,9 +1,9 @@ @model ScoreManager.Models.Scores;

- - +
+
取消保存 -
\ No newline at end of file + diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Index.cshtml" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Index.cshtml" index 0a3a066546300d6e5396526101aa649e335cd3d3..746b8733dfd1e08719aec08f324c11c6d1870cbf 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Index.cshtml" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Scores/Index.cshtml" @@ -6,7 +6,7 @@
diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Students/Index.cshtml" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Students/Index.cshtml" index ffcfec100f282902c6f7a36f64266d9de997b96d..239361373e11118e8954bc145979e758e4df3c0a 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Students/Index.cshtml" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\220\216\344\275\234\344\270\232/\346\225\264\346\225\264\344\270\211\344\270\252\350\241\250\345\221\242/ScoreManager/Views/Students/Index.cshtml" @@ -6,7 +6,7 @@
diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241225.md" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241225.md" index a4be287a1c7bf693336f14a20ffd97071a042201..e0e103449d70f29e4d6b2965278aa19feff17bfa 100644 --- "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241225.md" +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241225.md" @@ -1 +1,12 @@ -### 今天是有作业的好像,实现搜索功能————搜索后,输入的搜索文本保留 \ No newline at end of file +### 今天是有作业的好像,实现搜索功能————搜索后,输入的搜索文本保留 +```cs +ViewBag.keyword=keyword; +``` +```cshtml + +``` \ No newline at end of file diff --git "a/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241230.md" "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241230.md" new file mode 100644 index 0000000000000000000000000000000000000000..ec884494e29c94bcd17d8fad0b767d7e2fa1c9fc --- /dev/null +++ "b/\345\274\240\350\257\255\345\253\243/\350\257\276\345\240\202\347\254\224\350\256\260/20241230.md" @@ -0,0 +1,6 @@ +### 今天讲了怎么换数据库,虽然我脑子有点宕机了 +网址: + +emmmmm.......接下来的...... + +等我再捋捋叭😅 \ No newline at end of file