protected void btnSave_Click(object sender, EventArgs e) { try { if (CheckInput()) { Common_DictModel model = new Common_DictModel(); model = GetData(); bool result = false; if (string.IsNullOrEmpty(common_dict_id))//添加 { if (bll.Exists(model, 1)) { ClientScript.RegisterStartupScript(this.GetType(), "fildSave", "<script type='text/javascript'>parent.div_PopEdit('2','已存在同名数据更新项!');</script>"); return; } else { result = bll.Add(model) > 0 ? true : false; } } else//修改 { if (bll.Exists(model, 2)) { ClientScript.RegisterStartupScript(this.GetType(), "fildSave", "<script type='text/javascript'>parent.div_PopEdit('2','已存在同名数据更新项!');</script>"); return; } else { result = bll.Update(model) > 0 ? true : false; } } if (result) { ClientScript.RegisterStartupScript(this.GetType(), "fildSave", "<script type='text/javascript'>parent.div_PopEdit('1','保存成功!','" + model.Common_Dict_ID + "');</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "fildSave", "<script type='text/javascript'>parent.div_PopEdit('2','保存失败!');</script>"); } } } catch (Exception ex) { new BLL_clsAuth().AddLogErrorFromBS(Module_Id, string.Format("类:{0},方法:{1},错误信息:{2}, 详细:{3}", ex.TargetSite.DeclaringType.ToString(), ex.TargetSite.Name.ToString(), ex.Message, ex.StackTrace)); throw ex; } }
//验证编辑是否存在 private bool Exists(Common_DictModel model) { return(BLL.Exists(model)); }