//修改
public ActionResult Update(int id)
{
List<student> li = kaoshiModel.updateSelect(id);
return View(li);
}
public ActionResult updatestudent(int id, string studentname, string studentaddress, string phone)
{
int st = kaoshiModel.update(id, studentname, studentaddress, phone);
if (st>0)
{
return Content("<script>alert('修改成功');window.location.href='/Home/Index';</script>");
}
else
{
return Content("<script>alert('修改失败');window.location.href='/Home/Index';</script>");
}
}
@{
ViewBag.Title = "Index";
}
<script type="text/java script">
function Update(id) {
location.href = "/Home/Update/" + id;
}
function del(id) {
if (confirm("是否删除?")) {
location.href = '/Home/Delete/' + id;
}
}
</script>
<a href="/Home/Login">登录</a>
<table>
<tr>
<th>姓名<th>
<th>密码</th>
<th>是否停用</th>
<th colspan="2">操作</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Studentname</td>
<td>@item.phone</td>
<td>@item.Studentaddress</td>
<td><a href="#" onclick="Update(@item.Studentid)">修改</a></td>
<td><a href="#" onclick="del(@item.Studentid)">删除</a></td>
</tr>
}
</table>
@{
ViewBag.Title = "Login";
}
<h2>登录</h2>
@using (Html.BeginForm("ALogin", "Home", FormMethod.Post))
{
<input type ="text" name="studentname" placeholder="请输入姓名"/>
<input type ="password" name="phone" placeholder="请输入密码"/>
<button type="submit" class="blue" >登录</button>
<a href="/Home/Zhuce">注册</a>
}
@{
ViewBag.Title = "Update";
}
@using (Html.BeginForm("updatestudent", "Home", FormMethod.Post)) {
<table>
@foreach (var item in Model)
{
<tr>
<td>编号:</td>
<td>
<input type="text" value="@item.Studentid" name="id" readonly="readonly"/>
</td>
</tr>
<tr>
<td>姓名:</td>
<td>
<input type="text" value="@item.Studentname" name="studentname" readonly="readonly"/>
</td>
</tr>
<tr>
<td>是否停用:</td>
<td>
<input type="text" value="@item.Studentaddress" name="studentaddress"/>
</td>
</tr>
<tr>
<td>密码:</td>
<td>
<input type="text" value=&