private void btnEditUser_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxEditNameUser.Text == "" || passwordBoxEditPassword.Password == "" || passwordBoxEditPasswordAgain.Password == "" ||
                textBoxEditQuestion.Text == "" || textBoxEditResponse.Text == "")
            {
                ErrorFieldsDontFilled errorFieldsDontFilled = new ErrorFieldsDontFilled();
                errorFieldsDontFilled.ShowDialog();
                return;
            }

            if (passwordBoxEditPassword.Password != passwordBoxEditPasswordAgain.Password)
            {
                passwordBoxEditPassword.Clear();
                passwordBoxEditPasswordAgain.Clear();

                ErrorPasswordsDontEqual errorPasswordsDontEqual = new ErrorPasswordsDontEqual();
                errorPasswordsDontEqual.ShowDialog();
                return;
            }

            // Open a connection to the database and perform user editing

            try
            {
                using (ApplicationContext db = new ApplicationContext())
                {
                    User user = db.Users.FirstOrDefault(u => u.Id == _idForEdit);

                    if (user != null)
                    {
                        user.Username = textBoxEditNameUser.Text;
                        user.Password = passwordBoxEditPassword.Password;
                        user.Question = textBoxEditQuestion.Text;
                        user.Answer   = textBoxEditResponse.Text;

                        db.SaveChanges();
                    }
                }
            }

            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Close();
        }
        private void btnEnterAddUser_Click(object sender, RoutedEventArgs e)
        {
            // Checking the filling of fields with data

            if (textBoxEnterNameUser.Text == "" || passwordBoxEnterPassword.Password == "" || passwordBoxEnterPasswordAgain.Password == "" ||
                textBoxEnterQuestion.Text == "" || textBoxEnterResponse.Text == "")
            {
                ErrorFieldsDontFilled errorFieldsDontFilled = new ErrorFieldsDontFilled();
                errorFieldsDontFilled.ShowDialog();
                return;
            }

            if (passwordBoxEnterPassword.Password != passwordBoxEnterPasswordAgain.Password)
            {
                ErrorPasswordsDontEqual errorPasswordsDontEqual = new ErrorPasswordsDontEqual();
                errorPasswordsDontEqual.ShowDialog();
                return;
            }


            // Adding a User to the database

            try
            {
                using (ApplicationContext db = new ApplicationContext())
                {
                    db.Users.Add(new User
                    {
                        Username = textBoxEnterNameUser.Text,
                        Password = passwordBoxEnterPassword.Password,
                        Balance  = 500.0,
                        Question = textBoxEnterQuestion.Text,
                        Answer   = textBoxEnterResponse.Text
                    });

                    db.SaveChanges();
                }
            }

            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.Close();
        }