Ejemplo n.º 1
0
        public void AptDeleteApartment(object sender, RoutedEventArgs e)
        {
            EditingApartment = (LokaVerkefniCL.Apartment)ApartmentDisplayComboBoxApartment.SelectedItem;
            bool ApartmentInRent = false;

            foreach (Contract a in DContext.Contracts)
            {
                if (a.ApartmentID == EditingApartment.ID)
                {
                    ApartmentInRent = true;
                }
            }

            if (ApartmentInRent)
            {
                MessageBox.Show("Íbúðin er í leigu og ekki hægt að Eyða");
            }

            else
            {
                MessageBoxResult result = MessageBox.Show("Ertu Viss um að þú Viljir Eyða íbúðini?", "Staðfesting", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.No)
                {
                }
                else if (result == MessageBoxResult.Yes)
                {
                    LokaVerkefniCL.Apartment temp = (LokaVerkefniCL.Apartment)ApartmentDisplayComboBoxApartment.SelectedItem;
                    DContext.context.Apartments.Remove(temp);
                }
            }
        }
Ejemplo n.º 2
0
 private void ContractNewBtnSave_Click(object sender, RoutedEventArgs e)
 {
     ContractApartment    = (LokaVerkefniCL.Apartment)ContractNewComboBoxApartment.SelectedItem;
     Contract.ApartmentID = ContractApartment.ID;
     ContractTenant       = (LokaVerkefniCL.Tenant)ContractNewComboBoxTenant.SelectedItem;
     Contract.PersonID    = ContractTenant.ID;
     DContext.context.Contracts.AddOrUpdate(c => new { c.PersonID, c.ApartmentID }, Contract);
     DContext.context.SaveChanges();
     ContractNew.Visibility  = Visibility.Collapsed;
     ContractMain.Visibility = Visibility.Visible;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Changing Active Grid to New Apartment
 /// </summary>
 private void AptNewaptm(object sender, RoutedEventArgs e)
 {
     // Creating a Blank Apartment Variable and asigning it to NewApartment
     NewApartment = new LokaVerkefniCL.Apartment();
     // Creating a Blank Adress and asigning it to NewAdress
     NewAddress = new LokaVerkefniCL.Address();
     // Connecting the blank Adress to the Blank Apartment
     NewApartment.Address = NewAddress;
     // Seting NewApartment as the Data context for the New Apartment Grid
     ApartmentNewApartment.DataContext = NewApartment;
     // Linking the Zip Combobox to the zip VievSource
     ApartmentNewApartmentComboBoxZip.DataContext = ZipViewSource;
     // Hiding the Display Grid and showing the New Apartment Grid
     ApartmentDisplay.Visibility      = Visibility.Collapsed;
     ApartmentNewApartment.Visibility = Visibility.Visible;
 }