Example #1
0
        private void btnDeleteSelectedUser_Click(object sender, EventArgs e)
        {
            int    id       = Convert.ToInt32(dgvUsers.Rows[dgvUsers.CurrentCell.RowIndex].Cells[0].Value);
            string username = dgvUsers.Rows[dgvUsers.CurrentCell.RowIndex].Cells[1].Value.ToString();

            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this user?", "Confirm Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes) //delete the user if they confirm yes
            {
                if (rdoAdmins.Checked)            //check for the type of user (admin,teacher,parent,student)
                {
                    MathWizDB.DeleteUser("admin", id, username);
                }
                else if (rdoTeachers.Checked)
                {
                    MathWizDB.DeleteUser("teacher", id, username);
                }
                else if (rdoParents.Checked)
                {
                    MathWizDB.DeleteUser("parent", id, username);
                }
                else if (rdoStudents.Checked)
                {
                    MathWizDB.DeleteUser("student", id, username);
                }
                lblDeleted.Text = username + " was deleted";
                lblDeleted.Show();
                btnRefresh_Click(null, null);
            }
            else if (dialogResult == DialogResult.No)
            {
                lblDeleted.Text = "Delete cancelled";
                lblDeleted.Show();
            }
        }
Example #2
0
        //Delete Student Button
        private void button2_Click(object sender, EventArgs e)
        {
            int    id       = Convert.ToInt32(dgvStudents.Rows[dgvStudents.CurrentCell.RowIndex].Cells[0].Value);
            string username = dgvStudents.Rows[dgvStudents.CurrentCell.RowIndex].Cells[1].Value.ToString();

            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this student?", "Confirm Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes) //delete the user if they confirm yes
            {
                MathWizDB.DeleteUser("student", id, username);
            }
        }