private void TrainingParametersForm_Load(object sender, EventArgs e)
 {
     main = this.Owner as TrainedForm;
     if (main != null)
     {
         currentUser = main.CurrentUser;
         if (currentUser.NumberOfLastLevel != 0)
         {
             numericUpDownLevel.Value = currentUser.NumberOfLastLevel;
             if (!currentUser.DateofLastTraining.ToString().Equals("01.01.0001 0:00:00"))
             {
                 numberOfCurrentExercise = currentUser.getLastNumberOfEx();
                 numberOfCurrentExercise++;
                 switch (numberOfCurrentExercise)
                 {
                     case 0: break;
                     case 1: exercise1RButton.Checked = true; break;
                     case 2: exercise2RButton.Checked = true; break;
                     case 3: exercise3RButton.Checked = true; break;
                     case 4: exercise4RButton.Checked = true; break;
                     case 5: exercise5RButton.Checked = true; break;
                     case 6: exercise6RButton.Checked = true; break;
                     case 7: exercise7RButton.Checked = true; break;
                     case 8: exercise8RButton.Checked = true; break;
                     case 9: exercise9RButton.Checked = true; break;
                     case 10: exercise10RButton.Checked = true; break;
                     case 11: exercise11RButton.Checked = true; break;
                     case 12: exercise12RButton.Checked = true; break;
                     case 13: exercise13RButton.Checked = true; break;
                     case 14: exercise14RButton.Checked = true; break;
                     case 15: exercise15RButton.Checked = true; break;
                 }
             }
         }
       
     }
 }
Example #2
0
        /// <summary>
        /// Процесс проверки данных
        /// </summary>
        public void authentication()
        {
            string login = loginBox.Text;
            string password = passwordBox.Text;
            if (login.Equals(""))
                MessageBox.Show("Форма ввода логина не заполнена. ");
            else
            {
                if (password.Equals(""))
                    MessageBox.Show("Форма ввода пароля не заполнена.");
                else if (password.Length < 4)
                    MessageBox.Show("Слишком короткий пароль. Длина пароля должна быть не менее 4-х символов");
                else
                {
                    // Добавить проверку на админа
                    if (login.Equals(_admin.Login))
                    {
                        if (password.Equals(_admin.Password))
                        {
                            TrainerForm adminForm = new TrainerForm();
                            adminForm.Owner = this;
                            adminForm.ShowDialog();
                            loginBox.Text = _admin.Login;
                            passwordBox.Text = _admin.Password;
                        }
                        else
                            MessageBox.Show("Не правильно указан пароль. Проверьте правильность написания");

                    }
                    else
                    {
                        _currentUser = new User(login, password, false);
                        int code = _currentUser.selectSignIn();
                        if (code == -1)
                            MessageBox.Show("Ошибка подключения к БД. Возможно отсутствует файл");
                        else if (code == 0)
                            MessageBox.Show("Не существует учетной записи с таким логином, либо Введен неверный пароль. Проверьте правильность написания");
                        else
                        {
                            TrainedForm userForm = new TrainedForm();
                            userForm.Owner = this;
                            userForm.ShowDialog();
                            loginBox.Text = _currentUser.Login;
                            passwordBox.Text = _currentUser.Password;
                            //ControlAccounts testForm = new ControlAccounts(/*currentUser*/);
                            //testForm.ShowDialog();
                        }
                    }
                }
            }
        }
Example #3
0
 private void EditAccountForm_Load(object sender, EventArgs e)
 {
    
         main = this.Owner as TrainedForm;
         if (main != null)
         {
             _currentUser = main.CurrentUser;
             loginBox.Text = _currentUser.Login;
         }
         else
         {
             adminMain = this.Owner as TrainerForm;
             if (adminMain != null)
             {
                 _currentUser = adminMain.CurrentUser;
                 loginBox.Text = _currentUser.Login;
             }
         }
     
 }