コード例 #1
0
 private void BiuroAdd_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Biuro tmp = new Biuro {
             Adres = BiuroAdres.Text, Powierzchnia = float.Parse(BiuroPowierzchnia.Text), Typ = "Biuro", PracownikID = Int32.Parse(BiuroPracownik.Text), TypBiura = BiuroTyp.Text, Stanowiska = Int32.Parse(BiuroStanowiska.Text), Parking = BiuroParking.Text
         };
         ctx.Nieruchomosc.Add(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #2
0
 private void PracownikAdd_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Pracownik tmp = new Pracownik {
             Imie = PracownikImie.Text, Nazwisko = PracownikNazwisko.Text, Telefon = PracownikTelefon.Text, Adres = PracownikAdres.Text, Mail = PracownikMail.Text, IloscTransakcji = Int32.Parse(PracownikIloscTransakcji.Text), Typ = "Klient", Stanowisko = PracownikStanowisko.Text, Wynagrodzenie = float.Parse(PracownikWynagrodzenie.Text), Dostepnosc = PracownikDostepnosc.Text, DniUrlopu = Int32.Parse(PracownikDniUrlopu.Text)
         };
         ctx.Osoba.Add(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #3
0
 private void KlientAdd_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Klient tmp = new Klient {
             Imie = KlientImie.Text, Nazwisko = KlientNazwisko.Text, Telefon = KlientTelefon.Text, Adres = KlientAdres.Text, Mail = KlientMail.Text, IloscTransakcji = Int32.Parse(KlientIloscTransakcji.Text), Typ = "Klient", Pracownik = KlientPracownik.Text, Sprzedane = Int32.Parse(KlientSprzedane.Text), Kupione = Int32.Parse(KlientKupione.Text), Preferencje = KlientPreferencje.Text
         };
         ctx.Osoba.Add(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #4
0
 private void BiuroRemove_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Biuro tmp = new Biuro {
             ID = BiuroL.ElementAt <Biuro>(BiuroList.SelectedIndex).ID
         };
         ctx.Nieruchomosc.Attach(tmp);
         ctx.Nieruchomosc.Remove(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #5
0
 private void PracownikRemove_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Pracownik tmp = new Pracownik {
             ID = PracownikL.ElementAt <Pracownik>(PracownikList.SelectedIndex).ID
         };
         ctx.Osoba.Attach(tmp);
         ctx.Osoba.Remove(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #6
0
 private void KlientRemove_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         Klient tmp = new Klient {
             ID = KlientL.ElementAt <Klient>(KlientList.SelectedIndex).ID
         };
         ctx.Osoba.Attach(tmp);
         ctx.Osoba.Remove(tmp);
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #7
0
 private void KlientRemoveAll_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new BazyDanychContext())
     {
         foreach (var obj in KlientL)
         {
             Klient tmp = obj;
             ctx.Osoba.Attach(tmp);
             ctx.Osoba.Remove(tmp);
         }
         ctx.SaveChanges();
     }
     InitTabs();
 }
コード例 #8
0
        void InitTabs()
        {
            // DISABLE NOT IMPLEMENTED TABS
            DomTab.IsEnabled        = false;
            GruntTab.IsEnabled      = false;
            HalaTab.IsEnabled       = false;
            MieszkanieTab.IsEnabled = false;
            SpotkanieTab.IsEnabled  = false;
            UmowaTab.IsEnabled      = false;

            KlientL.Clear();
            PracownikL.Clear();
            BiuroL.Clear();

            // ADD LISTS AS SOURCES TO LISTBOXES\

            // KLIENT
            KlientList.ItemsSource = KlientL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Klient orderby b.ID select b;

                foreach (var item in query)
                {
                    KlientL.Add(item);
                }
            }
            // PRACOWNIK
            PracownikList.ItemsSource = PracownikL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Pracownik orderby b.ID select b;

                foreach (var item in query)
                {
                    PracownikL.Add(item);
                }
            }
            // BIURO
            BiuroList.ItemsSource = BiuroL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Biuro orderby b.ID select b;

                foreach (var item in query)
                {
                    BiuroL.Add(item);
                }
            }
        }
