MVC之排球比赛计分程序 ——(八)具体代码(1)
2021-07-15 11:04
标签:view bool base move elf list modified field val 一、JuController代码如下: public class JuController : Controller // public ActionResult Index() // public ActionResult Details(int id = 0) // public ActionResult Create() // [HttpPost] return View(ju); // public ActionResult Edit(int id = 0) // [HttpPost] // public ActionResult Delete(int id = 0) // [HttpPost, ActionName("Delete")] protected override void Dispose(bool disposing) 所对应的增删改查视图: 1、Index.cshtml @model IEnumerable @{ @foreach (var item in Model) { 2、Edit.cshtml @model MvcVolleyball.Models.Ju @{ @using (Html.BeginForm()) { @section Scripts { 3、Details.cshtml @model MvcVolleyball.Models.Ju @{ 4、Delete.cshtml @model MvcVolleyball.Models.Ju @{ 5、Create.cshtml @model MvcVolleyball.Models.Ju @{ @using (Html.BeginForm()) { @section Scripts { 二、ScoreController代码如下: public class ScoreController : Controller // public ActionResult Index() // public ActionResult Details(int id = 0) // public ActionResult Create() // [HttpPost] return View(score); // public ActionResult Edit(int id = 0) // [HttpPost] // public ActionResult Delete(int id = 0) // [HttpPost, ActionName("Delete")] protected override void Dispose(bool disposing) 1、Create.cshtml @model MvcVolleyball.Models.Score @{ @using (Html.BeginForm()) { @section Scripts { 2、Delete.cshtml @model MvcVolleyball.Models.Score @{ 3、Details.cshtml @model MvcVolleyball.Models.Score @{ 4、Edit.cshtml @model MvcVolleyball.Models.Score @{ @using (Html.BeginForm()) { @section Scripts { 5、Index.cshtml @model IEnumerable @{ @foreach (var item in Model) { MVC之排球比赛计分程序 ——(八)具体代码(1) 标签:view bool base move elf list modified field val 原文地址:http://www.cnblogs.com/150902yt/p/7073033.html
{
private CountScoreDBContext db = new CountScoreDBContext();
// GET: /Ju/
{
return View(db.Ju.ToList());
}
// GET: /Ju/Details/5
{
Ju ju = db.Ju.Find(id);
if (ju == null)
{
return HttpNotFound();
}
return View(ju);
}
// GET: /Ju/Create
{
return View();
}
// POST: /Ju/Create
[ValidateAntiForgeryToken]
public ActionResult Create(Ju ju)
{
if (ModelState.IsValid)
{
db.Ju.Add(ju);
db.SaveChanges();
return RedirectToAction("Index");
}
}
// GET: /Ju/Edit/5
{
Ju ju = db.Ju.Find(id);
if (ju == null)
{
return HttpNotFound();
}
return View(ju);
}
// POST: /Ju/Edit/5
[ValidateAntiForgeryToken]
public ActionResult Edit(Ju ju)
{
if (ModelState.IsValid)
{
db.Entry(ju).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(ju);
}
// GET: /Ju/Delete/5
{
Ju ju = db.Ju.Find(id);
if (ju == null)
{
return HttpNotFound();
}
return View(ju);
}
// POST: /Ju/Delete/5
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Ju ju = db.Ju.Find(id);
db.Ju.Remove(ju);
db.SaveChanges();
return RedirectToAction("Index");
}
{
db.Dispose();
base.Dispose(disposing);
}
}
ViewBag.Title = "Index";
}局分首页
@Html.ActionLink("添加局分数据", "Create")
@Html.DisplayNameFor(model => model.JUCi)
@Html.DisplayNameFor(model => model.JScore)
@Html.DisplayFor(modelItem => item.JUCi)
@Html.DisplayFor(modelItem => item.JScore)
@Html.ActionLink("编辑", "Edit", new { id=item.JId }) |
@Html.ActionLink("详细信息", "Details", new { id=item.JId }) |
@Html.ActionLink("删除", "Delete", new { id=item.JId })
}
@Html.ActionLink("返回首页", "Index","Team")
ViewBag.Title = "Edit";
}编辑
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
}
@Html.ActionLink("返回首页", "Index")
@Scripts.Render("~/bundles/jqueryval")
}
ViewBag.Title = "Details";
}详细信息
@Html.ActionLink("编辑", "Edit", new { id=Model.JId }) |
@Html.ActionLink("返回首页", "Index")
ViewBag.Title = "Delete";
}删除
确认删除?
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
|
@Html.ActionLink("返回首页", "Index")
}
ViewBag.Title = "Create";
}添加数据
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
}
@Html.ActionLink("返回首页", "Index")
@Scripts.Render("~/bundles/jqueryval")
}
{
private CountScoreDBContext db = new CountScoreDBContext();
// GET: /Score/
{
return View(db.Score.ToList());
}
// GET: /Score/Details/5
{
Score score = db.Score.Find(id);
if (score == null)
{
return HttpNotFound();
}
return View(score);
}
// GET: /Score/Create
{
return View();
}
// POST: /Score/Create
[ValidateAntiForgeryToken]
public ActionResult Create(Score score)
{
if (ModelState.IsValid)
{
db.Score.Add(score);
db.SaveChanges();
return RedirectToAction("Index");
}
}
// GET: /Score/Edit/5
{
Score score = db.Score.Find(id);
if (score == null)
{
return HttpNotFound();
}
return View(score);
}
// POST: /Score/Edit/5
[ValidateAntiForgeryToken]
public ActionResult Edit(Score score)
{
if (ModelState.IsValid)
{
db.Entry(score).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(score);
}
// GET: /Score/Delete/5
{
Score score = db.Score.Find(id);
if (score == null)
{
return HttpNotFound();
}
return View(score);
}
// POST: /Score/Delete/5
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Score score = db.Score.Find(id);
db.Score.Remove(score);
db.SaveChanges();
return RedirectToAction("Index");
}
{
db.Dispose();
base.Dispose(disposing);
}
}
ViewBag.Title = "Create";
}添加数据
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
}
@Html.ActionLink("返回分数首页", "Index")
@Scripts.Render("~/bundles/jqueryval")
}
ViewBag.Title = "Delete";
}删除
确认删除?
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
|
@Html.ActionLink("返回分数首页", "Index")
}
ViewBag.Title = "Details";
}详细信息
@Html.ActionLink("编辑", "Edit", new { id=Model.SId }) |
@Html.ActionLink("返回分数首页", "Index")
ViewBag.Title = "Edit";
}编辑
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
}
@Html.ActionLink("返回分数首页", "Index")
@Scripts.Render("~/bundles/jqueryval")
}
ViewBag.Title = "Index";
}分数首页
@Html.ActionLink("添加数据", "Create")
@Html.DisplayNameFor(model => model.AScore)
@Html.DisplayNameFor(model => model.BScore)
@Html.DisplayNameFor(model => model.Note)
@Html.DisplayFor(modelItem => item.AScore)
@Html.DisplayFor(modelItem => item.BScore)
@Html.DisplayFor(modelItem => item.Note)
@Html.ActionLink("编辑", "Edit", new { id=item.SId }) |
@Html.ActionLink("详细信息", "Details", new { id=item.SId }) |
@Html.ActionLink("删除", "Delete", new { id=item.SId })
}
@Html.ActionLink("返回局首页", "Index","Ju")