private void buttonShowBus_Click(object sender, EventArgs e)
 {
     if (comboBoxBusID.SelectedIndex != -1)
     {
         BusDialog editBus = new BusDialog((int)comboBoxBusID.SelectedItem);
         editBus.ShowDialog();
     }
 }
        private void buttonNewBus_Click(object sender, EventArgs e)
        {
            BusDialog editBus = new BusDialog(new Bus(), BusDialog.Mode.New);

            editBus.ShowDialog();

            GetDataFromDatabase();
        }
Beispiel #3
0
        /// <summary>
        /// Zeigt den Jewaligen Dialog an
        /// </summary>
        /// <param name="mode"></param>
        private void ShowDialog(Mode mode)
        {
            // Testet die Verbundung zur Datenbank
            if (Database.ConnectionAvailable())
            {
                if (type == Type.Busflotte)
                {
                    Bus         bus = new Bus();
                    DataRowView dr  = (DataRowView)tblBusBS.Current;
                    if (dr != null)
                    {
                        bus.BusID          = (int)dr.Row.ItemArray[0];
                        bus.AusstattungsID = (int)dr.Row.ItemArray[1];
                        bus.SitzplanID     = (int)dr.Row.ItemArray[2];
                        bus.HasWlan        = (bool)dr.Row.ItemArray[3];
                        bus.HasToilet      = (bool)dr.Row.ItemArray[4];
                        bus.HasDrinks      = (bool)dr.Row.ItemArray[5];
                        bus.CountSeats     = (int)dr.Row.ItemArray[6];
                        bus.CountReclining = (int)dr.Row.ItemArray[7];
                        bus.CountSleeping  = (int)dr.Row.ItemArray[8];
                    }
                    BusDialog busDialog = new BusDialog(bus, (BusDialog.Mode)mode);
                    busDialog.ShowDialog();
                }
                else if (type == Type.Buchungen)
                {
                    Buchung     buchung = new Buchung();
                    DataRowView dr      = (DataRowView)tblBuchungBS.Current;
                    if (dr != null)
                    {
                        buchung.BuchungsID      = (int)dr.Row.ItemArray[0];
                        buchung.BenutzerdatenID = (int)dr.Row.ItemArray[1];
                        buchung.LinienID        = (int)dr.Row.ItemArray[2];
                        buchung.Nachname        = (string)dr.Row.ItemArray[3].ToString();
                        buchung.Vorname         = (string)dr.Row.ItemArray[4].ToString();
                        buchung.Sitzplaetze     = (int)dr.Row.ItemArray[5];
                        buchung.Liegesitze      = (int)dr.Row.ItemArray[6];
                        buchung.Schlafsitze     = (int)dr.Row.ItemArray[7];
                        if (dr.Row.ItemArray[8].ToString() != "")
                        {
                            buchung.Starthaltestelle = (string)dr.Row.ItemArray[8];
                        }
                        if (dr.Row.ItemArray[9].ToString() != "")
                        {
                            buchung.Endhaltestelle = (string)dr.Row.ItemArray[9];
                        }
                    }
                    BuchungDialog buchungDialog = new BuchungDialog(buchung, (BuchungDialog.Mode)mode);
                    buchungDialog.ShowDialog();
                }
                else if (type == Type.Buslinie)
                {
                    Buslinie    buslinie = new Buslinie();
                    DataRowView dr       = (DataRowView)tblBuslinieBS.Current;
                    if (dr != null)
                    {
                        buslinie.LinienID   = (int)dr.Row.ItemArray[0];
                        buslinie.FahrplanID = (int)dr.Row.ItemArray[1];
                        buslinie.BusID      = (int)dr.Row.ItemArray[2];
                        buslinie.Start      = (string)dr.Row.ItemArray[3];
                        buslinie.Ende       = (string)dr.Row.ItemArray[4];
                    }
                    BuslinieDialog buslinieDialog = new BuslinieDialog(buslinie, (BuslinieDialog.Mode)mode);
                    buslinieDialog.ShowDialog();
                }
                else if (type == Type.Fahrplan)
                {
                    Fahrplan    fahrplan = new Fahrplan();
                    DataRowView dr       = (DataRowView)tblFahrplanBS.Current;
                    if (dr != null)
                    {
                        fahrplan.FahrplanID   = (int)dr.Row.ItemArray[0];
                        fahrplan.AbfahrtsZeit = (string)dr.Row.ItemArray[1].ToString();
                        fahrplan.Abfahrtdatum = (DateTime)dr.Row.ItemArray[2];
                        fahrplan.Fahrtdauer   = (string)dr.Row.ItemArray[3].ToString();
                        fahrplan.Fahrpreis    = (double)dr.Row.ItemArray[4];
                    }
                    FahrplanDialog fahrplanDialog = new FahrplanDialog(fahrplan, (FahrplanDialog.Mode)mode);
                    fahrplanDialog.ShowDialog();
                }

                ResetView();
            }
            else
            {
                MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden.");
            }
        }