- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Xml.Linq;
- using System.Xml;
- namespace WpfApplication13
- {
- /// <summary>
- /// Logika interakcji dla klasy MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- static public string pathToCzytelnicy = @"..\..\Data\Czytelnicy.xml";
- static public string pathToRecenzenci = @"..\..\Data\Recenzenci.xml";
- static public string pathToKsiazki = @"..\..\Data\Ksiazki.xml";
- private XElement listaCzytelnikow;
- private XElement listaRecenzentow;
- private XElement listaKsiazek;
- public MainWindow()
- {
- InitializeComponent();
- listaCzytelnikow = XElement.Load(pathToCzytelnicy);
- gridCzytelnik.DataContext = listaCzytelnikow;
- listaRecenzentow = XElement.Load(pathToRecenzenci);
- gridRecenzent.DataContext = listaRecenzentow;
- listaKsiazek = XElement.Load(pathToKsiazki);
- gridKsiazka.DataContext = listaKsiazek;
- }
- private void btnDodajCzytelnika_Click(object sender, RoutedEventArgs e)
- {
- Window1 oknododajczytelnik = new Window1(this);
- oknododajczytelnik.Owner = this;
- oknododajczytelnik.ShowDialog();
- }
- private void btnZapiszCzytelnik_Click(object sender, RoutedEventArgs e)
- {
- listaCzytelnikow.Save(pathToCzytelnicy);
- MessageBox.Show("Dane zostały poprawnie zapisane !");
- }
- private void btnUsunCzytelnika_Click(object sender, RoutedEventArgs e)
- {
- }
- private void btnDodajRecenzenta_Click(object sender, RoutedEventArgs e)
- {
- Window2 oknododajrecenzent = new Window2(this);
- oknododajrecenzent.Owner = this;
- oknododajrecenzent.ShowDialog();
- }
- private void btnUsunRecenzenta_Click(object sender, RoutedEventArgs e)
- {
- }
- private void btnZapiszRecenzent_Click(object sender, RoutedEventArgs e)
- {
- listaRecenzentow.Save(pathToRecenzenci);
- MessageBox.Show("Dane zostały poprawnie zapisane !");
- }
- private void btnDodajKsiazke_Click(object sender, RoutedEventArgs e)
- {
- }
- private void btnUsunKsiazke_Click(object sender, RoutedEventArgs e)
- {
- }
- private void btnZapiszKsiazka_Click(object sender, RoutedEventArgs e)
- {
- listaKsiazek.Save(pathToKsiazki);
- MessageBox.Show("Dane zostały poprawnie zapisane !");
- }
- }
- }
- {
- class Osoba : IOsoba
- {
- public string Imie {get;set;}
- public string Nazwisko{get;set;}
- public int Wiek {get;set;}
- public Osoba(string i, string n, int w)
- {
- this.Imie = i;
- this.Nazwisko = n;
- this.Wiek = w;
- }
- }
- }
- class Czytelnik : Osoba
- {
- public Czytelnik(string Imie, string Nazwisko, int Wiek)
- : base(Imie,Nazwisko,Wiek)
- {
- }
- }
- }
- sealed class Recenzent : Czytelnik
- {
- public Recenzent(string Imie, string Nazwisko, int Wiek)
- : base(Imie, Nazwisko, Wiek)
- {
- }
- }
- class Ksiazka : IKsiazka
- {
- protected string tytul;
- protected string autor;
- protected DateTime dataWydania;
- public string Tytul
- {
- get { return this.tytul; }
- set { this.tytul = value; }
- }
- public String Autor
- {
- get { return this.autor; }
- set { this.autor = value; }
- }
- public DateTime DataWydania
- {
- get { return this.dataWydania; }
- set { this.dataWydania = value; }
- }
- }