private void Button_Click_1(object sender, RoutedEventArgs e) { if (WpisanaNazwaEdycja.Text.Length == 0) { MessageBox.Show("Nie można zapisać pustej notatki"); } else { try { string TekstNotatki = WpisanaNazwaEdycja.Text; XElement ZapisanyElement = XElement.Load("ZapisaneDane.xml"); var ZapisanaNotatka = from Zapis in ZapisanyElement.Elements("Notatka") where Zapis.Element("Tresc_notatki") != null && Zapis.Element("Tresc_notatki").Value == Zapamietywanie select Zapis; foreach (XElement itemElement in ZapisanaNotatka) { itemElement.SetElementValue("Tresc_notatki", TekstNotatki); } ZapisanyElement.Save("ZapisaneDane.xml"); new Notatki().Show(); this.Close(); MessageBox.Show("Zapisano notatkę", "Zapis"); } catch (Exception Wyjątek) { MessageBox.Show(Wyjątek.ToString(), "Wystąpił błąd"); } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { if (WyborSemestrMojeNotatki.SelectedValue == null) { MessageBox.Show("Nie wprowadzono semstru", "Brak filtru"); } else if (WyborPrzedmiotMojeNotatki.SelectedValue == null) { MessageBox.Show("Nie wprowadzono przedmiotu", "Brak filtru"); } else { ListaNotatek.Items.Clear(); } string Semestr = WyborSemestrMojeNotatki.Text; string Przedmiot = WyborPrzedmiotMojeNotatki.Text; var Filtr = XElement.Load("ZapisaneDane.xml") .Descendants("Notatka") .Where(Nody => Nody.Element("Semestr").Value == Semestr && Nody.Element("Przedmiot").Value == Przedmiot) .OrderBy(Zmienna => (Zmienna.Element("Tresc_notatki").Value)) .ToList <XElement>(); foreach (var Tresc in Filtr) { string NowaTresc = Tresc.Element("Tresc_notatki").Value; ListaNotatek.Items.Add(NowaTresc); } } catch (Exception Wyjątek) { MessageBox.Show(Wyjątek.ToString(), "Wystąpił błąd"); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { try { Dodanie++; XDocument Dokument = XDocument.Load("ZapisaneDane.xml"); Dokument.Root.Add(new XElement("Notatka", new XElement("Numer_notatki", Dodanie), new XElement("Semestr", WyborSemestrMain.Text), new XElement("Przedmiot", WyborPrzedmiotMain.Text), new XElement("Tresc_notatki", WpisanaNotatka.Text))); Dokument.Save("ZapisaneDane.xml"); } catch (Exception Wyjątek) { MessageBox.Show(Wyjątek.ToString(), "Wystąpił błąd"); } WpisanaNotatka.Text = null; WyborSemestrMain.SelectedItem = null; WyborPrzedmiotMain.SelectedItem = null; Storyboard Animacja = Resources["AnimacjaLabela"] as Storyboard; Animacja.Begin(ZapisanoNotatke); }