MVC修改 (当前页面开启Dialog,不用Ifram)
2015-09-21 19:33
309 查看
//修改
function Edit(op) {
if ($('#CarType').datagrid("getRows").length == 0) { return; } //是否有信息
_opItem = op;
AjaxCall("/BaseInfo/CarType/GetCarTypeInfo", { ID: _Row.ID }, function (res) {
OpenDialog();
$('#CarTypeInfoFrom').form('clear');
$("#CarTypeInfoFrom").form("load", res);
});
}
//模态对话框
function OpenDialog() {
$("#CarTypeInfo").show();
$("#CarTypeInfo").dialog({
title: "车型信息",
width: 700,
height: 300,
draggable: true,
resizable: false,
modal: true,
buttons:
[
{
text: '保存',
iconCls: 'icon-save',
handler: function () {
Save();
}
},
{
text: '取消',
handler: function () {
$("#CarTypeInfo").dialog('close');
}
}
]
});
}
///保存信息
function Save() {
if (!$("#CarTypeInfoFrom").valid()) return;//表单验证
var CarType = $("#CarTypeInfoFrom").JsonData();
var rows = $("#CarType").datagrid("getRows");
AjaxCall("/BaseInfo/CarType/SaveCarType", { CarType: CarType }, function (res) {
if (res == 1) {
$.messager.alert('提示', "保存成功", 'info', function () {
$("#CarTypeInfo").dialog("close");
GetCarType(_pageIndex, _pageSize);
});
}
else if (res == -1) {
$.messager.alert('错误', '输入的信息已存在!', 'error');
}
else {
$.messager.alert('错误', '保存失败', 'error');
}
});
}
/////////////////////////////////////////////////
@*添加,修改框*@
<div id="CarTypeInfo" title="车型信息" style="display:none;">
<form id="CarTypeInfoFrom" action="">
<input type="hidden" id="hd_ID" name="ID" dn="ID" value="" />
<div style="padding:5px;">
<table class="gridtable" width="100%">
<tr>
<td valign="middle" class="title">首字母:</td>
<td valign="middle" class="content">
<input id="txt_sFirstLetter" name="sFirstLetter" dn="sFirstLetter" type="text" maxlength="2" class="{required:true,isEnglish:true} form-input"/>
</td>
<td valign="middle" class="title">品牌:</td>
<td valign="middle" class="content">
<input id="txt_sBrand" name="sBrand" dn="sBrand" type="text" maxlength="50" class="{required:true} form-input" placeholder="请输入品牌名称"/>
</td>
</tr>
<tr>
<td valign="middle" class="title">厂商:</td>
<td valign="middle" class="content">
<input id="txt_sFirm" name="sFirm" dn="sFirm" maxlength="50" class="{required:true} form-input" placeholder="请输入厂商名称">
</td>
<td valign="middle" class="title">型号:</td>
<td valign="middle" class="content">
<input id="txt_sModel" name="sModel" dn="sModel" maxlength="50" class="{required:true} form-input" placeholder="请输入型号名称">
</td>
</tr>
<tr>
<td valign="middle" class="title">年代款型:</td>
<td valign="middle" class="content" colspan="3">
<input id="txt_iYearsStyle" name="iYearsStyle" dn="iYearsStyle" style="width:488px;" maxlength="100" class="{required:true} form-input">
</td>
</tr>
<tr>
<td valign="middle" class="title">排量:</td>
<td valign="middle" class="content">
<input id="txt_sDisplacement" name="sDisplacement" dn="sDisplacement" maxlength="20">
</td>
<td valign="middle" class="title">变速箱型号:</td>
<td valign="middle" class="content">
<input id="txt_sTransmissionMmodel" name="sTransmissionMmodel" dn="sTransmissionMmodel" maxlength="50">
</td>
</tr>
<tr>
<td valign="middle" class="title">发动机类型:</td>
<td valign="middle" class="content">
<input id="txt_sEngine" name="sEngine" dn="sEngine" maxlength="50">
</td>
<td valign="middle" class="title">指导价:</td>
<td valign="middle" class="content">
<input id="txt_iGuidedPrice" name="iGuidedPrice" dn="iGuidedPrice" maxlength="10" class="{number:true} form-input" placeholder="请输入数字指导价">万
</td>
</tr>
@* <tr>
<td valign="middle" class="title">结构特点:</td>
<td valign="middle" class="content">
<input id="txt_sStructure" name="sStructure" dn="sStructure" maxlength="50">
</td>
<td valign="top" class="title" >级别:</td>
<td valign="middle" class="content">
<select id="SLevel" name="sLevel" dn="sLevel" style="width:153px;">
@foreach (Common.EnumItem item in (List<Common.EnumItem>)ViewBag.CTsLevel)
{
<option value="@(item.Value)">@item.Text</option>
}
</select>
</td>
</tr>*@
</table>
</div>
</form>
</div>
控制器
public int SaveCarType(EHECD_CarType CarType)
{
CarTypeBll bll = new CarTypeBll();
return bll.SaveCarType(CarType);
}
function Edit(op) {
if ($('#CarType').datagrid("getRows").length == 0) { return; } //是否有信息
_opItem = op;
AjaxCall("/BaseInfo/CarType/GetCarTypeInfo", { ID: _Row.ID }, function (res) {
OpenDialog();
$('#CarTypeInfoFrom').form('clear');
$("#CarTypeInfoFrom").form("load", res);
});
}
//模态对话框
function OpenDialog() {
$("#CarTypeInfo").show();
$("#CarTypeInfo").dialog({
title: "车型信息",
width: 700,
height: 300,
draggable: true,
resizable: false,
modal: true,
buttons:
[
{
text: '保存',
iconCls: 'icon-save',
handler: function () {
Save();
}
},
{
text: '取消',
handler: function () {
$("#CarTypeInfo").dialog('close');
}
}
]
});
}
///保存信息
function Save() {
if (!$("#CarTypeInfoFrom").valid()) return;//表单验证
var CarType = $("#CarTypeInfoFrom").JsonData();
var rows = $("#CarType").datagrid("getRows");
AjaxCall("/BaseInfo/CarType/SaveCarType", { CarType: CarType }, function (res) {
if (res == 1) {
$.messager.alert('提示', "保存成功", 'info', function () {
$("#CarTypeInfo").dialog("close");
GetCarType(_pageIndex, _pageSize);
});
}
else if (res == -1) {
$.messager.alert('错误', '输入的信息已存在!', 'error');
}
else {
$.messager.alert('错误', '保存失败', 'error');
}
});
}
/////////////////////////////////////////////////
@*添加,修改框*@
<div id="CarTypeInfo" title="车型信息" style="display:none;">
<form id="CarTypeInfoFrom" action="">
<input type="hidden" id="hd_ID" name="ID" dn="ID" value="" />
<div style="padding:5px;">
<table class="gridtable" width="100%">
<tr>
<td valign="middle" class="title">首字母:</td>
<td valign="middle" class="content">
<input id="txt_sFirstLetter" name="sFirstLetter" dn="sFirstLetter" type="text" maxlength="2" class="{required:true,isEnglish:true} form-input"/>
</td>
<td valign="middle" class="title">品牌:</td>
<td valign="middle" class="content">
<input id="txt_sBrand" name="sBrand" dn="sBrand" type="text" maxlength="50" class="{required:true} form-input" placeholder="请输入品牌名称"/>
</td>
</tr>
<tr>
<td valign="middle" class="title">厂商:</td>
<td valign="middle" class="content">
<input id="txt_sFirm" name="sFirm" dn="sFirm" maxlength="50" class="{required:true} form-input" placeholder="请输入厂商名称">
</td>
<td valign="middle" class="title">型号:</td>
<td valign="middle" class="content">
<input id="txt_sModel" name="sModel" dn="sModel" maxlength="50" class="{required:true} form-input" placeholder="请输入型号名称">
</td>
</tr>
<tr>
<td valign="middle" class="title">年代款型:</td>
<td valign="middle" class="content" colspan="3">
<input id="txt_iYearsStyle" name="iYearsStyle" dn="iYearsStyle" style="width:488px;" maxlength="100" class="{required:true} form-input">
</td>
</tr>
<tr>
<td valign="middle" class="title">排量:</td>
<td valign="middle" class="content">
<input id="txt_sDisplacement" name="sDisplacement" dn="sDisplacement" maxlength="20">
</td>
<td valign="middle" class="title">变速箱型号:</td>
<td valign="middle" class="content">
<input id="txt_sTransmissionMmodel" name="sTransmissionMmodel" dn="sTransmissionMmodel" maxlength="50">
</td>
</tr>
<tr>
<td valign="middle" class="title">发动机类型:</td>
<td valign="middle" class="content">
<input id="txt_sEngine" name="sEngine" dn="sEngine" maxlength="50">
</td>
<td valign="middle" class="title">指导价:</td>
<td valign="middle" class="content">
<input id="txt_iGuidedPrice" name="iGuidedPrice" dn="iGuidedPrice" maxlength="10" class="{number:true} form-input" placeholder="请输入数字指导价">万
</td>
</tr>
@* <tr>
<td valign="middle" class="title">结构特点:</td>
<td valign="middle" class="content">
<input id="txt_sStructure" name="sStructure" dn="sStructure" maxlength="50">
</td>
<td valign="top" class="title" >级别:</td>
<td valign="middle" class="content">
<select id="SLevel" name="sLevel" dn="sLevel" style="width:153px;">
@foreach (Common.EnumItem item in (List<Common.EnumItem>)ViewBag.CTsLevel)
{
<option value="@(item.Value)">@item.Text</option>
}
</select>
</td>
</tr>*@
</table>
</div>
</form>
</div>
控制器
public int SaveCarType(EHECD_CarType CarType)
{
CarTypeBll bll = new CarTypeBll();
return bll.SaveCarType(CarType);
}
相关文章推荐
- ocp-v13-612
- 对oracle中date/timestamp的操作
- stm32f407使用OV7725使用迭代阈值法进行图像二值化,图像分割
- jQuery实现图片懒加载
- 【链表项目1 - 建立单链表】
- 传球游戏
- SQLServer 2012 包含数据库(Contained Databases)
- 设计一个getMin功能的栈,如果面试官让你写一个数组类,一定不要用指针去管理new出来原生的数组,那就是在给自己挖坑
- 进程间通信方法
- 02-Block和typedef
- Spring JDBC 执行sql并下载执行sql的数据
- js数组的迭代器方法(some、every、forEach、map、filter)
- BAT 笔记
- 捡到8000块钱的滋味
- 如何通过ISO安装win7程序
- Android Handler 异步消息处理机制 《第一行代码》
- fstream
- shell中条件判断if中的-a到-z的意思
- IOS 不同的 UIViewController 之间如何跳转
- 卸载oracle11g