protected void Page_Load(object sender, EventArgs e) { //ACTIVE DIRECTORY SearchResult rs = (SearchResult)Session["directsearch"]; if (rs.GetDirectoryEntry().Properties["samaccountname"].Value != null) { lblDbNaam.Text = "Username : "******"samaccountname"].Value.ToString(); } //ACTIVE DIRECTORY ab = new AccountBijdrage(); b = new Bijdrage(); bs = new Bestand(); ber = new Bericht(); c = new Categorie(); c.getSUBCategorie(); foreach (Categorie cat in c.categorieen) { Button ButtonChange = new Button(); ButtonChange.Height = 100; ButtonChange.Width = 120; ButtonChange.Text = cat.Naam; ButtonChange.ID = "id" + cat.BijdrageID.ToString(); ButtonChange.Font.Size = FontUnit.Point(7); ButtonChange.ControlStyle.CssClass = "button"; ButtonChange.Click += new EventHandler(wbtn_Click); // ButtonChange.OnClientClick = "return false"; // ButtonChange.CausesValidation = false; pnlMappen.Controls.Add(ButtonChange); } if (!IsPostBack) { //Toevoegen van de bestand namen in de listbox bs.GetBestand(); foreach (Bestand bstnd in bs.bestanden) { lbBestanden.Items.Add(bstnd.ToString()); } ber.GetBericht(); foreach (Bericht brcht in ber.Berichten) { //BUG: Berichten worden opnieuw ingeladen als er op de knop gedrukt wordt. //int eindPos = brcht.ToString().IndexOf("*", 0); //lbPosts.Items.Add(brcht.ToString().Substring(0,eindPos)); lbPosts.Items.Add(brcht.ToString()); } } }
public void GetBericht() { string bijdrageID = (String)System.Web.HttpContext.Current.Session["categorie"]; using (DbConnection con = OracleClientFactory.Instance.CreateConnection()) { if (con == null) { //return "Error! No Connection"; } con.ConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; con.Open(); DbCommand com = OracleClientFactory.Instance.CreateCommand(); if (com == null) { //return "Error! No Command"; } com.Connection = con; com.CommandText = @"SELECT ""bijdrage_id"", ""titel"", ""inhoud"" FROM BERICHT WHERE ""titel"" IS NOT NULL"; DbDataReader reader = com.ExecuteReader(); try { Bericht b; Berichten.Clear(); while (reader.Read()) { string titel; try { titel = reader.GetString(1); } catch { titel = ""; } b = new Bericht(reader.GetInt32(0), titel, reader.GetString(2)); Berichten.Add(b); } } catch (NullReferenceException) { } } }
public void GetReacties() { Berichten.Clear(); string bijdrageID = (String)System.Web.HttpContext.Current.Session["bijdrage"]; using (DbConnection con = OracleClientFactory.Instance.CreateConnection()) { if (con == null) { //return "Error! No Connection"; } con.ConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; con.Open(); DbCommand com = OracleClientFactory.Instance.CreateCommand(); if (com == null) { //return "Error! No Command"; } com.Connection = con; com.CommandText = @"SELECT b.""inhoud"" FROM bijdrage bij, bericht b, bijdrage_bericht bb WHERE bij.id = bb.""bijdrage_id"" AND bb.""bericht_id"" = b.""bijdrage_id"" AND bij.id = " + bijdrageID; DbDataReader reader = com.ExecuteReader(); try { Bericht b; Berichten.Clear(); while (reader.Read()) { b = new Bericht(reader.GetString(0)); Reacties.Add(b); } } catch (NullReferenceException) { } } }