private void cbSpoor_SelectedIndexChanged(object sender, EventArgs e) { int SpoorNummer = Convert.ToInt32(cbSpoor.Text); Spoor spoor = RemiseManager.spoorViaNummer(SpoorNummer); cbSector.Items.Clear(); foreach (Sector sec in spoor.SectorList) { cbSector.Items.Add(sec.Nummer); } }
private void btnSpoorstatus_Click(object sender, EventArgs e) { int SectorNR; int SpoorNR; if (!int.TryParse(cbSector.Text, out SectorNR) || !int.TryParse(cbSpoor.Text, out SpoorNR)) { MessageBox.Show("Voer geldige nummers in"); return; } Spoor spoor = RemiseManager.spoorViaNummer(SpoorNR); foreach (Sector sector in spoor.SectorList) { if (sector.Nummer == SectorNR && sector.Blokkade == true) { MessageBox.Show("Sector is vrijgemaakt"); sector.Deblokkeer(); DatabaseManager.registreerSectorStatus(sector); foreach (Sector sector1 in spoor.SectorList) { if (sector1.Nummer > SectorNR && sector1.Blokkade == true) { sector1.Deblokkeer(); DatabaseManager.registreerSectorStatus(sector1); } } } else if (sector.Nummer == SectorNR && sector.Blokkade == false) { MessageBox.Show("Sector is Geblokkeerd"); sector.Blokkeer(); DatabaseManager.registreerSectorStatus(sector); foreach (Sector sector1 in spoor.SectorList) { if (sector1.Nummer > SectorNR) { sector1.Blokkeer(); DatabaseManager.registreerSectorStatus(sector1); } } } } mainForm.refreshEenSpoor(spoor); }
private void btnBevestig_Click(object sender, EventArgs e) { int tramNr; int spoorNr; int sectorNr; if (!int.TryParse(tbTramnummer.Text, out tramNr) || !int.TryParse(tbSpoornummer.Text, out spoorNr) || !int.TryParse(tbSectornummer.Text, out sectorNr)) { MessageBox.Show("Voer geldige nummers in"); return; } if (TramManager.tramViaNummer(tramNr) != null) { if (RemiseManager.spoorViaNummer(spoorNr) != null) { Spoor spoor = RemiseManager.spoorViaNummer(spoorNr); if (lbSectornummer.Text != "Sectornummer") { TramIndeling tI = new TramIndeling(); Tram tram = TramManager.tramViaNummer(tramNr); Sector sector = RemiseManager.sectorViaNummer(sectorNr, spoor); string message = tI.DeelTramInOpSector(tram, sector); MessageBox.Show(message); } else { foreach (Sector sector in spoor.SectorList) { if (sector.Nummer == sectorNr) { Tram trammetje = TramManager.tramViaNummer(tramNr); Sector sectorCheck = RemiseManager.sectorViaTram(trammetje); if (sectorCheck != null) { sectorCheck.ClearSector(); DatabaseManager.registreerSectorStatus(sectorCheck); mainForm.refreshEenSpoor(RemiseManager.spoorViaId(sectorCheck.SpoorNummer)); } if (sector.Blokkade == true) { MessageBox.Show("Sector is geblokkeerd"); return; } sector.VoegTramToe(trammetje); mainForm.refreshEenSpoor(RemiseManager.spoorViaId(sector.SpoorNummer)); DatabaseManager.registreerSectorStatus(sector); MessageBox.Show("Tram is toegevoegd"); this.Close(); return; } } } } else { MessageBox.Show("Spoor bestaat niet"); } } else { MessageBox.Show("Tram bestaat niet"); } }