예제 #1
0
 private void Yes_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var sql = @"Update [User] SET FirstName = @FirstName WHERE Id = @Id";
         ctx.Database.ExecuteSqlCommand(sql);
     }
 }
예제 #2
0
 private void TechReviewList_Checked(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var techReviewList = ctx.BadanieTechniczne
                              .SqlQuery("Select * From BadanieTechniczne")
                              .ToList <TechnicalReview>();
         MyList4.ItemsSource = techReviewList;
     }
     MyList4.Visibility = Visibility.Visible;
 }
예제 #3
0
 private void DriversWithNoCarsList_Checked(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var driverNoCarList = ctx.Kierowcy
                               .SqlQuery("Select * From Pojazdy p INNER JOIN Kierowcy k ON p.DriverId = k.DriverId WHERE CarId IS NULL")
                               .ToList <Drivers>();
         MyList5.ItemsSource = driverNoCarList;
     }
     MyList5.Visibility = Visibility.Visible;
 }
예제 #4
0
 private void IpList_Checked(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var IpList = ctx.Polisa
                      .SqlQuery("Select * From InsurancePolicies")
                      .ToList <InsurancePolicy>();
         MyList3.ItemsSource = IpList;
     }
     MyList3.Visibility = Visibility.Visible;
 }
예제 #5
0
 private void DriversList_Checked(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var driverList = ctx.Kierowcy
                          .SqlQuery("Select * From Drivers")
                          .ToList <Drivers>();
         MyList1.ItemsSource = driverList;
         //firstColumn.DisplayMemberBinding = "{Binding Path=FirstName}"; <- to nie dziala
     }
     MyList1.Visibility = Visibility.Visible;
 }
예제 #6
0
 private void CarsList_Checked(object sender, RoutedEventArgs e)
 {
     using (var ctx = new CepikDB())
     {
         var carList = ctx.Pojazdy
                       .SqlQuery("SELECT *" +
                                 "FROM Cars" +
                                 "")
                       .ToList <Cars>();
         MyList2.ItemsSource = carList;
     }
     MyList2.Visibility = Visibility.Visible;
 }
예제 #7
0
 public MainWindow()
 {
     InitializeComponent();
     CreateDbButton.IsEnabled = false;
     using (var database = new CepikDB()) //nie dziala, nie rozumiem czemu
     {
         if (database.Database.Exists())
         {
             CreateDbButton.IsEnabled = false;
         }
         else
         {
             CreateDbButton.IsEnabled = true;
         }
     }
 }
예제 #8
0
 private void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     using (var database = new CepikDB())
     {
         if (!database.Database.Exists())
         {
             Database.SetInitializer(new CreateDatabaseIfNotExists <CepikDB>());
             var context = new CepikDB();
             context.Database.Create();
         }
         var admin = new Users();
         admin.Login    = "******";
         admin.Password = "******";
         admin.Role     = 1;
         database.Uzytkownicy.Add(admin);
         database.SaveChanges();
     }
 }
예제 #9
0
        private void logInButton_Click(object sender, RoutedEventArgs e)
        {
            using (var ctx = new CepikDB())
            {
                var login    = LoginTextBox.Text;
                var password = PasswordTextBox.Text;

                var logginIn = ctx.Uzytkownicy
                               .Where(s => s.Login == login && s.Password == password)
                               .FirstOrDefault <Users>();
                if (logginIn == null)
                {
                    Wrong.Content = "Nieprawidłowy login lub hasło.";
                }
                else if (logginIn.Role == 1)
                {
                    MainMenu mm = new MainMenu();
                    mm.Owner = this;
                    this.Hide();
                    mm.ShowDialog();

                    mm.Hello.Content = "Witaj, adminie";
                }
                else if (logginIn.Role == 2)
                {
                    MainMenu mm = new MainMenu();
                    mm.Owner = this;
                    this.Hide();
                    mm.ShowDialog();
                    mm.Hello.Content = "Witaj, diagnosto";
                }
                else if (logginIn.Role == 3)
                {
                    MainMenu mm = new MainMenu();
                    mm.Owner = this;
                    this.Hide();
                    mm.ShowDialog();
                    mm.Hello.Content = "Witaj, użytkowniku";
                }
            }
        }
