protected void btnSave_Click(object sender, EventArgs e) { //设置权益 if (!VerifyPurview(",SM-SET,")) { Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE); return; } if (mid <= 0 || mcode.Length == 0) { Alert.ShowInParent("参数错误"); return; } string strErr = String.Empty; int num = 1; string name = HttpUtility.HtmlEncode(txtName.Text.Trim()); if (name.Length == 0) { strErr += num + "、权益名称不能为空 <br />"; num++; } string code = HttpUtility.HtmlEncode(txtCode.Text.Trim()); if (code.Length == 0) { strErr += num + "、权益编码不能为空 <br />"; } if (strErr.Length > 0) { Alert.ShowInParent(strErr); return; } PCModel model = new PCModel(); model.Id = Convert.ToInt32(txtID.Text); model.Name = name; model.Code = mcode + "-" + code; model.MenuId = mid; model.Disabled = chkDisabled.Checked; string tipTitle = model.Id == 0 ? "添加" : "修改"; int result = new PCBLL().Save(model); if (result > 0) { BindData(); } else if (result == -10000) { Alert.ShowInParent("存在相同的权益编码"); } else { Alert.ShowInParent(tipTitle + "数据失败"); } }
/// <summary> /// 保存一条数据 /// </summary> public int Save(ADT.XingZhi.Models.S.MenuPurviewCode model) { try { SqlParameter[] param = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@menuid", SqlDbType.Int), new SqlParameter("@name", SqlDbType.VarChar, 50), new SqlParameter("@code", SqlDbType.VarChar, 20), new SqlParameter("@disabled", SqlDbType.Bit), new SqlParameter("@result", SqlDbType.Int) }; param[0].Value = model.Id; param[1].Value = model.MenuId; param[2].Value = model.Name; param[3].Value = model.Code; param[4].Value = model.Disabled; param[5].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.StoredProcedure, "sp_save_S_MENU_PURVIEWCODE", param); return(Convert.ToInt32(param[5].Value)); } catch (ArgumentNullException ex) { logger.Error("调用方法Save(ADT.XingZhi.Models.S.MenuPurviewCode model)发生ArgumentNullException", ex); } catch (SqlException ex) { logger.Error("调用方法Save(ADT.XingZhi.Models.S.MenuPurviewCode model)发生SqlException", ex); } catch (Exception ex) { logger.Error("调用方法Save(ADT.XingZhi.Models.S.MenuPurviewCode model)发生Exception", ex); } return(-1); }
/// <summary> /// 保存一条数据 /// </summary> public int Save(ADT.XingZhi.Models.S.MenuPurviewCode model) { return(dal.Save(model)); }