private void lbBuses_SelectedIndexChanged(object sender, EventArgs e) { if (lbBuses.SelectedIndex != -1) { btnRemoveBus.Enabled = true; btnAddLine.Enabled = true; lbLines.Items.Clear(); Buses bus = busLines.ElementAt(lbBuses.SelectedIndex); loadLines(bus); if (lbLines.Items.Count == 0) { tbMostExpensiveLine.Text = "Нема линии за овој автобус!"; tbAveragePerLine.Text = "Нема линии за овој автобус!"; } else { tbAveragePerLine.Text = bus.averagePriceOfLines().ToString(); tbMostExpensiveLine.Text = bus.mostExpensiveLine().ToString(); } } else { btnRemoveBus.Enabled = false; } }
private void loadLines(Buses bus) { lbLines.Items.Clear(); foreach (Lines l in bus.listLines) { lbLines.Items.Add(l); } }
private void button2_Click(object sender, EventArgs e) { AddLine form = new AddLine(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Buses bus = busLines.ElementAt(lbBuses.SelectedIndex); bus.addLine(form.line); loadLines(bus); AverageAndMostExpensiveRoutes(bus); } }
private void Form1_Load(object sender, EventArgs e) { Buses a = new Buses("Transkop", "OH213BT", true); a.addLine(new Lines("4:20", "Jamaica", 500)); Buses b = new Buses("Galeb", "OH111VG", false); b.addLine(new Lines("15:20", "Bitola", 150)); busLines.Add(a); busLines.Add(b); btnRemoveBus.Enabled = false; loadBuses(); }
private void btnAdd_Click(object sender, EventArgs e) { bus = new Buses(tbName.Text, tbDestination.Text, cbLocal.Checked); DialogResult = System.Windows.Forms.DialogResult.OK; MessageBox.Show("Автобусот е успешно додаден.", "Успех!", MessageBoxButtons.OK); }
private void AverageAndMostExpensiveRoutes(Buses bus) { tbAveragePerLine.Text = bus.averagePriceOfLines().ToString(); tbMostExpensiveLine.Text = bus.mostExpensiveLine().ToString(); }
internal void addAndLoad(Buses bus) { busLines.Add(bus); loadBuses(); }