예제 #1
0
        private void UpdateGridViews()
        {
            DataTable dt = dbmngr.GetProductInfo(PNaam);
            DataTable dt2 = new DataTable();
            for (int i = 0; i <= dt.Rows.Count; i++)
            {
                dt2.Columns.Add();
            }
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                dt2.Rows.Add();
                dt2.Rows[i][0] = dt.Columns[i].ColumnName;
            }
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    dt2.Rows[i][j + 1] = dt.Rows[j][i];
                }
            }
            ItemTable.DataSource = dt2;
            ItemTable.ShowHeader = false;
            ItemTable.DataBind();

            product = dbmngr.GetProduct(PNaam);
            TitleProd.Text = product.Naam;

            PricesTable.DataSource = product.Prijzen;
            PricesTable.DataBind();

            ReviewTable.DataSource = product.Reviews;
            ReviewTable.DataBind();
        }
예제 #2
0
 public Product GetProduct(string naam)
 {
     Product p = null;
     string pnaam = null;
     string merk = null;
     string afbeelding = null;
     string sql = @"SELECT naam, merk, afbeelding_url FROM Product WHERE Naam= :Naam";
     try
     {
         conn.Open();
         OracleCommand cmd = new OracleCommand(sql, conn);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add("Naam", OracleDbType.Varchar2, naam, ParameterDirection.Input);
         OracleDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             pnaam = reader.GetOracleString(0).ToString();
             merk = reader.GetOracleString(1).ToString();
             afbeelding = reader.GetOracleString(2).ToString();
         }
     }
     catch { }
     finally
     {
         conn.Close();
     }
     //Get Price list
     List<Prijs> prijzen = new List<Prijs>();
     sql = @"SELECT product, winkel, prijs FROM Prijs WHERE Product= :Naam";
     try
     {
         conn.Open();
         OracleCommand cmd = new OracleCommand(sql, conn);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add("Naam", OracleDbType.Varchar2, naam, ParameterDirection.Input);
         OracleDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             string Naam = Convert.ToString(reader.GetOracleString(0));
             string winkel = Convert.ToString(reader.GetOracleString(1));
             double prijs = Math.Round(Convert.ToDouble(reader.GetDouble(2)), 2);
             prijzen.Add(new Prijs(Naam, winkel, prijs));
         }
     }
     catch { }
     finally
     {
         conn.Close();
     }
     //Get review IDs
     sql = @"SELECT review_id FROM Product_review WHERE Product_naam = :Naam";
     List<int> reviewID = new List<int>();
     try
     {
         conn.Open();
         OracleCommand cmd = new OracleCommand(sql, conn);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add("Naam", OracleDbType.Varchar2, naam, ParameterDirection.Input);
         OracleDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             reviewID.Add(reader.GetInt32(0));
         }
     }
     catch { }
     finally
     {
         conn.Close();
     }
     //Get reviews list
     List<ProductReview> reviews = new List<ProductReview>();
     foreach (int i in reviewID)
     {
         try
         {
             sql = @"SELECT Review_ID, auteur_gebruikersnaam as auteur, onderwerp, review_tekst as tekst, beoordeling FROM Review WHERE Review_ID = :ID";
             conn.Open();
             OracleCommand cmd = new OracleCommand(sql, conn);
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.Add("ID", OracleDbType.Int32, i, ParameterDirection.Input);
             OracleDataReader reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 reviews.Add(new ProductReview(reader.GetInt32(0),
                     Convert.ToString(reader.GetOracleString(1)),
                     Convert.ToString(reader.GetOracleString(2)),
                     Convert.ToString(reader.GetOracleString(3)),
                     reader.GetInt32(4)));
             }
         }
         catch { }
         finally
         {
             conn.Close();
         }
     }
     p = new Product(pnaam, merk, afbeelding, prijzen, reviews);
     return p;
 }