コード例 #9
0
        private void EdytujBtn_Click(object sender, RoutedEventArgs e)
        {
            if (KlientList.SelectedIndex < 0)
            {
                KlientList.SelectedIndex = 0;
            }
            if (PracownikList.SelectedIndex < 0)
            {
                PracownikList.SelectedIndex = 0;
            }
            if (Nieruchomosci.SelectedIndex < 0)
            {
                Nieruchomosci.SelectedIndex = 0;
            }
            int klientID          = KlientL.ElementAt <Klient>(KlientList.SelectedIndex).ID;
            int pracownikID       = PracownikL.ElementAt <Pracownik>(PracownikList.SelectedIndex).ID;
            int nieruchomoscID    = NieruchomoscL.ElementAt <Nieruchomosc>(Nieruchomosci.SelectedIndex).ID;
            var isNumericProwizja = int.TryParse(WysokoscProwizji.Text, out int n);

            if (!isNumericProwizja)
            {
                MessageBox.Show("Pole prowizji musi być liczbą");
                return;
            }

            if (Data.Text == "")
            {
                MessageBox.Show("Podaj datę");
                return;
            }
            using (var ctx = new BazyDanychContext())
            {
                if (UmowaList.SelectedIndex < 0)
                {
                    UmowaList.SelectedIndex = 0;
                }
                int tmpID  = UmowaL.ElementAt <Umowa>(UmowaList.SelectedIndex).ID;
                var result = ctx.Umowa.SingleOrDefault(b => b.ID == tmpID);
                if (result != null)
                {
                    result.Cel      = "Umowa"; result.Typ = TypUmowy.Text;
                    result.KlientID = klientID; result.PracownikID = pracownikID;
                    result.Prowizja = Int32.Parse(WysokoscProwizji.Text); result.Termin = Data.Text;
                    result.Miejsce  = Miejsce.Text; result.NieruchomoscID = nieruchomoscID;
                    ctx.SaveChanges();
                }
            }
            InitTabs();
        }
コード例 #10
0
 private void UsunBtn_Click(object sender, RoutedEventArgs e)
 {
     if (UmowaL.Count > 0)
     {
         using (var ctx = new BazyDanychContext())
         {
             Umowa tmp = new Umowa {
                 ID = UmowaL.ElementAt <Umowa>(UmowaList.SelectedIndex).ID
             };
             ctx.Spotkanie.Attach(tmp);
             ctx.Spotkanie.Remove(tmp);
             ctx.SaveChanges();
         }
     }
     InitTabs();
 }
コード例 #11
0
        private void EditBtn_Click(object sender, RoutedEventArgs e)
        {
            if (KlientImie.Text == "" | KlientNazwisko.Text == "" | KlientAdres.Text == "" | KlientTelefon.Text == "")
            {
                MessageBox.Show("Proszę uzupełnić obowiązkowe pola");
                return;
            }
            var isNumericTelefon = int.TryParse(KlientTelefon.Text, out int m);

            if (!isNumericTelefon | KlientTelefon.Text.Length != 9)
            {
                MessageBox.Show("Niepoprawny numer telefonu");
                return;
            }
            if (KlientMail.Text != "" && !KlientMail.Text.Contains("@"))
            {
                MessageBox.Show("Niepoprawny adres email");
                return;
            }
            var isNumericKupione   = int.TryParse(KlientKupione.Text, out int n);
            var isNumericSprzedane = int.TryParse(KlientSprzedane.Text, out int k);

            if (!isNumericKupione | !isNumericSprzedane)
            {
                MessageBox.Show("Pole transakcji musi być liczbą");
                return;
            }
            using (var ctx = new BazyDanychContext())
            {
                int tmpID  = KlientL.ElementAt <Klient>(KlientList.SelectedIndex).ID;
                var result = ctx.Klient.SingleOrDefault(b => b.ID == tmpID);
                if (result != null)
                {
                    result.Imie        = KlientImie.Text; result.Nazwisko = KlientNazwisko.Text;
                    result.Telefon     = KlientTelefon.Text; result.Adres = KlientAdres.Text;
                    result.Mail        = KlientMail.Text; result.IloscTransakcji = Int32.Parse(KlientKupione.Text) + Int32.Parse(KlientSprzedane.Text);
                    result.Typ         = "Klient"; result.Pracownik = KlientPracownik.Text;
                    result.Sprzedane   = Int32.Parse(KlientSprzedane.Text); result.Kupione = Int32.Parse(KlientKupione.Text);
                    result.Preferencje = KlientPreferencje.Text;
                    ctx.SaveChanges();
                }
            }
            InitTabs();
        }
