Facebook
From Filip, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 279
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Xml.Linq;
  16. using System.Xml;
  17.  
  18. namespace WpfApplication13
  19. {
  20.     /// <summary>
  21.     /// Logika interakcji dla klasy MainWindow.xaml
  22.     /// </summary>
  23.    
  24.    
  25.     public partial class MainWindow : Window
  26.     {
  27.        
  28.        
  29.         static public string pathToCzytelnicy = @"..\..\Data\Czytelnicy.xml";
  30.         static public string pathToRecenzenci = @"..\..\Data\Recenzenci.xml";
  31.         static public string pathToKsiazki = @"..\..\Data\Ksiazki.xml";
  32.        
  33.         private XElement listaCzytelnikow;
  34.         private XElement listaRecenzentow;
  35.         private XElement listaKsiazek;
  36.        
  37.         public MainWindow()
  38.         {
  39.            
  40.            
  41.             InitializeComponent();
  42.             listaCzytelnikow = XElement.Load(pathToCzytelnicy);
  43.             gridCzytelnik.DataContext = listaCzytelnikow;
  44.             listaRecenzentow = XElement.Load(pathToRecenzenci);
  45.             gridRecenzent.DataContext = listaRecenzentow;
  46.             listaKsiazek = XElement.Load(pathToKsiazki);
  47.             gridKsiazka.DataContext = listaKsiazek;
  48.                  
  49.            
  50.          
  51.         }
  52.  
  53.         private void btnDodajCzytelnika_Click(object sender, RoutedEventArgs e)
  54.         {
  55.  
  56.            
  57.             Window1 oknododajczytelnik = new Window1(this);
  58.             oknododajczytelnik.Owner = this;
  59.             oknododajczytelnik.ShowDialog();
  60.            
  61.  
  62.  
  63.          
  64.            
  65.            
  66.         }
  67.  
  68.         private void btnZapiszCzytelnik_Click(object sender, RoutedEventArgs e)
  69.         {
  70.             listaCzytelnikow.Save(pathToCzytelnicy);
  71.             MessageBox.Show("Dane zostały poprawnie zapisane !");
  72.         }
  73.  
  74.        
  75.  
  76.         private void btnUsunCzytelnika_Click(object sender, RoutedEventArgs e)
  77.         {
  78.            
  79.            
  80.         }
  81.  
  82.         private void btnDodajRecenzenta_Click(object sender, RoutedEventArgs e)
  83.         {
  84.             Window2 oknododajrecenzent = new Window2(this);
  85.             oknododajrecenzent.Owner = this;
  86.             oknododajrecenzent.ShowDialog();
  87.         }
  88.  
  89.         private void btnUsunRecenzenta_Click(object sender, RoutedEventArgs e)
  90.         {
  91.  
  92.         }
  93.  
  94.         private void btnZapiszRecenzent_Click(object sender, RoutedEventArgs e)
  95.         {
  96.             listaRecenzentow.Save(pathToRecenzenci);
  97.             MessageBox.Show("Dane zostały poprawnie zapisane !");
  98.         }
  99.  
  100.         private void btnDodajKsiazke_Click(object sender, RoutedEventArgs e)
  101.         {
  102.  
  103.         }
  104.  
  105.         private void btnUsunKsiazke_Click(object sender, RoutedEventArgs e)
  106.         {
  107.  
  108.         }
  109.  
  110.         private void btnZapiszKsiazka_Click(object sender, RoutedEventArgs e)
  111.         {
  112.             listaKsiazek.Save(pathToKsiazki);
  113.             MessageBox.Show("Dane zostały poprawnie zapisane !");
  114.         }
  115.  
  116.        
  117.  
  118.        
  119.  
  120.        
  121.  
  122.        
  123.     }
  124. }
  125.  
  126.  
  127. {
  128.     class Osoba : IOsoba
  129.     {
  130.         public string Imie {get;set;}
  131.         public string Nazwisko{get;set;}
  132.         public int Wiek {get;set;}
  133.  
  134.        
  135.         public Osoba(string i, string n, int w)
  136.         {
  137.             this.Imie = i;
  138.             this.Nazwisko = n;
  139.             this.Wiek = w;
  140.         }
  141.  
  142.        
  143.  
  144.        
  145.     }
  146. }
  147.  
  148.     class Czytelnik : Osoba
  149.     {
  150.        
  151.  
  152.  
  153.        
  154.         public Czytelnik(string Imie, string Nazwisko, int Wiek)
  155.            : base(Imie,Nazwisko,Wiek)
  156.         {
  157.            
  158.         }
  159.  
  160.  
  161.     }
  162. }
  163. sealed class Recenzent : Czytelnik
  164.     {
  165.         public Recenzent(string Imie, string Nazwisko, int Wiek)
  166.             : base(Imie, Nazwisko, Wiek)
  167.         {
  168.  
  169.         }
  170.  
  171.        
  172.     }
  173.     class Ksiazka : IKsiazka
  174.     {
  175.         protected string tytul;
  176.         protected string autor;
  177.         protected DateTime dataWydania;
  178.  
  179.         public string Tytul
  180.         {
  181.             get { return this.tytul; }
  182.             set { this.tytul = value; }
  183.         }
  184.  
  185.         public String Autor
  186.         {
  187.             get { return this.autor; }
  188.             set { this.autor = value; }
  189.         }
  190.  
  191.         public DateTime DataWydania
  192.         {
  193.             get { return this.dataWydania; }
  194.             set { this.dataWydania = value; }
  195.         }
  196.  
  197.        
  198.     }