예제 #10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  user = new Users();
                bool passwordcondition = false;
                bool loginCondition    = false;
                bool checkboxCondition = false;

                //login
                if (string.IsNullOrEmpty(loginTextBox.Text))
                {
                    LoginNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    user.Login     = loginTextBox.Text;
                    loginCondition = true;
                };

                //password
                if (string.IsNullOrEmpty(passwordTextBox.Text))
                {
                    PasswordNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    user.Password     = passwordTextBox.Text;
                    passwordcondition = true;
                };

                //role
                if (adminCheckBox.IsChecked == true)
                {
                    diagnostCheckBox.IsChecked = false;
                    userCheckBox.IsChecked     = false;
                    user.Role         = 1;
                    checkboxCondition = true;
                }
                else if (diagnostCheckBox.IsChecked == true)
                {
                    adminCheckBox.IsChecked = false;
                    userCheckBox.IsChecked  = false;
                    user.Role         = 2;
                    checkboxCondition = true;
                }
                else if (userCheckBox.IsChecked == true)
                {
                    adminCheckBox.IsChecked    = false;
                    diagnostCheckBox.IsChecked = false;
                    user.Role         = 3;
                    checkboxCondition = true;
                }
                else
                {
                    checkboxCondition = false;
                }

                if (passwordcondition && loginCondition && checkboxCondition)
                {
                    saveData.Content     = "Trwa dodawanie użytkownika do bazy...";
                    saveData.Visibility  = Visibility.Visible;
                    saveButton.IsEnabled = false;
                    backButton.IsEnabled = false;
                    context.Uzytkownicy.Add(user);
                    context.SaveChanges();
                    saveData.Content     = "Użytkownik został dodant do bazy!";
                    saveButton.IsEnabled = true;
                    saveButton.IsEnabled = true;
                    foreach (Control ctl in Container.Children)
                    {
                        if (ctl.GetType() == typeof(Label))
                        {
                            ((Label)ctl).Visibility = Visibility.Hidden;
                        }
                        if (ctl.GetType() == typeof(TextBox))
                        {
                            ((TextBox)ctl).Text = String.Empty;
                        }
                        if (ctl.GetType() == typeof(CheckBox))
                        {
                            ((CheckBox)ctl).IsChecked = false;
                        }
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(2));
                    saveData.Visibility = Visibility.Hidden;
                }
            }
        }