コード例 #12
0
        private void InitializeDataBase()
        {
            using (var ctx = new BazyDanychContext())
            {
                //var query = from b in ctx.Osoba orderby b.ID select b;

                //foreach (var item in query)
                //{
                BazaDanychLbl.Text = "Nazwa bazy: ProjektBD \n" +
                                     "Struktura tablic: \n" +
                                     "  │\n  ├  Osoba\n  │      ├ Pracownik\n" +
                                     "  │      └ Klient\n  │\n  ├  Nieruchomość\n" +
                                     "  │      ├ Grunt\n  │      ├ Hala\n" +
                                     "  │      ├ Mieszkanie\n  │      ├ Dom\n" +
                                     "  │      └ Biuro\n  │\n  ├  Umowa\n  │\n" +
                                     "  └  Spotkanie";
                //}
            }
        }
コード例 #13
0
        private void DodajBtn_Click(object sender, RoutedEventArgs e)
        {
            if (KlientList.SelectedIndex < 0)
            {
                KlientList.SelectedIndex = 0;
            }
            if (PracownikList.SelectedIndex < 0)
            {
                PracownikList.SelectedIndex = 0;
            }
            if (Nieruchomosci.SelectedIndex < 0)
            {
                Nieruchomosci.SelectedIndex = 0;
            }
            int klientID          = KlientL.ElementAt <Klient>(KlientList.SelectedIndex).ID;
            int pracownikID       = PracownikL.ElementAt <Pracownik>(PracownikList.SelectedIndex).ID;
            int nieruchomoscID    = NieruchomoscL.ElementAt <Nieruchomosc>(Nieruchomosci.SelectedIndex).ID;
            var isNumericProwizja = int.TryParse(WysokoscProwizji.Text, out int n);

            if (!isNumericProwizja)
            {
                MessageBox.Show("Pole prowizji musi być liczbą");
                return;
            }
            if (Data.Text == "")
            {
                MessageBox.Show("Podaj datę");
                return;
            }
            using (var ctx = new BazyDanychContext())
            {
                Umowa tmp = new Umowa {
                    Cel = "Umowa", KlientID = klientID, PracownikID = pracownikID, Miejsce = Miejsce.Text, NieruchomoscID = nieruchomoscID, Prowizja = Int32.Parse(WysokoscProwizji.Text), Termin = Data.Text, Typ = TypUmowy.Text
                };
                ctx.Spotkanie.Add(tmp);
                ctx.SaveChanges();
            }
            InitTabs();
        }
コード例 #14
0
        private void KlientAdd_Click(object sender, RoutedEventArgs e)
        {
            if (KlientImie.Text == "" | KlientNazwisko.Text == "" | KlientAdres.Text == "" | KlientTelefon.Text == "")
            {
                MessageBox.Show("Proszę uzupełnić obowiązkowe pola");
                return;
            }
            var isNumericTelefon = int.TryParse(KlientTelefon.Text, out int m);

            if (!isNumericTelefon | KlientTelefon.Text.Length != 9)
            {
                MessageBox.Show("Niepoprawny numer telefonu");
                return;
            }
            if (KlientMail.Text != "" && !KlientMail.Text.Contains("@"))
            {
                MessageBox.Show("Niepoprawny adres email");
                return;
            }
            var isNumericKupione   = int.TryParse(KlientKupione.Text, out int n);
            var isNumericSprzedane = int.TryParse(KlientSprzedane.Text, out int k);

            if (!isNumericKupione | !isNumericSprzedane)
            {
                MessageBox.Show("Pole transakcji musi być liczbą");
                return;
            }
            using (var ctx = new BazyDanychContext())
            {
                Klient tmp = new Klient {
                    Imie = KlientImie.Text, Nazwisko = KlientNazwisko.Text, Telefon = KlientTelefon.Text, Adres = KlientAdres.Text, Mail = KlientMail.Text, IloscTransakcji = Int32.Parse(KlientKupione.Text) + Int32.Parse(KlientSprzedane.Text), Typ = "Klient", Pracownik = KlientPracownik.Text, Sprzedane = Int32.Parse(KlientSprzedane.Text), Kupione = Int32.Parse(KlientKupione.Text), Preferencje = KlientPreferencje.Text
                };
                ctx.Osoba.Add(tmp);
                ctx.SaveChanges();
            }
            InitTabs();
        }
