private void btnDelete_Click(object sender, EventArgs e) { if (!cu.is_dataGridView_colored(dataGridViewMorimProject)) { MessageBox.Show("Nothing is picked on table!"); return; } string a = cu.GetID(dataGridViewMorimProject); Lessons les = new Lessons(); DataTable lessonsID = les.GetLessonsTeachersStudentId(); foreach (DataRow dr in lessonsID.Rows) { if (dr["teacher_id"].ToString() == a && cu.is_date_in_future(dr["due_date"].ToString())) { MessageBox.Show(dr["due_date"].ToString()); MessageBox.Show("Cannot delete teachers with scheduled lessons!"); return; } } MorimProject mkk = new MorimProject(); mkk.DeleteButton(a); cu.charge_data_grid_view(mkk.GetMorim(), dataGridViewMorimProject); dataGridViewMorimProject.ClearSelection(); }
private void btnDelete_Click(object sender, EventArgs e) { if (!cu.is_dataGridView_colored(dataGridViewStudents)) { MessageBox.Show("Nothing is picked on table!"); return; } string a = cu.GetID(dataGridViewStudents); Lessons les = new Lessons(); string field = "student_id"; DataTable lessonsID = les.GetLessonsTeachersStudentId(); foreach (DataRow dr in lessonsID.Rows) { if (dr[field].ToString() == a && cu.is_date_in_future(dr["due_date"].ToString())) { MessageBox.Show("Cannot delete student with scheduled lessons!"); return; } } Student mkk = new Student(); mkk.Delete(a); tan(); dataGridViewStudents.ClearSelection(); }