Пример #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            if (AreBikesShown)
            {
                Bike            bike = new Bike(0, " ", Bikekind.City);
                AddOrUpdateBike add  = new AddOrUpdateBike(bike);
                add.Title = "Tilføj";
                add.ShowDialog();

                if (!add.IsCancelled)
                {
                    dataController.NewEntity(bike);
                }
            }
            else
            {
                Rentee            rentee = new Rentee("Navn", "Addresse", "000-000-000", DateTime.Now);
                AddOrUpdateRentee add    = new AddOrUpdateRentee(rentee);
                add.Title = "Tilføj";
                add.ShowDialog();

                if (!add.IsCancelled)
                {
                    dataController.NewEntity(rentee);
                }
            }
        }
Пример #2
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            if (DtgSelected.SelectedItem == null)
            {
                MessageBox.Show("Du skal vælge et row for at ændre det");
                return;
            }
            else
            {
                if (AreBikesShown)
                {
                    Bike bike = (Bike)DtgSelected.SelectedCells[0].Item;
                    bike = new Bike(bike.PricePerDay, bike.Description, bike.Kind, bike.ID);
                    AddOrUpdateBike edit = new AddOrUpdateBike(bike);
                    edit.Title = "Rediger";
                    edit.ShowDialog();

                    if (!edit.IsCancelled)
                    {
                        dataController.UpdateEntity(bike);
                    }
                }
                else
                {
                    Rentee rentee = (Rentee)DtgSelected.SelectedCells[0].Item;
                    rentee = new Rentee(rentee.Name, rentee.Address, rentee.Phonenumber, rentee.RegisterDate, rentee.ID);
                    AddOrUpdateRentee edit = new AddOrUpdateRentee(rentee);
                    edit.Title = "Rediger";
                    edit.ShowDialog();

                    if (!edit.IsCancelled)
                    {
                        dataController.UpdateEntity(rentee);
                    }
                }
            }
        }