예제 #11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  carInfo          = new CarDocsAndInfo();
                var  RegexVIN         = new Regex(@"^[A-Z0-9]{17}$");
                var  RegexDate        = new Regex(@"^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9]{3}$");
                var  RegexCarId       = new Regex(@"^[0-9]$");
                bool VINcondition     = false;
                bool DateCondition    = false;
                bool IdCondition      = false;
                bool carCardCondition = false;

                //czy mniej kodu jest tu, czy jak zrobie to dynamicznie?


                //vin number
                if (string.IsNullOrEmpty(vinTextBox.Text))
                {
                    vinNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(vinTextBox.Text))
                {
                    vinIncorrect.Visibility = Visibility.Hidden;
                }
                else
                {
                    carInfo.VinNumber = vinTextBox.Text;
                    VINcondition      = true;
                };

                //car card nr
                if (string.IsNullOrEmpty(carCardTextBox.Text))
                {
                    carCardNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    carInfo.CarCardNumber = carCardTextBox.Text;
                    carCardCondition      = true;
                };

                //date
                if (string.IsNullOrEmpty(firstRegistryTextBox.Text))
                {
                    DateNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(firstRegistryTextBox.Text))
                {
                    firstRegistryIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    carInfo.FirstRegistrationDate = DateTime.Parse(firstRegistryTextBox.Text);
                    DateCondition = true;
                }

                //car id
                int  number;
                bool success = Int32.TryParse(carIdTextBox.Text, out number);
                if (!success || !RegexCarId.IsMatch(carIdTextBox.Text))
                {
                    carIdIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(carIdTextBox.Text))
                {
                    IdNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    carInfo.CarId = number;
                    IdCondition   = true;
                }


                if (IdCondition && DateCondition && VINcondition && carCardCondition)
                {
                    try
                    {
                        backButton.IsEnabled = false;
                        saveButton.IsEnabled = false;
                        saveData.Content     = "Trwa zapisywanie danych do bazy";
                        saveData.Visibility  = Visibility.Visible;
                        context.Informacje.Add(carInfo);
                        context.SaveChanges();
                        saveData.Content     = "Dane zostały zapisane";
                        backButton.IsEnabled = true;
                        saveButton.IsEnabled = true;
                        foreach (Control ctl in Container.Children)
                        {
                            if (ctl.GetType() == typeof(Label))
                            {
                                ((Label)ctl).Visibility = Visibility.Hidden;
                            }
                            if (ctl.GetType() == typeof(TextBox))
                            {
                                ((TextBox)ctl).Text = String.Empty;
                            }
                        }
                        Thread.Sleep(TimeSpan.FromSeconds(2));
                        saveData.Visibility = Visibility.Hidden;
                    }
                    catch (System.Data.Entity.Infrastructure.DbUpdateException)
                    {
                        ErrorWindow ew = new ErrorWindow();
                        ew.Owner = this;
                        ew.ShowDialog();
                    }
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  ip                  = new InsurancePolicy();
                var  RegexID             = new Regex(@"^[0-9]{1,6}$");
                var  RegexDate           = new Regex(@"^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9]{3}$");
                bool IpIdCondition       = false;
                bool CarIdCondition      = false;
                bool firstDateCondition  = false;
                bool secondDateCondition = false;



                //IP id
                int  number;
                bool success = Int32.TryParse(IpIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(IpIdTextBox.Text))
                {
                    IpIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!success || !RegexID.IsMatch(IpIdTextBox.Text))
                {
                    IpIdIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    ip.InsuranceId = number;
                    IpIdCondition  = true;
                };

                //first date
                if (string.IsNullOrEmpty(firstDateTextBox.Text))
                {
                    FirstDateNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(firstDateTextBox.Text))
                {
                    FirstDateIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    ip.PolicyStartDay  = DateTime.Parse(firstDateTextBox.Text);
                    firstDateCondition = true;
                };

                //last name
                if (string.IsNullOrEmpty(secondDateTextBox.Text))
                {
                    SecondDateNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(secondDateTextBox.Text))
                {
                    SecondDateIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    ip.PolicyExpiryDate = DateTime.Parse(secondDateTextBox.Text);
                    secondDateCondition = true;
                };

                //car id
                bool success2 = Int32.TryParse(carIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(IpIdTextBox.Text))
                {
                    CarIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!success || !RegexID.IsMatch(carIdTextBox.Text))
                {
                    CarIdIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    ip.CarId       = number;
                    CarIdCondition = true;
                };


                {
                    if (IpIdCondition && CarIdCondition && firstDateCondition && secondDateCondition)
                    {
                        try
                        {
                            backButton.IsEnabled = false;
                            saveButton.IsEnabled = false;
                            saveData.Content     = "Trwa zapisywanie danych do bazy";
                            saveData.Visibility  = Visibility.Visible;
                            context.Polisa.Add(ip);
                            context.SaveChanges();
                            saveData.Content     = "Dane zostały zapisane";
                            backButton.IsEnabled = true;
                            saveButton.IsEnabled = true;
                            foreach (Control ctl in Container.Children)
                            {
                                if (ctl.GetType() == typeof(Label))
                                {
                                    ((Label)ctl).Visibility = Visibility.Hidden;
                                }
                                if (ctl.GetType() == typeof(TextBox))
                                {
                                    ((TextBox)ctl).Text = String.Empty;
                                }
                            }
                            Thread.Sleep(TimeSpan.FromSeconds(2));
                            saveData.Visibility = Visibility.Hidden;
                        }
                        catch (System.Data.Entity.Infrastructure.DbUpdateException)
                        {
                            ErrorWindow ew = new ErrorWindow();
                            ew.Owner = this;
                            ew.ShowDialog();
                        }
                    }
                }
            }
        }
