private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            string typeCar  = "";
            string nickname = "";

            try
            {
                if (string.IsNullOrEmpty(textBoxNickname.Text) || string.IsNullOrEmpty(textBoxPassword.Password))
                {
                    throw new Exception("Some field is empty!!!");
                }

                string filePath = $@"..\..\Files\Taxists\{textBoxNickname.Text}.txt";
                if (!File.Exists(filePath))
                {
                    throw new Exception($"User with nickname: {textBoxNickname.Text}\nDoes not exist!!!");
                }
                else
                {
                    using (StreamReader reader = new StreamReader(filePath))
                    {
                        nickname = reader.ReadLine();
                        string password = reader.ReadLine();
                        typeCar = reader.ReadLine();
                        if (textBoxNickname.Text == nickname && textBoxPassword.Password == password)
                        {
                            WindowForException windowForException = new WindowForException("Successful login");
                            windowForException.ShowDialog();
                            this.Hide();
                        }
                        else
                        {
                            throw new Exception("Incorrect password\nEnter again!");
                        }
                    }
                }

                if (typeCar == "Econom")
                {
                    WorkingWithXML.DeserializeEconomCar(ref car, nickname);
                }
                else if (typeCar == "Luxury")
                {
                    WorkingWithXML.DeserializeLuxuryCar(ref car, nickname);
                }
                else if (typeCar == "Truck")
                {
                    WorkingWithXML.DeserializeTruck(ref car, nickname);
                }
                TaxistWorking taxistWorking = new TaxistWorking(car);
                taxistWorking.ShowDialog();
            }
            catch (Exception ex)
            {
                WindowForException windowForException = new WindowForException(ex.Message);
                windowForException.Show();
            }
        }
        private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            string typeCar  = "";
            string nickname = "";

            try
            {
                if (string.IsNullOrEmpty(textBoxNickname.Text) || string.IsNullOrEmpty(textBoxPassword.Password))
                {
                    throw new Exception("Some field is empty!!!");
                }

                string filePath = $@"..\..\Files\Taxists\{textBoxNickname.Text}.txt";
                if (!File.Exists(filePath))
                {
                    throw new Exception($"User with nickname: {textBoxNickname.Text}\nDoes not exist!!!");
                }
                else
                {
                    using (StreamReader reader = new StreamReader(filePath))
                    {
                        nickname = reader.ReadLine();
                        string password = reader.ReadLine();
                        typeCar = reader.ReadLine();
                        if (textBoxNickname.Text == nickname && textBoxPassword.Password == password)
                        {
                            MessageBox.Show("Successful login");
                            this.Hide();
                        }
                        else
                        {
                            throw new Exception("Incorrect password\nEnter again!");
                        }
                    }
                }

                if (typeCar == "Econom")
                {
                    XmlSerializer xmlSerializer = new XmlSerializer(typeof(EconomCar));
                    using (Stream stream = File.OpenRead($@"..\..\XML\TaxistsWithCars\{nickname}.xml"))
                    {
                        car = (EconomCar)xmlSerializer.Deserialize(stream);
                    }
                }
                else if (typeCar == "Luxury")
                {
                    XmlSerializer xmlSerializer = new XmlSerializer(typeof(LuxuryCar));
                    using (Stream stream = File.OpenRead($@"..\..\XML\TaxistsWithCars\{nickname}.xml"))
                    {
                        car = (LuxuryCar)xmlSerializer.Deserialize(stream);
                    }
                }
                else if (typeCar == "Truck")
                {
                    XmlSerializer xmlSerializer = new XmlSerializer(typeof(Truck));
                    using (Stream stream = File.OpenRead($@"..\..\XML\TaxistsWithCars\{nickname}.xml"))
                    {
                        car = (Truck)xmlSerializer.Deserialize(stream);
                    }
                }
                TaxistWorking taxistWorking = new TaxistWorking(car);
                taxistWorking.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ButtonRegistration_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(textBoxName.Text) ||
                    string.IsNullOrEmpty(textBoxSurname.Text) ||
                    string.IsNullOrEmpty(textBoxNickname.Text) ||
                    string.IsNullOrEmpty(textBoxPassword.Password) ||
                    string.IsNullOrEmpty(textBoxConfirmPass.Password) ||
                    string.IsNullOrEmpty(textBoxCarName.Text) ||
                    string.IsNullOrEmpty(textBoxCarModel.Text) ||
                    string.IsNullOrEmpty(textBoxCarNumber.Text))
                {
                    throw new Exception("Some field is empty!!!");
                }

                if (textBoxPassword.Password != textBoxConfirmPass.Password)
                {
                    throw new Exception("Password mismatch");
                }

                string filePath = $@"..\..\Files\Taxists\{textBoxNickname.Text}.txt";
                if (File.Exists(filePath))
                {
                    throw new Exception("Taxist with this nickname is already exist!!!");
                }
                else
                {
                    using (StreamWriter writer = new StreamWriter(filePath))
                    {
                        writer.WriteLine(textBoxNickname.Text);
                        writer.WriteLine(textBoxPassword.Password);
                        writer.WriteLine(comboBoxCarsType.Text);
                    }
                }

                taxist.Name      = textBoxName.Text;
                taxist.Surname   = textBoxSurname.Text;
                taxist.birthDate = dateTimePicker1.DisplayDate;
                taxist.Nickname  = textBoxNickname.Text;
                taxist.Password  = textBoxPassword.Password;

                car.taxist    = taxist;
                car.CarName   = textBoxCarName.Text;
                car.CarModel  = textBoxCarModel.Text;
                car.CarNumber = textBoxCarNumber.Text;

                if (comboBoxCarsType.Text == "Econom")
                {
                    WorkingWithXML.SerializeEconomCar(ref car, taxist.Nickname);
                }
                else if (comboBoxCarsType.Text == "Luxury")
                {
                    WorkingWithXML.SerializeLuxuryCar(ref car, taxist.Nickname);
                }
                else if (comboBoxCarsType.Text == "Truck")
                {
                    WorkingWithXML.SerializeTruck(ref car, taxist.Nickname);
                }
                comboBoxCarsType.IsEnabled = false;


                TaxistWorking taxistWorking = new TaxistWorking(car);
                this.Close();
                taxistWorking.ShowDialog();
            }
            catch (Exception ex)
            {
                WindowForException windowForException = new WindowForException(ex.Message);
                windowForException.Show();
            }
        }
        private void ButtonRegistration_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(textBoxName.Text) ||
                    string.IsNullOrEmpty(textBoxSurname.Text) ||
                    string.IsNullOrEmpty(textBoxNickname.Text) ||
                    string.IsNullOrEmpty(textBoxPassword.Password) ||
                    string.IsNullOrEmpty(textBoxConfirmPass.Password) ||
                    string.IsNullOrEmpty(textBoxCarName.Text) ||
                    string.IsNullOrEmpty(textBoxCarModel.Text) ||
                    string.IsNullOrEmpty(textBoxCarNumber.Text))
                {
                    throw new Exception("Some field is empty!!!");
                }

                if (textBoxPassword.Password != textBoxConfirmPass.Password)
                {
                    throw new Exception("Password mismatch");
                }

                string filePath = $@"..\..\Files\Taxists\{textBoxNickname.Text}.txt";
                if (File.Exists(filePath))
                {
                    throw new Exception("Taxist with this nickname is already exist!!!");
                }
                else
                {
                    using (StreamWriter writer = new StreamWriter(filePath))
                    {
                        writer.WriteLine(textBoxNickname.Text);
                        writer.WriteLine(textBoxPassword.Password);
                        writer.WriteLine(comboBoxCarsType.Text);
                    }
                }

                taxist.Name      = textBoxName.Text;
                taxist.Surname   = textBoxSurname.Text;
                taxist.birthDate = dateTimePicker1.DisplayDate;
                taxist.Nickname  = textBoxNickname.Text;
                taxist.Password  = textBoxPassword.Password;

                car.taxist    = taxist;
                car.CarName   = textBoxCarName.Text;
                car.CarModel  = textBoxCarModel.Text;
                car.CarNumber = textBoxCarNumber.Text;

                if (comboBoxCarsType.Text == "Econom")
                {
                    XmlSerializer xmlSerializerCar = new XmlSerializer(typeof(EconomCar));
                    using (Stream stream = File.Create($@"..\..\XML\TaxistsWithCars\{taxist.Nickname}.xml"))
                    {
                        xmlSerializerCar.Serialize(stream, ((EconomCar)car));
                    }
                }
                else if (comboBoxCarsType.Text == "Luxury")
                {
                    XmlSerializer xmlSerializerCar = new XmlSerializer(typeof(LuxuryCar));
                    using (Stream stream = File.Create($@"..\..\XML\TaxistsWithCars\{taxist.Nickname}.xml"))
                    {
                        xmlSerializerCar.Serialize(stream, ((LuxuryCar)car));
                    }
                }
                else if (comboBoxCarsType.Text == "Truck")
                {
                    XmlSerializer xmlSerializerCar = new XmlSerializer(typeof(Truck));
                    using (Stream stream = File.Create($@"..\..\XML\TaxistsWithCars\{taxist.Nickname}.xml"))
                    {
                        xmlSerializerCar.Serialize(stream, ((Truck)car));
                    }
                }
                comboBoxCarsType.IsEnabled = false;


                TaxistWorking taxistWorking = new TaxistWorking(car);
                this.Close();
                taxistWorking.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}");
            }
        }