protected void ddlSectorBlokkerenSpoor_SelectedIndexChanged(object sender, EventArgs e) { //todo; sectoren ophalen die bij dit spoor horen ddlSectorBlokkerenSector.Items.Clear(); Spoor selectedSpoor = null; foreach (Spoor spoor in bc.GetAllSporen()) { if (spoor.Nummer == Convert.ToInt32(ddlSectorBlokkerenSpoor.SelectedItem.Text)) { selectedSpoor = spoor; } } if (selectedSpoor == null) { Response.Write("Selectedspoor is null"); return; } foreach (Sector s in selectedSpoor.Sectoren) { ddlSectorBlokkerenSector.Items.Add(s.Nummer.ToString()); } }
private void btnTramVerplaatsenBevestig_Click(object sender, EventArgs e) { if (cbTramTramVerplaatsen.SelectedItem != null && cbSectorTramVerplaatsen.SelectedItem != null && cbSpoorTramVerplaatsen.SelectedItem != null) { int tramnummer = Convert.ToInt32(cbTramTramVerplaatsen.SelectedItem.ToString()); int spoornummer = Convert.ToInt32(cbSpoorTramVerplaatsen.SelectedItem.ToString()); int sectornummer = Convert.ToInt32(cbSectorTramVerplaatsen.SelectedItem.ToString()); Tram tram = bc.GetTramByNummer(tramnummer); Spoor spoor = bc.GetSpoorByNummer(spoornummer); Sector sector = bc.GetSectorByID(spoor, sectornummer); if (tram != null && spoor != null && sector != null) { MessageBox.Show(bc.TramVerplaatsen(tram, bc.GetSpoorByTram(tram), bc.GetSectorByTram(tram), spoor, sector)); } else { MessageBox.Show("tram, spoor of sector naar zijn null"); } } else { MessageBox.Show("Niet alle vereiste informatie geselecteerd."); } }
public void ToggleRailBlockTest() { Assert.AreEqual(1, Database.ToggleRailBlock(12, true)); Spoor spoor = Database.GetAllTracks().First(s => s.Geblokkeerd); Assert.AreEqual(true, spoor.Geblokkeerd); }
protected void ddlSectorReserverenSpoor_SelectedIndexChanged(object sender, EventArgs e) { int spoornummer = Convert.ToInt32(ddlSpoorReserverenSpoor.SelectedItem.Text); Spoor selectedSpoor = bc.GetSpoorByNummer(spoornummer); if (selectedSpoor == null) { Response.Write("Selectedspoor " + spoornummer + " is null"); return; } }
public void GetAllTracksTest() { List <Spoor> allTracks = Database.GetAllTracks().ToList(); Assert.AreEqual(41, allTracks.Count); Spoor spoor = allTracks[0]; Assert.AreEqual(1, spoor.Id); Assert.AreEqual(1, spoor.Lengte); Assert.AreEqual(false, spoor.InUitRijspoor); }
protected void btnSectorBlokkerenDeblokkeren_Click1(object sender, EventArgs e) { try { Spoor s = bc.GetSpoorByNummer(Convert.ToInt32(ddlSectorBlokkerenSpoor.SelectedItem.Text)); int sectorId = Convert.ToInt32(ddlSectorBlokkerenSector.SelectedItem.Text); Sector se = bc.GetSectorByID(s, sectorId); bc.ToggleSector(se); Response.Redirect(Request.RawUrl); } catch (Exception ex) { Response.Write("<script>alert(" + ex.Message + ");</script>"); } }
private void LoadAllTracks(object sender, EventArgs e) { List <Spoor> tracks = Database.GetAllTracks().ToList(); List <Sector> sectors = Database.GetAllSectors().ToList(); foreach (Track track in Tracks) { Spoor result = tracks.FirstOrDefault(t => t.Nummer == track.Number); if (result != null) { track.Length = result.Lengte; track.Enabled = result.Beschikbaar; track.Sectors = sectors.Where(s => s.SpoorId == result.Id).ToList(); } } }
protected void btnSpoorBlokkerenDeblokkeren_Click(object sender, EventArgs e) { try { Spoor s = bc.GetSpoorByNummer(Convert.ToInt32(ddlSpoorBlokkeren.SelectedItem.Text)); foreach (Sector sector in s.Sectoren) { bc.ToggleSector(sector); } Response.Redirect(Request.RawUrl); } catch (Exception ex) { string script = "alert(\" " + ex.Message + "\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } }
/// <summary> /// Assigns the sector to the right track /// </summary> public void AssignSector(Tram tram) { if (tram.Vervuild) { foreach (int track in _cleaningTracks.Where(Database.IsRailAvailable)) { Database.CreateSector(track, tram.Id); return; } } else if (tram.Defect) { foreach (int track in _maintenanceTracks.Where(Database.IsRailAvailable)) { Database.CreateSector(track, tram.Id); return; } } // Combino heeft een speciaal spoor nodig. else if (tram.TramTypeId == 1) { if (Database.IsRailAvailable(33)) { Database.CreateSector(33, tram.Id); return; } } for (var i = 0; i < 1337; i++) { List <Spoor> sporen = Database.GetSelectedTracks(i) .Where(s => !_maintenanceTracks.Contains(s.Id)) .Where(s => !_cleaningTracks.Contains(s.Id)) .ToList(); if (sporen.Count != 0) { Spoor spoor = sporen.First(); Database.CreateSector(spoor.Id, tram.Id); break; } } }
protected void Button1_Click(object sender, EventArgs e) { List <Sector> sectorLst = new List <Sector>(); List <Spoor> spoorLst = new List <Spoor>(); for (int i = 1; i < 8; i++) { Sector sctr = new Sector(1, i, null, i, true, false); sectorLst.Add(sctr); } for (int i = 1; i < 44; i++) { Spoor sp = new Spoor(i, null, i, 8, true, false, sectorLst); spoorLst.Add(sp); } List <Spoor> spoorList = DatabaseManager.LaadSporen(); AddTextBoxToTable(spoorList); }
private void cbSpoorSectorReserveren_SelectedIndexChanged(object sender, EventArgs e) { cbSectorSectorReserveren.Items.Clear(); int spoornummer = Convert.ToInt32(cbSpoorSectorReserveren.SelectedItem.ToString()); Spoor spoor = bc.GetSpoorByNummer(spoornummer); if (spoor == null) { MessageBox.Show("Kon geen sector vinden"); return; } foreach (Sector s in spoor.Sectoren) { cbSectorSectorReserveren.Items.Add(s.Id); } cbSectorSectorReserveren.SelectedIndex = 0; cbSectorSectorReserveren.Enabled = true; }
protected void btnTramVerplaatsen_Click(object sender, EventArgs e) { try { int tramnummer = Convert.ToInt32(ddlTramVerplaatsenTram.SelectedItem.Text); int sectornaar = Convert.ToInt32(ddlTramVerplaatsenSector.SelectedItem.Text); int spoornaar = Convert.ToInt32(ddlTramVerplaatsenSpoor.SelectedItem.Text); Tram t = bc.GetTramByNummer(tramnummer); Spoor p = bc.GetSpoorByNummer(spoornaar); bc.TramVerplaatsen(t, bc.GetSpoorByTram(t), bc.GetSectorByTram(t), p, bc.GetSectorByID(p, sectornaar)); Response.Redirect(Request.RawUrl); } catch (Exception ex) { string script = "alert(\" " + ex.Message + "\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } }
protected void btnSpoorReserveren_Click(object sender, EventArgs e) { try { bc = new BeheerController(); int spoornummer = Convert.ToInt32(ddlSpoorReserverenSpoor.SelectedItem.Text); int tramnummer = Convert.ToInt32(ddlSpoorReserverenTram.SelectedItem.Text); Spoor s = bc.GetSpoorByNummer(spoornummer); Tram t = bc.GetTramByNummer(tramnummer); bc.SpoorReserveren(s, t); Response.Redirect(Request.RawUrl); } catch (Exception ex) { string script = "alert(\" " + ex.Message + "\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } }
private void btnToggleBlokkeren_Click(object sender, EventArgs e) { if (cbSpoorSectorblokkeren.SelectedItem != null && cbSectorSectorblokkeren.SelectedItem != null) { int spoornr = Convert.ToInt32(cbSpoorSectorblokkeren.SelectedItem.ToString()); int sectorid = Convert.ToInt32(cbSectorSectorblokkeren.SelectedItem.ToString()); Spoor spoor = bc.GetSpoorByNummer(spoornr); if (spoor != null) { MessageBox.Show(bc.ToggleSector(bc.GetSectorByID(spoor, sectorid))); } else { MessageBox.Show("Spoor kon niet worden getoggled"); } } else { MessageBox.Show("Niet alle vereiste informatie geselecteerd."); } }
protected void ddlTramVerplaatsenSpoor_SelectedIndexChanged(object sender, EventArgs e) { ddlTramVerplaatsenSector.Items.Clear(); Spoor selectedSpoor = null; foreach (Spoor spoor in bc.GetAllSporen()) { if (spoor.Nummer == Convert.ToInt32(ddlTramVerplaatsenSpoor.SelectedItem.Text)) { selectedSpoor = spoor; } } if (selectedSpoor == null) { Response.Write("Selectedspoor is null"); return; } foreach (Sector s in selectedSpoor.GetLegeSectoren()) { ddlTramVerplaatsenSector.Items.Add(s.Nummer.ToString()); } }
public void TramInrijden(Tram tram, Spoor spoor, Sector sector) { context.TramInrijden(tram, spoor, sector); }
public List <Sector> ZoekVrijSector(Spoor spoor) { return(context.ZoekVrijSector(spoor)); }