zoukankan      html  css  js  c++  java
  • EF

    Model1 db = new Model1();
    public int add(Wsl.Model.Ram model)
    {
    db.Ram.Add(model);
    return db.SaveChanges();
    }
    public List<Ram> select() {
    List<Ram> n = db.Ram.ToList();
    return n;
    }
    public int del(int id)
    {
    Ram r = db.Ram.Find(id);
    db.Ram.Remove(r);
    return db.SaveChanges();

    }

    public Ram ft(int id)
    {
    return db.Ram.Where(m => m.id == id).FirstOrDefault();
    }

    public int update(Ram model)
    {
    Ram r = db.Ram.Where(m=>m.id==model.id).FirstOrDefault();
    r.id = model.id;
    r.Name = model.Name;
    r.pwd = model.pwd;
    r.email = model.email;
    r.ModifedDate = model.ModifedDate;
    r.Description = model.Description;
    r.CName = model.CName;
    return db.SaveChanges();
    }

    <script>

    $.ajax({
    url: "http://localhost:2678/wsl/select",
    type: "get",
    success: function (data)
    {
    $(data).each(function (i,data) {
    tr = '<tr>'
    + '<td>' + data.Name + '</td>'
    + '<td>' + data.email + '</td>'
    + '<td>' + data.pwd + '</td>'
    + '<td>' + data.CName + '</td>'
    + '<td><a href="/Index/Map?name=' + data.Description+'">' +data.Description +'</a></td>'
    + '<td>' + data.ModifedDate + '</td>'
    + '<td><input id="Button1" type="button" value="删除" onclick="del(' + data.id + ')"/><input id="Button1" type="button" value="修改" onclick="update(' + data.id + ')"/></td>'
    + '</tr>'
    $("#tab").append(tr);
    })
    }
    })
    function del(id) {
    if (confirm("确认删除吗?")) {


    $.ajax({
    url: "http://localhost:2678/wsl/del?id="+id,
    //data: { id: id },
    type: "post",
    success: function (data) {
    if (data>0) {
    aler("删除成功");
    location.href = "/Index/select"
    }

    }
    })
    }
    }

    function update(id) {
    location.href = "/Index/update?id=" + id;

    }


    </script>

    $(function(id){
    $.ajax({
    url:"http://localhost:2678/wsl/ft?id="+@ViewBag.id,
    type:"get",
    //data:{id:@ViewBag.id},
    success:function(data){
    $("#Name").val(data.Name),
    $("#email").val(data.email),
    $("#pwd").val(data.pwd),
    $("#CName").val(data.CName),
    $("#Description").val(data.Description),
    $("#ModifedDate").val(data.ModifedDate)

    }
    })
    })

    public ActionResult update(int id)
    {
    ViewBag.id = id;
    return View();
    }

  • 相关阅读:
    JVM描述符标识字符含义
    finally代码块的执行
    职业发展心之某日与领导的聊天
    springboot由于bean加载顺序导致的问题
    springboot自动配置国际化失效分析
    springboot 2.1.3.RELEASE添加filter,servlet源码学习
    jquery 数组添加不重复数据
    Oracle执行存储过程报错——ora-01031:权限不足
    oracle 存储过程使用动态sql
    将jsp页面的<s:iterator>的数据返回到action
  • 原文地址:https://www.cnblogs.com/wsl0608/p/10003080.html
Copyright © 2011-2022 走看看