//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; } }
public AanpassenBestelling(ref Bestellingssysteem systeem, Bestelling bestelling, Form sender) { InitializeComponent(); this.systeem = systeem; this.bestelling = bestelling; this.FormBorderStyle = FormBorderStyle.None; this.ShowInTaskbar = false; cmbStatus.Items.Add(Bestellingstatus.Gereed); cmbStatus.Items.Add(Bestellingstatus.Openstaand); cmbStatus.Items.Add(Bestellingstatus.Geserveerd); cmbStatus.Items.Add(Bestellingstatus.Afgerond); cmbStatus.SelectedItem = bestelling.Status; this.overlay = new Plexiglass(sender); lblTafel.Text = String.Format("Tafel: {0}", bestelling.Tafel.Nummer.ToString()); VulList(); }
public static void AanpassenBestellingsProducten(Bestelling bestelling, int productid, int aantal) { SqlCommand command = new SqlCommand("UPDATE BEVAT SET aantal = @Aantal WHERE bestelling_id = @Bestellingid AND product_id = @Productid"); command.Parameters.AddWithValue("Aantal", aantal); command.Parameters.AddWithValue("Bestellingid", bestelling.ID); command.Parameters.AddWithValue("Productid", productid); DatabaseWriter(command); CloseConnection(); }
public static List<Bestelling> GetOpenstaandeBestellingen() { List<Bestelling> bestellingen = new List<Bestelling>(); SqlCommand command = new SqlCommand(@"SELECT tafel_id, tijd_opname, STATUS.status, MEDEWERKER.voornaam, MEDEWERKER.achternaam, medewerker_id, MEDEWERKER.medewerker_type, BESTELLING.ID FROM BESTELLING JOIN status on BESTELLING.status = status.id JOIN MEDEWERKER on BESTELLING.medewerker_id = MEDEWERKER.ID WHERE STATUS.Status != 'Afgerond'"); SqlDataReader reader = DatabaseReader(command); while (reader.Read()) { int tafelID = (int)reader["tafel_id"]; DateTime tijd = (DateTime)reader["tijd_opname"]; Bestellingstatus status = (Bestellingstatus)Enum.Parse(typeof(Bestellingstatus), (string)reader["status"]); string voornaam = (string)reader["voornaam"]; voornaam = voornaam.Trim(); int medewerkeridstring = (int)reader["medewerker_id"]; string achternaam = (string)reader["achternaam"]; achternaam = achternaam.Trim(); Medewerkertype medewerkertype = (Medewerkertype)Enum.Parse(typeof(Medewerkertype), (string)reader["medewerker_type"]); int bestellingID = (int)reader["id"]; Tafel tafel = Systeem.Tafels.Find(x => x.Nummer == tafelID); Medewerker medewerker = new Medewerker(1, voornaam, achternaam, medewerkertype); Bestelling bestelling = new Bestelling(bestellingID, status, tafel, null, tijd, medewerker); bestellingen.Add(bestelling); } foreach (Bestelling b in bestellingen) { b.Producten = GetProductenVanBestelling(b.ID); } return bestellingen; }
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); }
public static int WriteBestelling(Bestelling bestelling) { SqlCommand command = new SqlCommand(@"INSERT INTO BESTELLING (tijd_opname, medewerker_id, tafel_id, status) VALUES (@TijdOpname, @Medewerker, @Tafel, @Status); SELECT SCOPE_IDENTITY();", conn); command.Parameters.AddWithValue("TijdOpname", bestelling.Tijd); command.Parameters.AddWithValue("Medewerker", bestelling.Medewerker.Id); command.Parameters.AddWithValue("Tafel", bestelling.Tafel.Nummer); command.Parameters.AddWithValue("Status", (int)bestelling.Status); command.Connection.ConnectionString = connString; command.Connection.Open(); return Convert.ToInt32(command.ExecuteScalar()); }
//Maak nieuwe bestelling aan public void NieuweBestelling(int tafelNummer, Medewerker medewerker) { HuidigeBestelling = new Bestelling(0, Bestellingstatus.Openstaand, Tafels[tafelNummer - 1], null, DateTime.Now, medewerker); }