/// <summary> /// 获取多角色的操作权限(汇总) /// </summary> /// <param name="roles"></param> /// <returns></returns> public List <ITC_RoleOperator_M> GetRoleOperater(List <ITC_Roles_M> roles) { List <ITC_RoleOperator_M> list_power = new List <ITC_RoleOperator_M>(); if (roles != null && roles.Count > 0) { string where_rol = "Role_ID in ("; foreach (ITC_Roles_M r in roles) { where_rol += "'" + r.Role_ID + "',"; } where_rol = where_rol.TrimEnd(','); where_rol += ") and RoleOperator_Status=0"; string sql = string.Format("select Menu_ID,Buttons_ID from ITC_RoleOperator where {0} and RoleOperator_Status=0 group by Menu_ID,Buttons_ID", where_rol); DataSet ds = DbHelperSQL.Query(sql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ITC_RoleOperator_M model = null; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { model = new ITC_RoleOperator_M(); model.Menu_ID = ds.Tables[0].Rows[i]["Menu_ID"].ToString().Trim(); model.Buttons_ID = ds.Tables[0].Rows[i]["Buttons_ID"].ToString().Trim(); list_power.Add(model); } } } return(list_power); }
/// <summary> /// 获得数据列表 /// </summary> public List <ITC_RoleOperator_M> GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM ITC_RoleOperator "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } DataSet ds = DbHelperSQL.Query(strSql.ToString()); List <ITC_RoleOperator_M> list = new List <ITC_RoleOperator_M>(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ITC_RoleOperator_M model = new ITC_RoleOperator_M(); model.Role_ID = ds.Tables[0].Rows[i]["Role_ID"].ToString(); model.Menu_ID = ds.Tables[0].Rows[i]["Menu_ID"].ToString(); model.Buttons_ID = ds.Tables[0].Rows[i]["Buttons_ID"].ToString(); if (ds.Tables[0].Rows[i]["RoleOperator_createdtime"].ToString() != "") { model.RoleOperator_createdtime = DateTime.Parse(ds.Tables[0].Rows[i]["RoleOperator_createdtime"].ToString()); } if (ds.Tables[0].Rows[i]["RoleOperator_Status"].ToString() != "") { model.RoleOperator_Status = int.Parse(ds.Tables[0].Rows[i]["RoleOperator_Status"].ToString()); } model.RoleOperator_oprt = ds.Tables[0].Rows[i]["RoleOperator_oprt"].ToString(); list.Add(model); } return(list); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ITC_RoleOperator_M model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ITC_RoleOperator set "); strSql.Append(" Menu_ID = @Menu_ID , "); strSql.Append(" Buttons_ID = @Buttons_ID , "); strSql.Append(" RoleOperator_createdtime = @RoleOperator_createdtime , "); strSql.Append(" RoleOperator_Status = @RoleOperator_Status , "); strSql.Append(" RoleOperator_oprt = @RoleOperator_oprt "); strSql.Append(" where Role_ID=@Role_ID "); SqlParameter[] parameters = { new SqlParameter("@Role_ID", SqlDbType.VarChar, 10), new SqlParameter("@Menu_ID", SqlDbType.VarChar, 10), new SqlParameter("@Buttons_ID", SqlDbType.VarChar, 10), new SqlParameter("@RoleOperator_createdtime", SqlDbType.DateTime), new SqlParameter("@RoleOperator_Status", SqlDbType.Bit, 1), new SqlParameter("@RoleOperator_oprt", SqlDbType.VarChar, 10) }; parameters[0].Value = model.Role_ID; parameters[1].Value = model.Menu_ID; parameters[2].Value = model.Buttons_ID; parameters[3].Value = model.RoleOperator_createdtime; parameters[4].Value = model.RoleOperator_Status; parameters[5].Value = model.RoleOperator_oprt; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 验证当前用户权限 /// </summary> /// <param name="menuid">菜单ID</param> /// <param name="buttonid">操作ID</param> /// <returns></returns> public static bool CheckPower(string menuid, string buttonid) { if (Power != null) { ITC_RoleOperator_M usropt = Power.Find( delegate(ITC_RoleOperator_M opt) { return(opt.Menu_ID == menuid && opt.Buttons_ID == buttonid); }); if (usropt != null) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ITC_RoleOperator_M model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ITC_RoleOperator("); strSql.Append("Role_ID,Menu_ID,Buttons_ID,RoleOperator_createdtime,RoleOperator_Status,RoleOperator_oprt"); strSql.Append(") values ("); strSql.Append("@Role_ID,@Menu_ID,@Buttons_ID,@RoleOperator_createdtime,@RoleOperator_Status,@RoleOperator_oprt"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@Role_ID", SqlDbType.VarChar, 10), new SqlParameter("@Menu_ID", SqlDbType.VarChar, 10), new SqlParameter("@Buttons_ID", SqlDbType.VarChar, 10), new SqlParameter("@RoleOperator_createdtime", SqlDbType.DateTime), new SqlParameter("@RoleOperator_Status", SqlDbType.Bit, 1), new SqlParameter("@RoleOperator_oprt", SqlDbType.VarChar, 10) }; parameters[0].Value = model.Role_ID; parameters[1].Value = model.Menu_ID; parameters[2].Value = model.Buttons_ID; parameters[3].Value = model.RoleOperator_createdtime; parameters[4].Value = model.RoleOperator_Status; parameters[5].Value = model.RoleOperator_oprt; int result = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (result > 0) { return(true); } else { return(false); } }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(ITC_RoleOperator_M model) { return(dal.Update(model)); }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(ITC_RoleOperator_M model) { return(dal.Add(model)); }