页面代码
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using WebApplication1.Models
@model List<Cusm>
<form action="/Curmes/Add" method="post">
<label>输入账号</label>
<input id="Text1" name="ID" type="text" />
<label>输入账号</label>
<input id="Text1" name="IDI" type="text" />
<label>余额</label>
<input id="Text1" name="YE" type="text" />
<input type="submit" value="转账" />
</form>
<table>
<thead>
<tr>
<th>编号</th>
<th>名称</th>
<th>余额</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<th>@item.ID</th>
<th>@item.Name</th>
<th>@item.Number</th>
</tr>
}
</tbody>
</table>
后台代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class CurmesController : Controller
{
Job_dbEntities db = new Job_dbEntities();
public ActionResult Index()
{
var cus = db.Cusm.ToList();
return View(cus);
}
[HttpPost]
public ActionResult Add(int ID,int IDI,decimal YE)
{
db.CP_Ch(ID, IDI, YE);
return RedirectToAction("index");
}
}
}