//Controls the action if btnsearch is clicked private void Btnsearch_Click(object sender, EventArgs e) { //The Object transport is getting created //The Items in the Listview are beeing removed //The Column Headers of the Listview are beeing renamed Transport transport = new Transport(); liview.Items.Clear(); clmankunft.Text = "Ankunft"; clmdauer.Text = "Dauer"; clmgleis.Text = "Gleis"; DateTime dtetimeclock = this.dtetimeclock.Value; DateTime dtetimecal = this.dtetimecal.Value; try { //Change the Cursor to WaitCursor //Gets the next 4 Connections from Connectionlist and insert them into Listview Cursor.Current = Cursors.WaitCursor; foreach (Connection conn in transport.GetConnections(cboxfrom.Text, cboxto.Text, dtetimecal, dtetimeclock).ConnectionList) { DateTime abfahrt = DateTime.Parse(conn.From.Departure); DateTime ankunft = DateTime.Parse(conn.To.Arrival); String[] item = { abfahrt.ToString(), ankunft.ToString(), conn.Duration, conn.From.Platform }; ListViewItem lview = new ListViewItem(item); liview.Items.Add(lview); } Cursor.Current = Cursors.Default; } //Catches WebException for too many Requests catch (WebException ex) { MessageBox.Show($"Zu viele Anfragen an den Server\nBitte kurz warten befor sie fortfahren\n\n{ex}"); } }
private void btnSuche_Click(object sender, EventArgs e) { try { dgvPlan.Rows.Clear(); string start = txtStart.Text; string ziel = txtZiel.Text; var station = transport.GetConnections(start, ziel); foreach (var stat in station.ConnectionList) { int n = dgvPlan.Rows.Add(); dgvPlan.Rows[n].Cells["colVon"].Value = start; dgvPlan.Rows[n].Cells["colBis"].Value = ziel; dgvPlan.Rows[n].Cells["colAbfahrt"].Value = DateTime.Parse(stat.From.Departure).ToString("HH:mm"); dgvPlan.Rows[n].Cells["colAnkunft"].Value = DateTime.Parse(stat.To.Arrival).ToString("HH:mm"); dgvPlan.Rows[n].Cells["colDauer"].Value = stat.Duration.Substring(3, 2) + " h " + stat.Duration.Substring(6, 2) + " min";; dgvPlan.Rows[n].Cells["colGleis"].Value = stat.From.Platform; } if (dgvPlan.Visible == false) { dgvPlan.Visible = true; } listStart.Visible = false; listZiel.Visible = false; } catch { MessageBox.Show("Keine Verbindung gefunden!", "OK"); txtStart.Text = ""; txtZiel.Text = ""; txtStart.Focus(); } }
private void textBox3_TextChanged(object sender, EventArgs e) { dataGridView1.Rows.Clear(); SwissTransport.Transport connection = new SwissTransport.Transport(); var connect = connection.GetConnections(textBox1.Text, textBox2.Text); foreach (var conn in connect.ConnectionList) { abfahrtsstation.Visible = true; abfahrtszeit.Visible = true; abfahrtszone.Visible = true; ankunftsstation.Visible = true; ankunftszeit.Visible = true; ankunftszone.Visible = true; verspaetung.Visible = true; DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone(); row.Cells[0].Value = textBox1.Text; row.Cells[1].Value = DateTime.Parse(conn.From.Departure).ToString("HH:mm"); row.Cells[1].Value = row.Cells[1].Value + " h"; row.Cells[2].Value = conn.From.Platform; row.Cells[3].Value = textBox2.Text; row.Cells[4].Value = DateTime.Parse(conn.To.Arrival).ToString("HH:mm"); row.Cells[4].Value = row.Cells[4].Value + " h"; row.Cells[5].Value = conn.To.Platform; row.Cells[6].Value = conn.To.Delay; dataGridView1.Rows.Add(row); } // List<Connections> connections = transport.GetConnections(textBox1.Text, textBox2.Text).fromStation; //foreach (Connections connection in connections) //{ // listBox3.Items.Add(connection.Name); //} }
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"); } } }
private void buttonverbindungen_Click(object sender, EventArgs e) { if (textboxvon.Text == string.Empty && textboxnach.Text == string.Empty) { MessageBox.Show("Es müssen Von und Nach Ort eingegeben werden"); } else if (textboxvon.Text == string.Empty) { MessageBox.Show("Es müssen den Von Ort eingegeben werden"); } else if (textboxnach.Text == string.Empty) { MessageBox.Show("Es muss der Nach Ort eingegeben werden"); } if (textboxvon.Text == "Von") { MessageBox.Show("Der Wert muss verändert werden."); } if (textboxnach.Text == "Nach") { MessageBox.Show("Der Wert muss verändert werden."); } // var result = transport.GetConnections(textboxvon.Name, textboxnach.Name, datetimepickerabfahrt.Value); var result = transport.GetConnections(textboxvon.Text, textboxnach.Text, datetimepickerabfahrt.Value); listboxausgabe.Items.Clear(); foreach (SwissTransport.Connection connection in result.ConnectionList) { listboxausgabe.Items.Add("Von" + " " + textboxvon.Text + " " + "nach" + " " + connection.To.station.Name); } }