private void btnNew_Click(object sender, EventArgs e) { frmAdmin Admin = new frmAdmin(true, ""); Admin.ShowDialog(); getInformation(); }
private void btnEdit_Click(object sender, EventArgs e) { bool Stop = false; Index = new int[dataGridStudents.SelectedRows.Count]; string[] Information; for (int i = 0; i < dataGridStudents.SelectedRows.Count; i++) { Index[i] = dataGridStudents.SelectedRows[i].Index; } Information = new string[Index.Length]; for (int i = 0; i < Index.Length; i++) { Information[i] = dataGridStudents.Rows[Index[i]].Cells[1].Value.ToString(); if (Information[i].ToLower() == "admin") { MessageBox.Show("You cannot edit the admin account."); Stop = true; } UserName = Information[i]; } //It would be very messy if the admin can edit multiple accounts are the same time, so I restricted it. //If the admin highlighted all the users and pressed edit, so many dialoges would open and they would be very annoying to close. if (Index.Length > 1) { MessageBox.Show("You can only edit one account at a time."); Stop = true; } if (Stop == false) { frmAdmin Admin = new frmAdmin(false, UserName); Admin.ShowDialog(); } getInformation(); }