private void btnDelete_Click(object sender, EventArgs e) { if (textSubjectID.Text == "") { MessageBox.Show("Fields Are Empty... Cannot Delete...!"); } else { //get data from the textboxes s.SubjectID = Convert.ToInt32(textSubjectID.Text); bool success = s.Delete(s); if (success == true) { //Successfully Deleted MessageBox.Show("Subject Deleted Successfully"); //refresh data grid view //Load data on data grid view DataTable dt = s.Select(); dataGridViewSubjects.DataSource = dt; //Call clear method Clear(); } else { //Failed to deleted MessageBox.Show("Failed to Delete Subject... Try Again...!"); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (cmdOfferedYearMS.Text != "" && cmdOfferedSemMS.Text != "" && txtSubNameMS.Text != "" && txtSubCodeMS.Text != "" && cmdLecHoursMS.Text != "" && cmdTuteHoursMS.Text != "" && cmdLabHoursMS.Text != "" && cmdEvaluHoursMS.Text != "") { s.SubjectID = Convert.ToInt32(id); bool success = s.Delete(s, id); if (success == true) { MessageBox.Show("Subject Successfully Deleted!"); DataTable dt = s.Select(); SubGridView.DataSource = dt; Clear(); } else { MessageBox.Show("Failed to Delete Subject. Try Again!"); } } else { MessageBox.Show("Please Select Relavent Row!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Delete private void btnSubDelete_Click(object sender, EventArgs e) { if (IsValidDelete()) { //Get data from database c.ID = Convert.ToInt32(txtSubIDEdit.Text); bool success = c.Delete(c); if (success == true) { MessageBox.Show("Subject Successfully Deleted."); // LOAD DATA DataTable dt = c.Select(); metroGrid1.DataSource = dt; ClearFieldsAfterUpdate(); } else { MessageBox.Show("error"); } } }