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"); } }
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(SectionPresenter sectionPresenter, SectionEditPresenter sectionEdit, FixedAssetsApp.FixedAssetsWebService.Section obj) { FixedAssetsApp.FixedAssetsWebService.Section section = ((FixedAssetsApp.FixedAssetsWebService.Section)sectionEdit.View.DataContext); obj.email = section.email; obj.id = section.id; obj.locality = section.locality; obj.name = section.name; obj.phone_number = section.phone_number; obj.post = section.post; obj.postal_code = section.postal_code; obj.short_name = section.short_name; obj.street = section.street; sectionPresenter.View.dataGridSections.Items.Refresh(); }