public CommentaarToevoegen(Form sender, ref BestellingsProduct product)
        {
            InitializeComponent();

            this.StartPosition = FormStartPosition.CenterScreen;

            this.overlay = new Plexiglass(sender);
            this.product = product;
            this.txtCommentaar.Text = product.Commentaar;
        }
 //Voeg product toe aan bestelling
 public BestellingsProduct VoegProductToe(Bestelling bestelling, Product product, string commentaar = "", int aantal = 1) 
 {
     BestellingsProduct p = (BestellingsProduct)bestelling.Producten.Find(x => x.Naam == product.Naam && x.Commentaar == commentaar);
     if (p != null)
         p.Aantal++;
     else
     {
         p = new BestellingsProduct(product, commentaar, aantal);
         bestelling.Producten.Add(p);
     } 
     product.AantalInVoorraad--;
     return p; 
 }
 //Verwijder product uit bestelling
 public bool VerwijderProduct(Bestelling bestelling, BestellingsProduct product)
 {
     try
     {
         bestelling.Producten.Remove(product);
         producten.Find(x => x.Naam == product.Naam).AantalInVoorraad++;
         return true;
     }
     catch (NullReferenceException e)
     {
         Console.Write(e.Message + " while trying to find: ", product.Naam);
         return false;
     }
 }
Ejemplo n.º 4
0
        public static List<BestellingsProduct> GetProductenVanBestelling(int bestellingID)
        {
            SqlCommand command = new SqlCommand(@"SELECT *
                                                FROM bevat, PRODUCT, MENUKAART, MENU_CATEGORIE
                                                WHERE bevat.product_id = PRODUCT.id 
                                                AND bevat.bestelling_id = @ID
                                                AND PRODUCT.menu_categorie = MENU_CATEGORIE.ID
                                                AND MENU_CATEGORIE.menukaart_id = MENUKAART.ID");
            command.Parameters.AddWithValue("ID", bestellingID);

            SqlDataReader reader = DatabaseReader(command);

            List<BestellingsProduct> producten = new List<BestellingsProduct>();
            while (reader.Read())
            {
                int productID = (int)reader["id"];
                string naam = (string)reader["naam"];
                naam = naam.Trim();
                naam = naam.Replace("_", " ");
                Productcategorie categorie = (Productcategorie)(int)reader["menu_categorie"];
                double prijs = (double)reader["prijs"];
                int aantalInVooraad = (int)reader["aantal_in_voorraad"];
                string commentaar = (string)reader["commentaar"];
                commentaar = commentaar.Trim();
                int aantal = (int)reader["aantal"];

                Menukaart kaart = (Menukaart)reader["menukaart_id"];

                BestellingsProduct product = new BestellingsProduct(productID, naam, kaart, categorie, prijs, aantalInVooraad, commentaar, aantal); //commentaar nog toevoegen
                producten.Add(product);
            }
            Database.CloseConnection();

            return producten;
        }
Ejemplo n.º 5
0
 public static int WriteProduct(Bestelling bestelling, BestellingsProduct product)
 {
     SqlCommand command = new SqlCommand("INSERT INTO bevat (bestelling_id, product_id, aantal, commentaar) VALUES (@BestellingID, @ProductID, @Aantal, @Commentaar)", conn);
     command.Parameters.AddWithValue("BestellingID", bestelling.ID);
     command.Parameters.AddWithValue("ProductID", product.Id);
     command.Parameters.AddWithValue("Aantal", product.Aantal);
     command.Parameters.AddWithValue("Commentaar", product.Commentaar);
     return DatabaseWriter(command);
 }
Ejemplo n.º 6
0
 //Gebruikt bij het maken van een bestelling
 public static int VerminderVoorraad(BestellingsProduct product)
 {
     SqlCommand command = new SqlCommand(@"UPDATE PRODUCT SET aantal_in_voorraad = aantal_in_voorraad - @ProductAantal WHERE ID = @ProductId;", conn);
     command.Parameters.AddWithValue("ProductAantal", product.Aantal);
     command.Parameters.AddWithValue("ProductId", product.Id);
     return DatabaseWriter(command);
 }
 //
 public bool WijzigProductCommentaar(BestellingsProduct product)
 {
     return false;
 }