private void DateTimePickerTijdregistraties_ValueChanged(object sender, EventArgs e) { if (Opleiding != null) { listBoxTijd.Items.Clear(); if (listBoxDeelnemersTijd.SelectedIndex < 1) { var tijdPerOpl = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.OpleidingsInformatie.Id == Opleiding.Id where t.DateTime.Date == dateTimePickerTijdregistraties.Value.Date select t; foreach (Tijdsregistraties item in tijdPerOpl) { listBoxTijd.Items.Add(item); } } else { Deelnemers deeln = listBoxDeelnemersTijd.SelectedItem as Deelnemers; var tijdPerDeeln = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.Deelnemers.Id == deeln.Id where t.DateTime.Date == dateTimePickerTijdregistraties.Value.Date select t; foreach (Tijdsregistraties item in tijdPerDeeln) { listBoxTijd.Items.Add(item); } } } }
private void ListboxDeelnemers_DoubleClick(object sender, EventArgs e) { string selectedItem = ListboxDeelnemers.SelectedItem.ToString(); var strings = selectedItem.Split(','); string naam = strings[0]; string woonplaats = strings[1].Substring(2); string geboorteDatum = strings[2].Substring(2); using (var context = new DatabaseContext()) { Deelnemers deelnemer = context.Deelnemers.FirstOrDefault(f => f.Naam == naam && f.Woonplaats == woonplaats); _selectedDeelnemer = deelnemer; TextboxDeelnemersNaam.Text = deelnemer.Naam; TextboxDeelnemersWoonplaats.Text = deelnemer.Woonplaats; TextboxDeelnemerBadgeNr.Text = deelnemer.BadgeNummer; DatetimepickerDeelnemerGeboortedatum.Value = deelnemer.GeboorteDatum; if (deelnemer.Opleidings != null) { foreach (var item in deelnemer.Opleidings) { ListboxDeelnemersOpleidingen.Items.Add(item); } } } }
//Tijdregistraties private void ListBoxDeelnemersTijd_SelectedIndexChanged(object sender, EventArgs e) { listBoxTijd.Items.Clear(); if (listBoxDeelnemersTijd.SelectedIndex > 0) { Deelnemers deeln = listBoxDeelnemersTijd.SelectedItem as Deelnemers; var tijdPerDeeln = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.Deelnemers.Id == deeln.Id select t; textBoxTijdNaamDeeln.Text = deeln.Naam; foreach (Tijdsregistraties item in tijdPerDeeln) { listBoxTijd.Items.Add(item); } } else { var tijdPerOpl = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.OpleidingsInformatie.Id == Opleiding.Id select t; foreach (Tijdsregistraties item in tijdPerOpl) { listBoxTijd.Items.Add(item); } } }
private void ButtonDeelnemerUpd_Click(object sender, EventArgs e) { DeelnTab_Validating(); if (comboBoxOpleiding.SelectedIndex <= 1) { errorProviderOplInfoTab.SetError(buttonDeelnemerUpd, "Selecteer of creeër eerst een opleiding om deelnemer aan toe tevoegen."); } else if (IsValidDeeln && textBoxDeelnId.Text != "") { int deelnId = int.Parse(textBoxDeelnId.Text); using (var ctx = new DataContext()) { Deelnemers deelnUpd = ctx.Deelnemers.SingleOrDefault(x => x.Id == deelnId); deelnUpd.Naam = textBoxDeelnNaam.Text; deelnUpd.GeboorteDatum = dateTimePickerDeelnGeb.Value.Date; deelnUpd.Woonplaats = textBoxDeelnWoon.Text; deelnUpd.Badgenummer = int.Parse(textBoxDeelnBadge.Text); ctx.SaveChanges(); DeelnLijst = ctx.Deelnemers.ToList(); } ClearAll(); LaadAlleListbox(); } else { errorProviderOplInfoTab.SetError(buttonOplUpd, "U probeert een nieuwe deelnemer toe te voegen.."); } }
private void ButtonDeelnemersAdd_Click(object sender, EventArgs e) { List <OpleidingsInformatie> opleidingen = new List <OpleidingsInformatie>(); foreach (var opleiding in ListboxDeelnemersOpleidingen.Items) { opleidingen.Add(opleiding as OpleidingsInformatie); } Deelnemers deelnemer = new Deelnemers() { Naam = TextboxDeelnemersNaam.Text, Woonplaats = TextboxDeelnemersWoonplaats.Text, BadgeNummer = TextboxDeelnemerBadgeNr.Text, GeboorteDatum = DatetimepickerDeelnemerGeboortedatum.Value, Opleidings = opleidingen }; using (var context = new DatabaseContext()) { context.Deelnemers.Add(deelnemer); context.SaveChanges(); } ReloadDeelnemerList(); }
private void ListBoxTijd_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxTijd.SelectedIndex > -1) { Tijdsregistraties tijdr = listBoxTijd.SelectedItem as Tijdsregistraties; Deelnemers deeln = tijdr.Deelnemers as Deelnemers; var tijdPerDeeln = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.Deelnemers.Id == deeln.Id select t; textBoxTijdNaamDeeln.Text = deeln.Naam; int tijdIndex = tijdPerDeeln.Select((item, index) => new { item, index }).Single(p => p.item.Id == tijdr.Id).index; if (tijdIndex % 2 == 0) { textBoxTijdBadgeStatus.Text = "Badge In"; textBoxTijdStip.Text = ""; checkBoxTijdVoorm.Checked = false; checkBoxTijdNam.Checked = false; } else { textBoxTijdBadgeStatus.Text = "Badge Out"; TimeSpan tijdAanwezig = tijdPerDeeln.ElementAt(tijdIndex).DateTime - tijdPerDeeln.ElementAt(tijdIndex - 1).DateTime; textBoxTijdStip.Text = tijdAanwezig.ToString(); if (tijdAanwezig > new TimeSpan(8, 0, 0)) { checkBoxTijdVoorm.Checked = true; checkBoxTijdNam.Checked = true; } else if (tijdAanwezig > new TimeSpan(3, 0, 0) && tijdPerDeeln.ElementAt(tijdIndex).DateTime.Hour < 14) { checkBoxTijdVoorm.Checked = true; checkBoxTijdNam.Checked = false; } else if (tijdAanwezig > new TimeSpan(3, 0, 0) && tijdPerDeeln.ElementAt(tijdIndex).DateTime.Hour > 14) { checkBoxTijdVoorm.Checked = false; checkBoxTijdNam.Checked = true; } else { checkBoxTijdVoorm.Checked = false; checkBoxTijdNam.Checked = false; } } } else { textBoxTijdStip.Text = ""; textBoxTijdBadgeStatus.Text = ""; checkBoxTijdNam.Checked = false; checkBoxTijdVoorm.Checked = false; } }
public void DeelnemerVerwijderen(Deelnemer deelnemer) { if (!Deelnemers.Contains(deelnemer)) { return; } Deelnemers.Remove(deelnemer); EvenementDeelnemer.Verwijderen(this, deelnemer); }
public void DeelnemerToevoegen(Deelnemer deelnemer) { if (Deelnemers.Contains(deelnemer)) { return; } Deelnemers.Add(deelnemer); EvenementDeelnemer.Toevoegen(this, deelnemer); }
private void ButtonDeelnemersRemove_Click(object sender, EventArgs e) { using (var context = new DatabaseContext()) { Deelnemers deelnemer = context.Deelnemers.FirstOrDefault(f => f.Naam == TextboxDeelnemersNaam.Text && f.Woonplaats == TextboxDeelnemersWoonplaats.Text); if (deelnemer != null) { context.Deelnemers.Remove(deelnemer); context.SaveChanges(); } } ReloadDeelnemerList(); }
private void WijzigDeelnemerForm_Click(object sender, EventArgs e) { int gekozenId = int.Parse(IdTextBox.Text); using (var ctx = new AanwezigheidslijstContext()) { Deelnemers deelnemers = ctx.Deelnemers.FirstOrDefault(a => a.Id == gekozenId); var deelnemer = ctx.Deelnemers.Select(dlnmr => new { dlnmr.Id, dlnmr.Naam, dlnmr.GeboorteDatum, dlnmr.Woonplaats, dlnmr.BadgeNummer }); } }
private void ListBoxDeelnemers_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxDeelnemers.SelectedIndex > 0) { Deelnemers deelnemer = listBoxDeelnemers.SelectedItem as Deelnemers; textBoxDeelnId.Text = deelnemer.Id.ToString(); textBoxDeelnNaam.Text = deelnemer.Naam; dateTimePickerDeelnGeb.Value = deelnemer.GeboorteDatum.Date; textBoxDeelnWoon.Text = deelnemer.Woonplaats; textBoxDeelnBadge.Text = deelnemer.Badgenummer.ToString(); } else { errorProviderOplInfoTab.SetError(buttonDeelnemerCreate, string.Empty); textBoxDeelnId.Text = ""; textBoxDeelnNaam.Text = ""; dateTimePickerDeelnGeb.Value = DateTime.Today; textBoxDeelnWoon.Text = ""; textBoxDeelnBadge.Text = ""; } }
private void DynamicButton_Click(object sender, EventArgs e) { Button button = sender as Button; var deeln = from d in DeelnLijst join dOpl in DeelnOplLijst on d.Id equals dOpl.Deelnemer.Id where dOpl.OpleidingsInformatie.Id == Opleiding.Id select d; Deelnemers deel = new Deelnemers(); using (var ctx = new DataContext()) { Opleiding = ctx.OpleidingsInformatie.SingleOrDefault(x => x.Id == Opleiding.Id); deel = ctx.Deelnemers.SingleOrDefault(d => d.Naam == button.Name); ctx.Tijdsregistraties.Add(new Tijdsregistraties { DateTime = DateTime.Now, OpleidingsInformatie = Opleiding, Deelnemers = deel }); ctx.SaveChanges(); TijdLijst = ctx.Tijdsregistraties.Include(x => x.Deelnemers).Include(x => x.OpleidingsInformatie).ToList(); } if (button.Text == "Badge In") { button.Text = "Badge Out"; } else { button.Text = "Badge In"; var tijdPerDeel = from t in TijdLijst join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id where t.Deelnemers.Id == deel.Id select t; //List<Tijdsregistraties> tijdPerDeeln = tijdPerDeel as List<Tijdsregistraties>; TimeSpan tijdIn = tijdPerDeel.Last().DateTime - tijdPerDeel.Reverse().Skip(1).First().DateTime; MessageBox.Show($"{deel.Naam} was {tijdIn} aanwezig."); } }
//buttons deelnemer tabblad private void ButtonDeelnemerCreate_Click(object sender, EventArgs e) { DeelnTab_Validating(); //check of badge nummer al bestaat, moet enkel in toevoegen, niet in updaten. foreach (Deelnemers item in DeelnLijst) { if (item.Badgenummer.ToString() == textBoxDeelnBadge.Text) { errorProviderOplInfoTab.SetError(textBoxOplOE, "Badge nummer bestaat al."); IsValidOpl = false; } else { errorProviderOplInfoTab.SetError(textBoxOplOE, string.Empty); } } if (comboBoxOpleiding.SelectedIndex < 1) { errorProviderOplInfoTab.SetError(buttonDeelnemerCreate, "Selecteer of creeër eerst een opleiding om deelnemer aan toe tevoegen."); } else if (IsValidDeeln && textBoxDeelnId.Text == "") { if (DeelnLijst.Any(d => d.Naam.ToLower() == textBoxDeelnNaam.Text.ToLower() && d.GeboorteDatum.Date == dateTimePickerDeelnGeb.Value.Date)) { using (var ctx = new DataContext()) { Opleiding = ctx.OpleidingsInformatie.SingleOrDefault(x => x.Id == Opleiding.Id); Deelnemers deelnUpd = ctx.Deelnemers.SingleOrDefault(x => x.Naam == textBoxDeelnNaam.Text && x.GeboorteDatum == dateTimePickerDeelnGeb.Value.Date); deelnUpd.Woonplaats = textBoxDeelnWoon.Text; deelnUpd.Badgenummer = int.Parse(textBoxDeelnBadge.Text); ctx.DeelnemersOpleidingen.Add(new DeelnemersOpleidingen { Deelnemer = deelnUpd, OpleidingsInformatie = Opleiding }); ctx.SaveChanges(); DeelnLijst = ctx.Deelnemers.ToList(); DeelnOplLijst = ctx.DeelnemersOpleidingen.Include(x => x.Deelnemer).Include(x => x.OpleidingsInformatie).ToList(); } } else { Deelnemers nieuweDeeln = new Deelnemers { Naam = textBoxDeelnNaam.Text, GeboorteDatum = dateTimePickerDeelnGeb.Value.Date, Woonplaats = textBoxDeelnWoon.Text, Badgenummer = int.Parse(textBoxDeelnBadge.Text) }; using (var ctx = new DataContext()) { Opleiding = ctx.OpleidingsInformatie.SingleOrDefault(x => x.Id == Opleiding.Id); ctx.Deelnemers.Add(nieuweDeeln); ctx.DeelnemersOpleidingen.Add(new DeelnemersOpleidingen { Deelnemer = nieuweDeeln, OpleidingsInformatie = Opleiding }); ctx.SaveChanges(); DeelnLijst = ctx.Deelnemers.ToList(); DeelnOplLijst = ctx.DeelnemersOpleidingen.Include(x => x.Deelnemer).Include(x => x.OpleidingsInformatie).ToList(); } textBoxDeelnId.Text = DeelnLijst.Last().Id.ToString(); } ClearAll(); LaadAlleListbox(); } else { errorProviderOplInfoTab.SetError(buttonDeelnemerCreate, "U probeert te updaten."); } }