{
<input type="hidden" name="DicId" value="@Model.DicId" /><!--主键-->
<input type="hidden" id="DicType" value="@Model.DicType" />
}
/// <summary>
/// 新增/修改页面-提交
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult DicEdit(Dic model)
{
bool isSuc = false;
model.RegulatoryDeptId = long.Parse(Request.Form["RegulatoryDeptSelected"].ToString());
//model.DicType = int.Parse(Request.Form["DicTypeSelected"].ToString());
//model.DicType = int.Parse(Request.QueryString["dictype"].ToString());
if (model.DicId > 0)
{
isSuc = DicService.Update(model);//修改
}
else
{
model.DicType = int.Parse(Request.Form["DicType"].ToString()); !未将对象引用至实例失败!原因是<input type="hidden" id="DicType" value="@Model.DicType" />没有name属性!
if (DicService.Exists(model.DicType,model.DicValue1))
{
return Json(new { RetCode = 0, RetMsg = "您添加的值已经存在!" });
}
isSuc = DicService.Add(model) > 0; //新增
}
var ret = new { RetCode = isSuc ? 1 : 0, RetMsg = isSuc ? "操作成功!" : "操作失败!" };
return Json(ret);
}