コード例 #15
0
        void InitTabs()
        {
            // DISABLE NOT IMPLEMENTED TABS
            KlientL.Clear();

            // KLIENT
            if (KlientFiltr.IsChecked == true)
            {
                KlientList.ItemsSource = KlientL;
                using (var ctx = new BazyDanychContext())
                {
                    var query = from b in ctx.Klient orderby b.ID select b;

                    foreach (var item in query)
                    {
                        bool f = false, s = false, t = false;
                        if (CzyWiecej.IsChecked == true)
                        {
                            var isNumeric = int.TryParse(WiecejNiz.Text, out int l);
                            if (!isNumeric)
                            {
                                MessageBox.Show("Pole Wiecej niz musi byc liczba");
                                return;
                            }
                            if (item.IloscTransakcji > Int32.Parse(WiecejNiz.Text))
                            {
                                f = true;
                            }
                        }
                        else
                        {
                            f = true;
                        }
                        if (WyborPreferencji.Text != "Brak")
                        {
                            if (item.Preferencje == WyborPreferencji.Text)
                            {
                                s = true;
                            }
                        }
                        else
                        {
                            s = true;
                        }
                        if (WiecejKupionych.IsChecked == true)
                        {
                            if (item.Kupione >= item.Sprzedane)
                            {
                                t = true;
                            }
                        }
                        else if (WiecejSprzedanych.IsChecked == true)
                        {
                            if (item.Sprzedane >= item.Kupione)
                            {
                                t = true;
                            }
                        }
                        else
                        {
                            t = true;
                        }
                        if (f && s && t)
                        {
                            KlientL.Add(item);
                        }
                    }
                }
            }
            else
            {
                KlientList.ItemsSource = KlientL;
                using (var ctx = new BazyDanychContext())
                {
                    var query = from b in ctx.Klient orderby b.ID select b;

                    foreach (var item in query)
                    {
                        KlientL.Add(item);
                    }
                }
            }
        }
コード例 #16
0
        private void InitTabs()
        {
            // INIT NIERUCHOMOSCI
            NieruchomoscL.Clear();
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Nieruchomosc orderby b.ID select b;

                foreach (var item in query)
                {
                    NieruchomoscL.Add(item);
                }
            }

            // INIT LIST BOXES
            Nieruchomosci.SelectedIndex = 0;
            Nieruchomosci.ItemsSource   = NieruchomoscL;
            TypUmowy.SelectedIndex      = 0;
            TypUmowy.ItemsSource        = new BindingList <string>()
            {
                "Kupno", "Sprzedaz", "Wynajem"
            };

            // DISABLE NOT IMPLEMENTED TABS
            KlientL.Clear();
            PracownikL.Clear();
            UmowaL.Clear();

            // INIT LISTS
            KlientList.ItemsSource = KlientL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Klient orderby b.ID select b;

                foreach (var item in query)
                {
                    KlientL.Add(item);
                }
            }

            PracownikList.ItemsSource = PracownikL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Pracownik orderby b.ID select b;

                foreach (var item in query)
                {
                    PracownikL.Add(item);
                }
            }

            UmowaList.ItemsSource = UmowaL;
            using (var ctx = new BazyDanychContext())
            {
                var query = from b in ctx.Umowa orderby b.ID select b;

                foreach (var item in query)
                {
                    UmowaL.Add(item);
                }
            }
        }