设为首页 加入收藏

TOP

asp.net mvc 三层加EF 登录注册 增删改查(四)
2019-09-17 18:46:21 】 浏览:87
Tags:asp.net mvc 登录 注册 删改
0) { return Content("<script>alert('删除成功');window.location.href='/Home/Index';</script>"); } else { return Content("<script>alert('删除失败');window.location.href='/Home/Index';</script>"); } }

修改

   //修改
        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>");
            }
        }

Index视图

@{
    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>

Login视图

@{
    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>
         }

Update视图

@{
    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=&
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇.NET高级代码审计(第三课)Fastj.. 下一篇.NET高级代码审计(第四课) Java..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目