您的位置:首页 > 其它

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: