private void okButton_Click(object sender, EventArgs e) { string login = loginBox.Text; string password = passwordBox.Text; string confirm = confirmBox.Text; if (login.Equals("")) MessageBox.Show("Форма ввода логина не заполнена. "); else { if (password.Equals("")) MessageBox.Show("Форма ввода пароля не заполнена."); else if (confirm.Equals("")) MessageBox.Show("Форма ввода подтверждения пароля не заполнена."); else if (password.Length < 4) MessageBox.Show("Слишком короткий пароль. Длина пароля должна быть не менее 4-х символов"); else if (password.Equals(confirm)) { _currentUser = new User(login, password, false); int code = _currentUser.insertUser(); if (code != -1) { KeyboardTrainIndex main = this.Owner as KeyboardTrainIndex; if (main != null) { main.CurrentUser = _currentUser; } this.Close(); } else MessageBox.Show("Учетная запись с таким логином уже существует!"); } else MessageBox.Show("Пароли не совпадают"); } }
private void statisticsButton_Click(object sender, EventArgs e) { StatisticOfUser statOfUser = new StatisticOfUser(); statOfUser.Owner = this; statOfUser.Show(); _currentUser = main.CurrentUser; loginBox.Text = _currentUser.Login; выToolStripMenuItem.Text = "Вы: " + _currentUser.Login; }
private void TrainedForm_Load(object sender, EventArgs e) { main = this.Owner as KeyboardTrainIndex; _currentUser = main.CurrentUser; loginBox.Text = _currentUser.Login; if(_currentUser.NumberOfLastLevel==0) levelBox.Text = "-"; else levelBox.Text = Convert.ToString(_currentUser.NumberOfLastLevel); if(_currentUser.DateofLastTraining.ToString().Equals("01.01.0001 0:00:00")) dateLastTrainBox.Text = "-"; else dateLastTrainBox.Text = _currentUser.DateofLastTraining.ToString(); выToolStripMenuItem.Text = "Вы: " + _currentUser.Login; }
private void deserializeAdmin() { try { FileInfo fi = new FileInfo(_adminPath); if (fi.Length == 0) { MessageBox.Show("Файл с информацией об учетной записи Администратора пуст"); //_admin = new User("Admin", "Admin", true); //serializeAdmin(); } else { FileStream stream = null; _admin=null; try { stream = File.Open(_adminPath, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); _admin = (User)bf.Deserialize(stream); } catch (FileNotFoundException fnfe) { } finally { if (stream != null) stream.Close(); } } } catch (FileNotFoundException fnfe) { MessageBox.Show("Отсутствует файл с информацией об учетной записи Администратора"); } }
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; } } } } }
private void StatisticOfUser_Load(object sender, EventArgs e) { main = this.Owner as TrainedForm; if (main != null) { _currentUser = main.CurrentUser; выToolStripMenuItem.Text = "Вы: " + _currentUser.Login; } else { mainAdmin = this.Owner as ControlAccounts; _adminUser = mainAdmin.CurrentUser; _currentUser = mainAdmin.ChosenUser; выToolStripMenuItem.Text = "Вы: " + _adminUser.Login; } this.Text += " " + _currentUser.Login; fillDataGreed(); if (listOfTrainings.SelectedRows.Count != 0) { chosenLevel = Convert.ToInt32(listOfTrainings.Rows[0].Cells[2].Value.ToString()); paintPlot(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(); } } } } }
/// <summary> /// Добавляет запись в таблицу пользователя (при регистрации) /// </summary> /// <param name="user">Объект пользователя</param> /// <returns></returns> public int insertUser(User user) { SQLiteCommand insertCom = new SQLiteCommand("INSERT " + "INTO User(login,password) " + "VALUES(" + "'" + user.Login + "'" + "," + "'"+ user.Password +"'" + ");", sqliteConnection); int num = insertCom.ExecuteNonQuery(); return num; }
private void TrainerForm_Load(object sender, EventArgs e) { main = this.Owner as KeyboardTrainIndex; _currentUser = main.Admin; выToolStripMenuItem.Text = "Вы: " +_currentUser.Login; fillTextBoxes(); deserealiseSettings(); }
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; } } }
/// <summary> /// Действия при загрузке формы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TrainingForm_Load(object sender, EventArgs e) { main = this.Owner as TrainingParametersForm; if (main != null) { currentUser = main.CurrentUser; выToolStripMenuItem.Text = "Вы: " + currentUser.Login; currentTraining = main.CurrentTraining; letter1.UserFontSize = currentTraining.FontSize; letter1.Refresh(); уровеньToolStripMenuItem.Text = "Уровень: " + currentTraining.NumberOfLevel; упражнениеToolStripMenuItem.Text = "Упражнение: " + currentTraining.NumberOfCurrentExercise; Exercise newEx = new Exercise(currentTraining.NumberOfCurrentExercise, currentTraining.NumberOfLevel); int code = newEx.selectExercise(); label1.Visible = false; label1.Text = newEx.Text.Replace(' ', '_'); letter1.Visible=false; usingSymbol = newEx.UsingSymbols; liteUsedSymbols(usingSymbol,true); keyBoard1.Focus(); } }
private void listOfUsers_CellClick(object sender, DataGridViewCellEventArgs e) { int rowInd = e.RowIndex; if (rowInd >= 0) { _chosenUser = new User(listOfUsers.Rows[rowInd].Cells[0].Value.ToString(), "", false); openStat(); } }
private void ControlAccounts_Load(object sender, EventArgs e) { main = this.Owner as TrainerForm; _currentUser = main.CurrentUser; выToolStripMenuItem.Text = "Вы: " + _currentUser.Login; }
private void openStat() { StatisticOfUser statOfUser = new StatisticOfUser(); statOfUser.Owner = this; statOfUser.ShowDialog(); _currentUser = main.CurrentUser; выToolStripMenuItem.Text = "Вы: " + _currentUser.Login; }
private void открытьСтатистикуToolStripMenuItem_Click(object sender, EventArgs e) { if (listOfUsers.SelectedRows.Count != 0) { _chosenUser = new User(listOfUsers[0, listOfUsers.CurrentRow.Index].Value.ToString(), "", false); openStat(); } else MessageBox.Show("Не выбран пользователь для открытия статистики", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); }