Mvc 修改


@{
    ViewBag.Title = "Update";
}
<h2>Update</h2>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<div>
    <table>
        <tr>
            <td>日志标题</td>
            <td><input id="Title" type="text" /></td>
        </tr>
        <tr>
            <td>日志类型</td>
            <td>
                <select id="LogTypeName">
                </select>
            </td>
        </tr>
        <tr>
            <td>发布人</td>
            <td><input id="Issuer" type="text" /></td>
        </tr>
        <tr>
            <td>执行时间</td>
            <td><input id="ExeTime" type="date" /></td>
        </tr>
        <tr>
            <td>日志内容</td>
            <td><input id="Context" type="text" /></td>
        </tr>
    </table>
    <input id="save" type="button" value="修改" />
    <input id="Button1" type="button" value="取消" onclick="location.href = '/log/RecordList'" />
</div>
<script>
    $(function () {
        var SID = window.location.toString().split("?")[1].split("=")[1];
        Type();
        Update(SID);
        $("#save").click(function () {
            var obj = {};
            obj.ID = SID;
            obj.Title = $("#Title").val();
            obj.Lid = $("#LogTypeName").val();
            obj.Issuer = $("#Issuer").val();
            obj.ExeTime = $("#ExeTime").val();
            obj.Context = $("#Context").val();
            $.ajax({
                url: "http://localhost:51251/api/Update",
                data: { model: JSON.stringify(obj) },
                dataType: "text",
                type: "GET",
                success: function (result) {
                    if (result > 0) {
                        alert("修改成功");
                        location.href = '/log/RecordList';
                    }
                    else {
                        alert("修改失败");
                    }
                }
            });
        });
    });
    function Type() {
        $.ajax({
            url: "http://localhost:51251/api/ShowType",
            data: null,
            dataType: "text",
            type: "get",
            success: function (result) {
                var std = JSON.parse(result);
                $(std).each(function (i, n) {
                    $("#LogTypeName").append("<option value='" + n.ID + "'>" + n.LogTypeName + "</option>");
                });
            }
        });
    }
    function Update(ID) {
        $.ajax({
            url: "http://localhost:51251/api/Rebellion",
            data: {ID: ID },
            dataType: "json",
            type: "get",
            success: function (result) {
                $("#Title").val(result.Title);
                $("#LogTypeName").val(result.LogTypeName);
                $("#Issuer").val(result.Issuer);
                $("#ExeTime").val(result.ExeTime);
                $("#Context").val(result.Context);
            }
        });
    }
</script>
 
 ///**//
   //问框框反填
        public RedPacketModel Show(string id)
        {
            string sql = "select * from RedPacket where ID=" + id + "";
            return dal.Query<RedPacketModel>(sql).First();
        }
  /// <summary>
        /// 反填
        /// </summary>
        [Route("api/Rebellion")]
        [HttpGet]
        public RedPacketModel Rebellion(string ID)
        {
            return bll.Show(ID);
        }
posted @ 2020-07-07 15:41  我们好像在那见过  阅读(137)  评论(0编辑  收藏  举报