private void ChangeButton_Click(object sender, RoutedEventArgs e) { try { int id = Convert.ToInt32(ID_tb.Text); string login = Login_tb.Text; string pass = Password_tb.Text; int newid = Convert.ToInt32(ID_tb_Copy.Text); string newlogin = Login_tb_Copy.Text; string newpass = Password_tb_Copy.Text; string connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); string cmdTxt1 = $"UPDATE Administrators SET Login = '******' WHERE ID_admin = '{id}'"; SqlCommand command1 = new SqlCommand(cmdTxt1, connection); string cmdTxt2 = $"UPDATE Administrators SET Password = '******' WHERE ID_admin = '{id}'"; SqlCommand command2 = new SqlCommand(cmdTxt2, connection); command1.ExecuteNonQuery(); command2.ExecuteNonQuery(); MessageBox.Show("Изменения сохранены успешно!", "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information); ID_tb.Clear(); Login_tb.Clear(); Password_tb.Clear(); ID_tb_Copy.Clear(); Login_tb_Copy.Clear(); Password_tb_Copy.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Username_Tb_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { Password_tb.Focus(); } }
private void SearchBtn_Click(object sender, EventArgs e) { var admin = _adminService.FindAccount(NickTb.Text); if (admin.Username != null) { id = admin.Id; DialogResult dialog = MessageBox.Show("We found your account, Now update your account and login again", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); UsernameGb.Visible = true; Username_tb.Text = admin.Username; PasswordGb.Visible = true; CPassGb.Visible = true; ForgetPwd.Visible = false; cPwd_lbl.Visible = true; cPwd_tb.Visible = true; RecoveryGb.Visible = true; LoginBtn.Visible = false; UpdateBtn.Visible = true; Exit.Visible = false; Cancelbtn.Visible = true; SearchBtn.Visible = false; } else { DialogResult result = MessageBox.Show("Incorrect NickName!!", "Warning", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { string message = "Do You Really Want To Cancel?"; string title = "Confirm Your Action"; DialogResult res = MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (res == DialogResult.Yes) { Username_tb.ResetText(); Password_tb.ResetText(); UsernameGb.Visible = true; PasswordGb.Visible = true; LoginBtn.Visible = true; CPassGb.Visible = true; cPwd_lbl.Visible = false; cPwd_tb.Visible = false; ForgetPwd.Visible = true; RecoveryGb.Visible = false; SearchBtn.Visible = false; Cancelbtn.Visible = false; Exit.Visible = true; UpdateBtn.Visible = false; } } } }
private void AuthorizeBtn_Click(object sender, EventArgs e) { if (Username_tb.Text == GlobalAuthorizationControl.Auth.Username && Password_tb.Text == GlobalAuthorizationControl.Auth.Password) { this.Hide(); _adminPanel.ShowDialog(); this.Close(); } else { MessageBox.Show("Please Provide credentials with which you are logged in now!", "Incorrect Username or Password"); Username_tb.ResetText(); Password_tb.ResetText(); } }
private void Cancelbtn_Click(object sender, EventArgs e) { Username_tb.ResetText(); Password_tb.ResetText(); UsernameGb.Visible = true; PasswordGb.Visible = true; LoginBtn.Visible = true; CPassGb.Visible = true; cPwd_lbl.Visible = false; cPwd_tb.Visible = false; ForgetPwd.Visible = true; RecoveryGb.Visible = false; SearchBtn.Visible = false; Cancelbtn.Visible = false; Exit.Visible = true; UpdateBtn.Visible = false; }
private void UpdateBtn_Click(object sender, EventArgs e) { if (Password_tb.Text == cPwd_tb.Text) { _admin.Id = id; _admin.Username = Username_tb.Text; _admin.Password = Password_tb.Text; _admin.RecoveryName = NickTb.Text; _adminService.UpdateLogín(_admin); DialogResult dialog = MessageBox.Show("Account Updated Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Username_tb.ResetText(); Password_tb.ResetText(); UsernameGb.Visible = true; PasswordGb.Visible = true; LoginBtn.Visible = true; CPassGb.Visible = true; cPwd_lbl.Visible = false; cPwd_tb.Visible = false; ForgetPwd.Visible = true; RecoveryGb.Visible = false; SearchBtn.Visible = false; Cancelbtn.Visible = false; Exit.Visible = true; UpdateBtn.Visible = false; } else { DialogResult result = MessageBox.Show("Passwords do not match!!", "Warning", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { string message = "Do You Really Want To Cancel?"; string title = "Confirm Your Action"; DialogResult res = MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (res == DialogResult.Yes) { this.Close(); } } Password_tb.ResetText(); cPwd_tb.ResetText(); } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { try { int id = Convert.ToInt32(ID_tb.Text); string login = Login_tb.Text; string pass = Password_tb.Text; string connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); SqlCommand command = new SqlCommand($"DELETE Administrators WHERE ID_admin = '{id}'", connection); int number = command.ExecuteNonQuery(); MessageBox.Show("Изменения сохранены успешно!\nУдалено объектов: " + number, "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information); ID_tb.Clear(); Login_tb.Clear(); Password_tb.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void loginbtn_Click(object sender, EventArgs e) { _admin.Username = Username_tb.Text; _admin.Password = Password_tb.Text; bool flag = _adminService.GetLogín(_admin); if (flag == true) { GlobalAuthorizationControl.Auth = _adminService.Get(Username_tb.Text, Password_tb.Text); DialogResult result = MessageBox.Show("You are Logged in!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { this.Hide(); MainForm mainForm = new MainForm(); mainForm.ShowDialog(); this.Close(); } } else { DialogResult result = MessageBox.Show("Incorrect Username or Password!", "Warning", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { string message = "Do You Really Want To Cancel?"; string title = "Confirm Your Action"; DialogResult res = MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { this.Close(); } } Username_tb.ResetText(); Password_tb.ResetText(); } }