예제 #13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  tr                  = new TechnicalReview();
                var  RegexID             = new Regex(@"^[0-9]{1,6}$");
                var  RegexDate           = new Regex(@"^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9]{3}$");
                bool TrIdCondition       = false;
                bool CarIdCondition      = false;
                bool firstDateCondition  = false;
                bool secondDateCondition = false;
                bool checkBoxCondition   = false;



                //IP id
                int  number;
                bool success = Int32.TryParse(trIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(trIdTextBox.Text))
                {
                    TrIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!success || !RegexID.IsMatch(trIdTextBox.Text))
                {
                    TrIdIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    tr.TechnicalReviewID = number;
                    TrIdCondition        = true;
                };

                //first date
                if (string.IsNullOrEmpty(firstDateTextBox.Text))
                {
                    TrDateNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(firstDateTextBox.Text))
                {
                    TrDateIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    tr.TechnicalReviewDate = DateTime.Parse(firstDateTextBox.Text);
                    firstDateCondition     = true;
                };

                //2nd date
                if (string.IsNullOrEmpty(secondDateTextBox.Text))
                {
                    TrExpiryNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexDate.IsMatch(secondDateTextBox.Text))
                {
                    TrExpiryIncorect.Visibility = Visibility.Visible;
                }
                else
                {
                    tr.TechnicalReviewExpiryDate = DateTime.Parse(secondDateTextBox.Text);
                    secondDateCondition          = true;
                };

                //car id
                bool success2 = Int32.TryParse(carIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(carIdTextBox.Text))
                {
                    CarIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!success || !RegexID.IsMatch(carIdTextBox.Text))
                {
                    CarIdIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    tr.CarId       = number;
                    CarIdCondition = true;
                };
                if (positiveCheckBox.IsChecked == false && negativeCheckBox.IsChecked == false)
                {
                    noCheck.Visibility = Visibility.Visible;
                }
                else if (positiveCheckBox.IsChecked == true)
                {
                    tr.TechnicalReviewStatus = true;
                    checkBoxCondition        = true;
                }
                else
                {
                    tr.TechnicalReviewStatus = false;
                    checkBoxCondition        = true;
                }


                if (TrIdCondition && CarIdCondition && firstDateCondition && secondDateCondition && checkBoxCondition)
                {
                    try
                    {
                        backButton.IsEnabled = false;
                        saveButton.IsEnabled = false;
                        saveData.Content     = "Trwa zapisywanie danych do bazy";
                        saveData.Visibility  = Visibility.Visible;
                        context.BadanieTechniczne.Add(tr);
                        context.SaveChanges();
                        saveData.Content     = "Dane zostały zapisane do bazy";
                        backButton.IsEnabled = true;
                        saveButton.IsEnabled = true;
                        foreach (Control ctl in Container.Children)
                        {
                            if (ctl.GetType() == typeof(Label))
                            {
                                ((Label)ctl).Visibility = Visibility.Hidden;
                            }
                            if (ctl.GetType() == typeof(TextBox))
                            {
                                ((TextBox)ctl).Text = String.Empty;
                            }
                            if (ctl.GetType() == typeof(TextBox))
                            {
                                ((TextBox)ctl).Text = String.Empty;
                            }
                        }
                        Thread.Sleep(TimeSpan.FromSeconds(2));
                        saveData.Visibility = Visibility.Hidden;
                    }
                    catch (System.Data.Entity.Infrastructure.DbUpdateException)
                    {
                        ErrorWindow ew = new ErrorWindow();
                        ew.Owner = this;
                        ew.ShowDialog();
                    }
                }
            }
        }
