private new void Update() { dgrhide.DataSource = null; if (SelectedStartStation.Name != null && SelectedDestinationStation.Name != null) { Connections = Transport.GetConnections(SelectedStartStation.Name, SelectedDestinationStation.Name, DateTime.Now, DateTime.Now); if (Connections != null) { dgrhide.DataSource = Connections.ConnectionList; } else { MessageBox.Show("Keine Verbindungen gefunden"); return; } try { dgrhide.Columns.Remove("Von"); dgrhide.Columns.Remove("Nach"); } catch { MessageBox.Show("Es wurde ein Fehler gefunden"); } } else { if (SelectedStartStation.Name != null) { StationBoard = Transport.GetStationBoard(SelectedStartStation.Name, SelectedStartStation.Id); } else { StationBoard = Transport.GetStationBoard(SelectedDestinationStation.Name, SelectedDestinationStation.Id); } if (StationBoard != null) { dgrhide.DataSource = StationBoard.Entries; } else { MessageBox.Show("Keinen Fahrplan gefunden"); return; } try { dgrhide.Columns.Remove("Name"); dgrhide.Columns.Remove("Category"); dgrhide.Columns.Remove("Operator"); } catch { MessageBox.Show("Es wurde ein Fehler gefunden"); } } }
//Clears all Items from the Listview //Changes the name of the Columnheaders //Gets the StationBoard from the cboxfrom station and fills it into the Listview //Sets the Cursor to Waitcursor until all Data is loaded into Listview private void btnshowtable_Click(object sender, EventArgs e) { Transport transport = new Transport(); DateTime dtetimeclock = this.dtetimeclock.Value; DateTime dtetimecal = this.dtetimecal.Value; liview.Items.Clear(); if (cboxfrom.Text != "") { try { //ColumnHeaders of Listview getting renamed Cursor.Current = Cursors.WaitCursor; clmankunft.Text = "Nach"; clmdauer.Text = "Typ"; clmgleis.Text = "Anbieter"; string id = transport.GetStations(cboxfrom.Text).StationList[0].Id; StationBoardRoot sbr = transport.GetStationBoard(cboxfrom.Text, id, dtetimecal, dtetimeclock); foreach (StationBoard stb in sbr.Entries) { String[] item = { stb.Stop.Departure.ToString(), stb.To, stb.Name, stb.Operator }; ListViewItem lview = new ListViewItem(item); liview.Items.Add(lview); } Cursor.Current = Cursors.Default; } catch (Exception ex) { MessageBox.Show($"Zu viele Anfragen an den Server\nBitte kurz warten befor sie fortfahren\n\n"); } } }
private void btnStationSuche_Click(object sender, EventArgs e) { try { dgvStationboard.Rows.Clear(); string start = txtStation.Text; var station = transport.GetStationBoard(start); foreach (var stat in station.Entries) { int n = dgvStationboard.Rows.Add(); dgvStationboard.Rows[n].Cells["colBis1"].Value = stat.To; dgvStationboard.Rows[n].Cells["colAbfahrt1"].Value = stat.Stop.Departure.ToShortTimeString(); dgvStationboard.Rows[n].Cells["colName"].Value = stat.Number; dgvStationboard.Rows[n].Cells["colGleis1"].Value = stat.Stop.Platform; } if (dgvStationboard.Visible == false) { dgvStationboard.Visible = true; } listStart.Visible = false; listZiel.Visible = false; } catch { MessageBox.Show("Keine Fahrten gefunden!", "OK"); txtStation.Text = ""; txtStation.Focus(); } }