public JsonResult UpdateRoleLimitAjax() { object retJson = new { success = 0, msg = "操作失败" }; int rid = int.Parse(Request["rid"]); string r_value = Request["value"]; m_role.r_id = rid; m_role.r_value = r_value.Replace(",on", ""); JMP.MDL.jmp_role old_m_role = bll_role.GetModel(rid);//查询本次更新前的数据 bool result = bll_role.UpdateValue(m_role); if (result) { Session.Remove("dtSession"); Session["dtSession"] = bll_limit.GetUserLimitSession(UserInfo.UserId, UserInfo.UserRoleId); Logger.OperateLog("角色的权限值更新为", m_role.r_value); retJson = new { success = 1, msg = "操作成功" }; } return(Json(retJson)); }
/// <summary> /// 修改商务角色界面 /// </summary> /// <returns></returns> public ActionResult RoleAgentUpdate() { m_role = bll_role.GetModel(int.Parse(Request["rid"])); ViewBag.data = m_role; GetState(m_role.r_state); return(View()); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_role("); strSql.Append("r_name,r_value,r_state,r_type"); strSql.Append(") values ("); strSql.Append("@r_name,@r_value,@r_state,@r_type"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@r_name", SqlDbType.NVarChar, -1), new SqlParameter("@r_value", SqlDbType.NVarChar, -1), new SqlParameter("@r_state", SqlDbType.Int, 4), new SqlParameter("@r_type", SqlDbType.Int, 4) }; parameters[0].Value = model.r_name; parameters[1].Value = model.r_value; parameters[2].Value = model.r_state; parameters[3].Value = model.r_type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新权限 /// </summary> public bool UpdateValue(JMP.MDL.jmp_role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update JMP_ROLE set "); strSql.Append("r_value=@r_value"); strSql.Append(" where r_id=@r_id"); SqlParameter[] parameters = { new SqlParameter("@r_value", SqlDbType.NChar, -1), new SqlParameter("@r_id", SqlDbType.Int, 4) }; parameters[0].Value = model.r_value; parameters[1].Value = model.r_id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_role> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_role> modelList = new List <JMP.MDL.jmp_role>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_role model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_role(); if (dt.Rows[n]["r_id"].ToString() != "") { model.r_id = int.Parse(dt.Rows[n]["r_id"].ToString()); } if (dt.Rows[n]["r_type"].ToString() != "") { model.r_type = int.Parse(dt.Rows[n]["r_type"].ToString()); } model.r_name = dt.Rows[n]["r_name"].ToString(); model.r_value = dt.Rows[n]["r_value"].ToString(); if (dt.Rows[n]["r_state"].ToString() != "") { model.r_state = int.Parse(dt.Rows[n]["r_state"].ToString()); } modelList.Add(model); } } return(modelList); }
public ActionResult UpdateRoleLimit() { int rid = string.IsNullOrEmpty(Request["rid"]) ? 0 :int.Parse(Request["rid"]); int type = string.IsNullOrEmpty(Request["type"]) ? 0 : Int32.Parse(Request["type"]); if (rid > 0) { m_role = bll_role.GetModel(rid); } GetFirstHtml(m_role.r_value, type); ViewBag.rid = m_role.r_id; return(View()); }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_role GetModel(int r_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select r_id, r_name, r_value, r_state, r_type "); strSql.Append(" from jmp_role "); strSql.Append(" where r_id=@r_id"); SqlParameter[] parameters = { new SqlParameter("@r_id", SqlDbType.Int, 4) }; parameters[0].Value = r_id; JMP.MDL.jmp_role model = new JMP.MDL.jmp_role(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["r_id"].ToString() != "") { model.r_id = int.Parse(ds.Tables[0].Rows[0]["r_id"].ToString()); } model.r_name = ds.Tables[0].Rows[0]["r_name"].ToString(); model.r_value = ds.Tables[0].Rows[0]["r_value"].ToString(); if (ds.Tables[0].Rows[0]["r_state"].ToString() != "") { model.r_state = int.Parse(ds.Tables[0].Rows[0]["r_state"].ToString()); } if (ds.Tables[0].Rows[0]["r_type"].ToString() != "") { model.r_type = int.Parse(ds.Tables[0].Rows[0]["r_type"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 修改商务角色方法 /// </summary> /// <returns></returns> public JsonResult RoleAgentUpdateAjax() { object retJson = new { success = 0, msg = "操作失败" }; m_role.r_id = int.Parse(Request["rid"]); m_role.r_name = Request["name"]; m_role.r_state = int.Parse(Request["state"]); m_role.r_type = 3; JMP.MDL.jmp_role old_m_role = bll_role.GetModel(int.Parse(Request["rid"])); m_role.r_value = old_m_role.r_value; bool result = bll_role.Update(m_role); if (result) { #region 添加日志 Logger.ModifyLog("操作修改代理商角色页面", old_m_role, m_role); #endregion retJson = new { success = 1, msg = "操作成功" }; } return(Json(retJson)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_role model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_role model) { return(dal.Add(model)); }