Пример #1
0
        private void CallDelForm_Click(object sender, EventArgs e)
        {
            string       name = ((Button)sender).Name;
            DialogResult res;

            Enabled = false;
            switch (name)
            {
            case "CallDTeacherForm":
            {
                res = MessageBox.Show(
                    "Are you sure?",
                    "Delete teacher",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    CoursesRequests.DelTeacher((int)(TeachersGridView.SelectedRows[0].Cells[0].Value));
                }
                break;
            }

            case "CallDSchoolForm":
            {
                res = MessageBox.Show(
                    "Are you sure?",
                    "Delete school",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    CoursesRequests.DelSchool((int)(SchoolsGridView.SelectedRows[0].Cells[0].Value));
                }
                break;
            }

            case "CallDSubjectForm":
            {
                res = MessageBox.Show(
                    "Are you sure?",
                    "Delete subject",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    CoursesRequests.DelSubject((int)(SubjectsGridView.SelectedRows[0].Cells[0].Value));
                }
                break;
            }

            case "CallDStudentForm":
            {
                res = MessageBox.Show(
                    "Are you sure?",
                    "Delete student",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    CoursesRequests.DelStudent((int)(StudentsGridView.SelectedRows[0].Cells[0].Value));
                }
                break;
            }

            case "CallDCourseForm":
            {
                res = MessageBox.Show(
                    "Are you sure?",
                    "Delete course",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    CoursesRequests.DelCourse((int)(CoursesGridView.SelectedRows[0].Cells[0].Value));
                }
                break;
            }
            }
            Enabled = true;
        }