您的位置:首页 > 移动开发 > Unity3D

构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查

2014-02-23 12:53 483 查看
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查

在第八讲中,我们已经做到了怎么样分页。这一讲主要讲增删改查。第六讲的代码已经给出,里面包含了增删改,大家可以下载下来看下。这讲主要是,制作漂亮的工具栏,虽然easyui的datagrid已经自带可以设置工具栏,我们还是要提取出来,为以后权限控制做更好的准备。

前端代码没有逻辑结果,这也许是我写代码以来写得最轻松的,但也是最繁琐的,因为美工我不是强项,每一次调整都非常的困难,最后我把他调成了这样了:

@model App.Models.Sys.SysSampleModel
@using App.Common;
@using App.Models.Sys;
@using App.Admin;
@{
ViewBag.Title = "创建";
Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";

}

<script type="text/javascript">
$(function () {
$("#btnSave").click(function () {

$.ajax({
url: "/SysSample/Create",
type: "Post",
data: $("#CreateForm").serialize(),
dataType: "json",
success: function (data) {
if (data == 1) {
window.parent.frameReturnByMes("成功");
window.parent.frameReturnByReload(true);
window.parent.frameReturnByClose()
}
else {
window.parent.frameReturnByMes("失败");
}
}
});
});
});
</script>

<div class="mvctool bgb">
<a id="btnSave" style="float: left;" class="l-btn l-btn-plain"><span class="l-btn-left"><span class="l-btn-text icon-save" style="padding-left: 20px;">保存</span></span></a>
</div>
@using (Html.BeginForm("Create", "SysSample", null, FormMethod.Post, new { Id = "CreateForm" }))
{
@Html.ValidationSummary(true)
<table class="fromEditTable setTextWidth300">
<tbody>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Id):
</td>
<td style="width:310px">
@Html.EditorFor(model => model.Id)
</td>
<td>@Html.ValidationMessageFor(model => model.Id)</td>
</tr>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Name):
</td>
<td>
@Html.EditorFor(model => model.Name)
</td>
<td>
@Html.ValidationMessageFor(model => model.Name)
</td>
</tr>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Age):
</td>

<td>
@Html.EditorFor(model => model.Age)
</td>
<td>
@Html.ValidationMessageFor(model => model.Age)
</td>
</tr>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Bir):
</td>

<td>
@Html.TextBoxFor(model => model.Bir)
</td>
<td>
@Html.ValidationMessageFor(model => model.Bir)
</td>
</tr>

<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Note):
</td>

<td>
@Html.EditorFor(model => model.Note)
</td>
<td>
@Html.ValidationMessageFor(model => model.Note)
</td>
</tr>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.CreateTime):

</td>

<td>
@Html.TextBoxFor(model => model.CreateTime)

</td>
<td>
@Html.ValidationMessageFor(model => model.CreateTime)
</td>
</tr>
<tr>
<td style="width:100px; text-align:right;">
@Html.LabelFor(model => model.Photo):
</td>
<td>
@Html.TextBoxFor(model => model.Photo)

</td>

<td>
@Html.ValidationMessageFor(model => model.Photo)
</td>
</tr>
</tbody>
</table>
}


Create



下面的太简单了,修改和详细自己动手做起来吧。说得太明白东西就没什么意思了

给点提示,修改就把创建复制一份,保存的时候把url指到修改

详细就把保存去掉就可以了

查询,在Controller的GetList增加一个queryStr参数,在BLL判断是queryStr是否为空。不为空就用Linq写多个where,O了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