예제 #14
0
        private void Button_Click1(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  cars                  = new Cars();
                var  RegexCarID            = new Regex(@"^[0-9]{1,6}$");
                var  RegexCarName          = new Regex(@"^([A-Z][a-z]*( [A-Z][a-z]*)?)$");
                var  RegexLicensePlate     = new Regex(@"^[A-Z]{2,3}[A-Z0-9]{4,5}$");
                var  RegexModelName        = new Regex(@"^([A-Z][a-z]*( [A-Z][a-z]*( [A-Za-z0-9]*))?)$");
                bool CarIdCondition        = false;;
                bool DriverIdCondition     = false;
                bool CarModelCondition     = false;
                bool CarCompanyCondition   = false;
                bool LicensePlateCondition = false;



                //carid
                int  number;
                bool success = Int32.TryParse(carIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(carIdTextBox.Text))
                {
                    carIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexCarID.IsMatch(carIdTextBox.Text) || !success)
                {
                    carIdIncorrect.Visibility = Visibility.Hidden;
                }
                else
                {
                    cars.CarId     = number;
                    CarIdCondition = true;
                };

                //license plate
                if (string.IsNullOrEmpty(licensePlateTextBox.Text))
                {
                    licensePlateNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexLicensePlate.IsMatch(licensePlateTextBox.Text))
                {
                    licensePlateIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    cars.LicensePlateNumber = licensePlateTextBox.Text;
                    LicensePlateCondition   = true;
                }

                //model
                if (string.IsNullOrEmpty(modelTextBox.Text))
                {
                    ModelNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexModelName.IsMatch(modelTextBox.Text))
                {
                    modelIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    cars.CarModel     = modelTextBox.Text;
                    CarModelCondition = true;
                }

                //company
                if (string.IsNullOrEmpty(companyTextBox.Text))
                {
                    companyEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexCarName.IsMatch(companyTextBox.Text))
                {
                    companyIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    cars.CarCompany     = companyTextBox.Text;
                    CarCompanyCondition = true;
                }

                //driver id
                bool success2 = Int32.TryParse(driverIdTextBox.Text, out number);
                if (!success || !RegexCarID.IsMatch(driverIdTextBox.Text))
                {
                    driverIdIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(carIdTextBox.Text))
                {
                    driverIdNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    cars.DriverId     = number;
                    DriverIdCondition = true;
                }

                if (DriverIdCondition && LicensePlateCondition && CarIdCondition && CarModelCondition && CarCompanyCondition)
                {
                    try
                    {
                        backButton.IsEnabled = false;
                        saveButton.IsEnabled = false;
                        saveData.Content     = "Trwa zapisywanie danych do bazy";
                        saveData.Visibility  = Visibility.Visible;
                        context.Pojazdy.Add(cars);
                        context.SaveChanges();
                        backButton.IsEnabled = true;
                        saveButton.IsEnabled = true;
                        foreach (Control ctl in Container.Children)
                        {
                            if (ctl.GetType() == typeof(Label))
                            {
                                ((Label)ctl).Visibility = Visibility.Hidden;
                            }
                            if (ctl.GetType() == typeof(TextBox))
                            {
                                ((TextBox)ctl).Text = String.Empty;
                            }
                        }
                        saveData.Content = "Dane zostały zapisane";
                        Thread.Sleep(TimeSpan.FromSeconds(2));
                        saveData.Visibility = Visibility.Hidden;
                    }
                    catch (System.Data.Entity.Infrastructure.DbUpdateException)
                    {
                        ErrorWindow2 ew = new ErrorWindow2();
                        ew.Owner = this;
                        ew.ShowDialog();
                    }
                }
            }
        }
