public static bool AlterarPermissao(Permissoes permissao) { try { MontadorSql mont = new MontadorSql("permissoes_web", MontadorType.Update); mont.AddField("perm_permite", permissao.Perm_permite); mont.SetWhere("WHERE usu_id = " + permissao.Usuario.Usu_id + " AND mod_id = " + permissao.Modulo.Mod_id, null); BD BD = new BD(); int alterou = BD.ExecuteNoQuery(mont.GetSqlString(), mont.GetParams()); return(alterou == 1); } catch (Exception ex) { throw new Exception("Erro ao alterar permissão: " + ex.Message); } }
public static bool GetPermissao(int usu_id, string mod_nome) { SqlParamsList ps = new SqlParamsList(); ps.Add(new Fields("usuid", usu_id)); ps.Add(new Fields("modnome", mod_nome)); string sql = "SELECT perm.perm_permite"; sql += " FROM Permissoes_Web perm"; sql += " JOIN Modulos_Web mod ON perm.mod_id = mod.mod_id"; sql += " WHERE perm.usu_id = @usuid"; sql += " AND mod.mod_nome = @modnome"; BD BD = new BD(); DataRow row = BD.GetOneRow(sql, ps); Permissoes permissao = new Permissoes(); permissao.Perm_permite = row["perm_permite"].ToString(); return(permissao.Perm_permite.Equals("S")); }