private void ComboBox_Sections_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     PersonModel ps = (PersonModel)DataContext;
     SectionMethods sm = new SectionMethods();
     ps.short_section_name = (sender as ComboBox).SelectedItem.ToString();
     ps.id_section = sm.GetIdByShortName(ps.short_section_name);
 }
        public ObservableCollection<FixedAssetsApp.FixedAssetsWebService.Section> CreateSectionList(object[] table)
        {
            SectionMethods sm = new SectionMethods();
            ObservableCollection<FixedAssetsApp.FixedAssetsWebService.Section> list = new ObservableCollection<FixedAssetsApp.FixedAssetsWebService.Section>();

            foreach (FixedAssetsApp.FixedAssetsWebService.Section section in table)
            {
                list.Add(section);
            }
            return list;
        }
 public static PersonModel CreatePersonSection(Person person)
 {
     SectionMethods sm = new SectionMethods();
     PersonModel temp;
     temp = new PersonModel();
     temp.id = person.id;
     temp.name = person.name;
     temp.surname = person.surname;
     temp.phone_number = person.phone_number;
     temp.phone_number2 = person.phone_number2;
     temp.area_code = person.area_code;
     temp.email = person.email;
     temp.id_section = person.id_section;
     temp.short_section_name = sm.GetShortNameById(person.id_section);
     return temp;
 }
 private void btn_AddSection_Click(object sender, RoutedEventArgs e)
 {
     SectionMethods sectionMethods = new SectionMethods();
     SectionEditPresenter sectionEditPresenter = new SectionEditPresenter(new SectionEditView(), new FixedAssetsApp.FixedAssetsWebService.Section());
     FixedAssetsApp.FixedAssetsWebService.Section section = (FixedAssetsApp.FixedAssetsWebService.Section)(sectionEditPresenter.View.DataContext);
     sectionEditPresenter.View.Label_AddOrEditSection.Content = "Dodawanie sekcji";
     SectionPresenter sectionPresenter = (SectionPresenter)this.DataContext;
     if (section != null)
     {
         sectionEditPresenter.View.ShowDialog();
         if (sectionEditPresenter.View.DialogResult == true)
         {
             sectionPresenter.SaveSection(section, false);
             sectionPresenter.GetAllSections();
         }
     }
     else
     {
         MessageBox.Show("Wystąpił błąd podczas dodawania sekcji. Spróbuj ponownie");
     }
 }
 public static ObservableCollection<PersonModel> CreatePersonSectionList(object[] table)
 {
     SectionMethods sm = new SectionMethods();
     ObservableCollection<PersonModel> personsectionList = new ObservableCollection<PersonModel>();
     PersonModel temp;
     foreach (Person person in table)
     {
         temp = new PersonModel();
         temp.id = person.id;
         temp.name = person.name;
         temp.surname = person.surname;
         temp.phone_number = person.phone_number;
         temp.phone_number2 = person.phone_number2;
         temp.area_code = person.area_code;
         temp.email = person.email;
         temp.id_section = person.id_section;
         temp.short_section_name = sm.GetShortNameById(person.id_section);
         personsectionList.Add(temp);
     }
     return personsectionList;
 }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SectionPresenter sectionPresenter = (SectionPresenter)this.DataContext;
                SectionMethods sectionMethods = new SectionMethods();
                FixedAssetsApp.FixedAssetsWebService.Section section = sectionMethods.CloneSection((FixedAssetsApp.FixedAssetsWebService.Section)(sectionPresenter.View.dataGridSections.SelectedItem));
                SectionEditPresenter sectionEditPresenter = new SectionEditPresenter(new SectionEditView(), section);
                sectionEditPresenter.View.Label_AddOrEditSection.Content = "Edytowanie sekcji";

                if (sectionEditPresenter.View.ShowDialog() == true)
                {
                    sectionPresenter.SaveSection(section, true);
                    FixedAssetsApp.FixedAssetsWebService.Section temp = (FixedAssetsApp.FixedAssetsWebService.Section)sectionPresenter.View.dataGridSections.SelectedItem;
                    ChangeCurrentRow(sectionPresenter, sectionEditPresenter, temp);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void ChangeCurrentRow(PersonPresenter presenterPerson,PersonEditPresenter presenterEdit, PersonModel obj)
 {
     SectionMethods sm = new SectionMethods(); 
     PersonModel ps = ((PersonModel)presenterEdit.View.DataContext);
     obj.area_code = ps.area_code;
     obj.id_section = ps.id_section;
     obj.name = ps.name;
     obj.phone_number = ps.phone_number;
     obj.phone_number2 = ps.phone_number2;
     obj.short_section_name = sm.GetShortNameById(ps.id_section);
     obj.surname = ps.surname;
     obj.email = ps.email;
     presenterPerson.View.dataGridPersons.Items.Refresh();
 }