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 void Edit() { if (!CheckInput()) { return; } //修改 try { //从页面上取值 var sysCodeTemp = GetSysCodeFromPage(2); if (sysCodeTemp == null) { //提示消息:不存在模板 ShowMsg(false, "不存在模板"); } else { if (!Exists(sysCodeTemp)) { var res = BLL.Update(sysCodeTemp); string strContent = string.Empty; ShowMsg(res > 0, "修改成功"); } else { ShowMsg(false, "此名称已存在"); } } } catch (Exception ex) { ////MS.Authority.clsAuth.AddLogErrorFromBS(Module_Id, string.Format("类:{0},方法:{1},错误信息:{2}, 详细:{3}", ex.TargetSite.DeclaringType.ToString(), ex.TargetSite.Name.ToString(), ex.Message, ex.StackTrace)); throw ex; } }