当前位置:   article > 正文

每日雕蟲一技[2012-12-27]_dictype

dictype
@using (Html.BeginForm("DicEdit", "Dic", FormMethod.Post, new { id = "form1", name = "form1" }))

{

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/353122
推荐阅读
相关标签
  

闽ICP备14008679号