/// <summary> /// geeft lijst van reviews terug van een bepaald product /// </summary> /// <param name="naam">productnaam</param> /// <returns></returns> public List<Review> GetReview(string naam) { Review result=null; List<Review> results = new List<Review>(); string sql = "SELECT * FROM Review WHERE PRODUCT_ID in (select PRODUCT_ID from PRODUCT where NAAM ='" + naam + "')"; try { this.Connect(); OracleCommand command = this.conn.CreateCommand(); command.CommandText = sql; OracleDataReader reader2 = command.ExecuteReader(); while (reader2.Read()) { result=new Review(Convert.ToDateTime(reader2["Datum"]), Convert.ToString(reader2["REACTIE"]), Convert.ToString(reader2["TEKST"]),Convert.ToInt32(reader2["SCORE"])); results.Add(result); } } catch { return null; } this.Disconnect(); return results; }
protected void Btn_Review_Click(object sender, EventArgs e) { if (TextBox1.Text != "") { int score; if (!Int32.TryParse(Tbox_Review_score.Text, out score)) { string error = "VOER EEN NUMMER IN"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + error + "');", true); } else { string selected = TextBox1.Text; string naam = selected.Substring(6, 12); Product product = mng.GetProduct(naam); Review rev = new Review(DateTime.Now, Tbox_Review_Reactie.Text, Tbox_Review_titel.Text, Convert.ToInt32(Tbox_Review_score.Text)); mng.AddReview(1, product.Naam, rev.Titel, rev.Datum, rev.Tekst, rev.Score); LaatProductzien(product); } } else { string error = "Kies een Product"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + error + "');", true); } }