예제 #15
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CepikDB())
            {
                var  drivers           = new Drivers();
                var  RegexID           = new Regex(@"^[0-9]{1,6}$");
                var  RegexName         = new Regex(@"^[A-Z][a-z]*$");
                var  RegexAddressCity  = new Regex(@"^([A-Z][a-z]*(-[A-Z][a-z]*)?)$");
                var  RegexAddress      = new Regex(@"^([A-Z][a-z]*(\s[0-9]{1,5})?)$");
                var  RegexLastName     = new Regex(@"^([A-Z][a-z]*(-[A-Z][a-z]*)?)$");
                var  RegexPESEL        = new Regex(@"^[0-9]{11}$");
                var  RegexDate         = new Regex(@"^[0-3][0-9]\/[0-1][0-9]\/[1-2][0-9][0-9][0-9]$");
                bool DriverIdCondition = false;
                bool AddressCondition  = false;
                bool PeselCondition    = false;
                bool NameCondition     = false;
                bool LastNameCondition = false;
                bool RegionCondition   = false;
                bool CityCondition     = false;
                bool DateCondition     = true;



                //driver id
                int  number;
                bool success = Int32.TryParse(driverIdTextBox.Text, out number);
                if (string.IsNullOrEmpty(driverIdTextBox.Text))
                {
                    driverIdNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!success || !RegexID.IsMatch(driverIdTextBox.Text))
                {
                    driverIdIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.DriverId  = number;
                    DriverIdCondition = true;
                };

                //name
                if (string.IsNullOrEmpty(nameTextBox.Text))
                {
                    nameNotEmpty.Visibility = Visibility.Visible;
                }
                else if (!RegexName.IsMatch(nameTextBox.Text))
                {
                    nameIncorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.FirstName = nameTextBox.Text;
                    NameCondition     = true;
                };

                //last name
                if (!RegexName.IsMatch(lastNameTextBox.Text))
                {
                    lastNameIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(lastNameTextBox.Text))
                {
                    lastNameNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.LastName  = lastNameTextBox.Text;
                    LastNameCondition = true;
                };

                //address
                if (!RegexAddress.IsMatch(addressTextBox.Text))
                {
                    addressIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(addressTextBox.Text))
                {
                    addressNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.Address  = addressTextBox.Text;
                    AddressCondition = true;
                }

                //region
                if (string.IsNullOrEmpty(regionTextBox.Text))
                {
                    regionNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.Region  = regionTextBox.Text;
                    RegionCondition = true;
                }

                //city
                if (!RegexAddressCity.IsMatch(cityTextBox.Text))
                {
                    cityIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(cityTextBox.Text))
                {
                    cityNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.City  = cityTextBox.Text;
                    CityCondition = true;
                }

                //pesel

                if (!RegexPESEL.IsMatch(peselTextBox.Text))
                {
                    peselIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(peselTextBox.Text))
                {
                    peselNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.PESEL  = peselTextBox.Text;
                    PeselCondition = true;
                }

                //date of birth
                if (!RegexDate.IsMatch(dateOfBirthTextBox.Text))
                {
                    dateOfBirthIncorrect.Visibility = Visibility.Visible;
                }
                else if (string.IsNullOrEmpty(dateOfBirthTextBox.Text))
                {
                    dateOfBirthNotEmpty.Visibility = Visibility.Visible;
                }
                else
                {
                    drivers.BirthDate = DateTime.Parse(dateOfBirthTextBox.Text);
                    DateCondition     = true;
                }

                if (DriverIdCondition && NameCondition && LastNameCondition && AddressCondition && PeselCondition && CityCondition && RegionCondition && DateCondition)
                {
                    backButton.IsEnabled = false;
                    saveButton.IsEnabled = false;
                    dataSaved.Content    = "Trwa zapisywanie do bazy...";
                    dataSaved.Visibility = Visibility.Visible;
                    context.Kierowcy.Add(drivers);
                    context.SaveChanges();
                    dataSaved.Content    = "Dane zostały zapisane do bazy!";
                    backButton.IsEnabled = true;
                    saveButton.IsEnabled = true;
                    foreach (Control ctl in Container.Children)
                    {
                        if (ctl.GetType() == typeof(Label))
                        {
                            ((Label)ctl).Visibility = Visibility.Hidden;
                        }
                        if (ctl.GetType() == typeof(TextBox))
                        {
                            ((TextBox)ctl).Text = String.Empty;
                        }
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(2));
                    dataSaved.Visibility = Visibility.Hidden;
                }
            }
        }