private void btnToevoegenAanBestelling_Click(object sender, EventArgs e) { if (geselecteerdePlant != null && validateFieldsToAddOrderLine()) { if (geselecteerdePlant.CheckVoorraad(Convert.ToInt32(nudAantal.Value))) { int prijs = Convert.ToInt32((nudEuro.Value * 100) + nudCenten.Value); Bestelregel nieuweBestelregel = geselecteerdePlant.BestelPlant(Convert.ToInt32(nudAantal.Value), prijs, Bestelling.Bestelregels); if (nieuweBestelregel != null) { Bestelling.Bestelregels.Add(nieuweBestelregel); } refreshView(); isEdited = true; geselecteerdePlant = null; lblGeselecteerdePlant.Text = "Selecteer een plant om toe te voegen aan de bestelling"; gbOrderLine.Enabled = false; nudEuro.Value = 0; nudCenten.Value = 0; nudAantal.Value = 1; } else { MessageBox.Show("Er zijn niet genoeg planten op voorraad", "Fout!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void checkBestelregels(Bestelregel bestelregel, int bestelling_id) { using (SQLiteConnection connection = db.Connection) { if (bestelregel.Id == 0) { string query = string.Format(@"INSERT INTO planten_in_bestelling VALUES (null, :plant_id, :bestelling_id, :aantal, :prijs);"); using (SQLiteCommand command = new SQLiteCommand(query, connection)) { command.Parameters.AddWithValue("plant_id", bestelregel.Plant.Id); command.Parameters.AddWithValue("bestelling_id", bestelling_id); command.Parameters.AddWithValue("aantal", bestelregel.Aantal); command.Parameters.AddWithValue("prijs", bestelregel.Prijs); command.ExecuteNonQuery(); bestelregel.Id = db.getLastInsertedId(connection); } } else { string query = string.Format(@"UPDATE planten_in_bestelling SET plant_id=:plant_id,bestelling_id=:bestelling_id,aantal=:aantal,prijs=:prijs WHERE id = {0};", bestelregel.Id); using (SQLiteCommand command = new SQLiteCommand(query, connection)) { command.Parameters.AddWithValue("plant_id", bestelregel.Plant.Id); command.Parameters.AddWithValue("bestelling_id", bestelling_id); command.Parameters.AddWithValue("aantal", bestelregel.Aantal); command.Parameters.AddWithValue("prijs", bestelregel.Prijs); command.ExecuteNonQuery(); foreach (Levering levering in bestelregel.Leveringen) { checkLeveringen(levering, bestelregel.Id); } } } } }
private void verwijderBestelregel() { DialogResult dialogResult = MessageBox.Show("Weet u zeker dat u de bestelregel wilt verwijderen?\nDeze actie kan niet meer ongedaan gemaakt worden!", "Bestelregel verwijderen?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { Bestelregel bestelregelToRemove = (Bestelregel)lvPlantenInBestelling.SelectedItems[0].Tag; geselecteerdeBestelling.Bestelregels.Remove(bestelregelToRemove); bestelregelToRemove.Plant.Voorraad += bestelregelToRemove.Aantal; refreshGeselecteerdeBestellingInformatie(); } }
public bool Remove(Bestelregel entity) { foreach (Bestelling b in bestellingen) { foreach (Bestelregel br in b.Bestelregels) { if (br == entity) { b.Bestelregels.Remove(br); return(true); } } } return(false); }
public LeveringAdd(Bestelregel bestelregel, Bestelling bestelling) { InitializeComponent(); this.bestelregel = bestelregel; this.bestelling = bestelling; checkBestaandeleveringenVoorZelfdeDag(); if (levering != null) { nudAantal.Maximum = bestelregel.Aantal - gevondenLeveraantallen; } else { nudAantal.Maximum = bestelregel.Aantal; } }
public bool Remove(Bestelregel entity) { using (SQLiteConnection connection = db.Connection) { string query = string.Format("DELETE FROM Planten_in_bestelling WHERE ID = {0};", entity.Id); using (SQLiteCommand command = new SQLiteCommand(query, connection)) { try { command.ExecuteNonQuery(); return(true); } catch (SQLiteException e) { if (e.ResultCode == SQLiteErrorCode.Constraint) { return(false); } throw; } } } }
public BestelRegelEdit(Bestelregel bestelregel) { InitializeComponent(); Bestelregel = bestelregel; orgineelAantal = Bestelregel.Aantal; }
public bool Remove(Bestelregel entity) { return(bestellingContext.Remove(entity)); }