コード例 #1
0
 private void AptAddIncident(object sender, RoutedEventArgs e)
 {
     LokaVerkefniCL.Incident inci = new LokaVerkefniCL.Incident(EditingApartment.ID);
     DContext.context.Incidents.Add(inci);
     DContext.context.SaveChanges();
     DContext.context.Incidents.Load();
     LokaVerkefniCL.Apartment temp = (LokaVerkefniCL.Apartment)ApartmentDisplayComboBoxApartment.SelectedItem;
     EditingApartment.Incidents = temp.Incidents;
 }
コード例 #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;
 }
コード例 #3
0
        public void AptDeleteApartment(object sender, RoutedEventArgs e)
        {
            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);
            }
        }
コード例 #4
0
 /// <summary>
 /// Changing active grid to Editing
 /// </summary>
 private void AptEnableEdit(object sender, RoutedEventArgs e)
 {
     // linking the selected Apartment to the EditingApartment Variable
     EditingApartment = new LokaVerkefniCL.Apartment((LokaVerkefniCL.Apartment)ApartmentDisplayComboBoxApartment.SelectedItem);
     // setting the EditingApartment as the Data Context of the Edit Grid
     ApartmentEdit.DataContext = EditingApartment;
     // Linking the Zip Combobox to the zip VievSource
     ApartmentEditComboBoxZip.DataContext = ApartmentzipviewSource;
     // Making the zip combo box select the correct zip,
     // Combobox starts counting at 0 while database starts at 1 so a correction is needed
     ApartmentEditComboBoxZip.SelectedIndex = EditingApartment.Address.ZipID - 1;
     // Hiding the Display Grid and showing the Edit Grid
     ApartmentDisplay.Visibility = Visibility.Collapsed;
     ApartmentEdit.Visibility    = Visibility.Visible;
 }
コード例 #5
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 = ApartmentzipviewSource;
     // Hiding the Display Grid and showing the New Apartment Grid
     ApartmentDisplay.Visibility      = Visibility.Collapsed;
     ApartmentNewApartment.Visibility = Visibility.Visible;
 }