• 暑假对排球计分规则的更新


    需求:

    作为观众,我想知道比赛进行时的队伍比分和比赛结束时的队伍输赢

    运行图:

    代码如下:

    查看比赛队伍

      1  public class UpdateController : Controller
      2     {
      3         private 排球计分规则Context db = new 排球计分规则Context();
      4 
      5         //
      6         // GET: /Update/
      7 
      8         public ActionResult Index()
      9         {
     10             return View(db.Updates.ToList());
     11         }
     12 
     13         //
     14         // GET: /Update/Details/5
     15 
     16         public ActionResult Details(int id = 0)
     17         {
     18             Update update = db.Updates.Find(id);
     19             if (update == null)
     20             {
     21                 return HttpNotFound();
     22             }
     23             return View(update);
     24         }
     25 
     26         //
     27         // GET: /Update/Create
     28 
     29         public ActionResult Create()
     30         {
     31             return View();
     32         }
     33 
     34         //
     35         // POST: /Update/Create
     36 
     37         [HttpPost]
     38         public ActionResult Create(Update update)
     39         {
     40             if (ModelState.IsValid)
     41             {
     42                 db.Updates.Add(update);
     43                 db.SaveChanges();
     44                 return RedirectToAction("Index");
     45             }
     46 
     47             return View(update);
     48         }
     49 
     50         //
     51         // GET: /Update/Edit/5
     52 
     53         public ActionResult Edit(int id = 0)
     54         {
     55             Update update = db.Updates.Find(id);
     56             if (update == null)
     57             {
     58                 return HttpNotFound();
     59             }
     60             return View(update);
     61         }
     62 
     63         //
     64         // POST: /Update/Edit/5
     65 
     66         [HttpPost]
     67         public ActionResult Edit(Update update)
     68         {
     69             if (ModelState.IsValid)
     70             {
     71                 db.Entry(update).State = EntityState.Modified;
     72                 db.SaveChanges();
     73                 return RedirectToAction("Index");
     74             }
     75             return View(update);
     76         }
     77 
     78         //
     79         // GET: /Update/Delete/5
     80 
     81         public ActionResult Delete(int id = 0)
     82         {
     83             Update update = db.Updates.Find(id);
     84             if (update == null)
     85             {
     86                 return HttpNotFound();
     87             }
     88             return View(update);
     89         }
     90 
     91         //
     92         // POST: /Update/Delete/5
     93 
     94         [HttpPost, ActionName("Delete")]
     95         public ActionResult DeleteConfirmed(int id)
     96         {
     97             Update update = db.Updates.Find(id);
     98             db.Updates.Remove(update);
     99             db.SaveChanges();
    100             return RedirectToAction("Index");
    101         }
    102 
    103         protected override void Dispose(bool disposing)
    104         {
    105             db.Dispose();
    106             base.Dispose(disposing);
    107         }
    108     }
    109 }

    比赛队伍比分视图:

     1 @model IEnumerable<排球计分规则.Models.Update>
     2 
     3 @{
     4     ViewBag.Title = "Index";
     5 }
     6 
     7 <h2>Index</h2>
     8 
     9 <p>
    10     @Html.ActionLink("Create New", "Create")
    11 </p>
    12 <table>
    13     <tr>
    14         <th>
    15             @Html.DisplayNameFor(model => model.DName)
    16         </th>
    17         <th>
    18             @Html.DisplayNameFor(model => model.integral)
    19         </th>
    20         <th></th>
    21     </tr>
    22 
    23 @foreach (var item in Model) {
    24     <tr>
    25         <td>
    26             @Html.DisplayFor(modelItem => item.DName)
    27         </td>
    28         <td>
    29             @Html.DisplayFor(modelItem => item.integral)
    30         </td>
    31         <td>
    32             @Html.ActionLink("Edit", "Edit", new { id=item.PId }) |
    33             @Html.ActionLink("Details", "Details", new { id=item.PId }) |
    34             @Html.ActionLink("Delete", "Delete", new { id=item.PId })
    35         </td>
    36     </tr>
    37 }
    38 
    39 </table>
  • 相关阅读:
    python 表达式
    anaconda jupyter notebook 启动方法
    python3基本数据类型补充
    Python3 基本数据类型
    pycharm 与 anaconda 关联
    31.Android之常用单位px、dip、sp学习
    30.Android之百度地图简单学习
    29.Android之文本框输入自动提示学习
    28.Android之权限请求汇总
    27.Android之ImageView获取图片学习
  • 原文地址:https://www.cnblogs.com/chen-bo/p/7511659.html
Copyright © 2020-2023  润新知