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();
 }
 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();
 }
 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();
 }
 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();
 }
 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();
 }
 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();
 }
 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
        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();
        }
示例#9
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();
 }
        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();
        }
示例#11
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();
        }
        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();
        }