private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { try { var confirmResult = MessageBox.Show("This will also delete all prescriptions and refills attached to this physician. Are you sure you want to delete this physician?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (confirmResult == DialogResult.Yes) { DataGridViewRow row = dgvPatients.SelectedRows[0]; myPhysicianID = row.Cells[0].Value.ToString(); //Send it throug the datatier PharmacyDataTier bPharm = new PharmacyDataTier(); DataSet ds2 = new DataSet(); ds2 = bPharm.DeletePhysician(myPhysicianID); MessageBox.Show("Physician succesfully deleted.", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); try { //get the values string fname = txtPhysicianFName.Text.Trim(); string lname = txtPhysicianLName.Text.Trim(); string physicianID = txtPhysicianID.Text.Trim(); //Fill patient datagrid DataSet ds1 = new DataSet(); ds1 = bPharm.GetPhysician(fname, lname, physicianID); dgvPatients.DataSource = ds1.Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { try { var confirmResult = MessageBox.Show("This will also delete all prescriptions and refills attached to this physician. Are you sure you want to delete this physician?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (confirmResult == DialogResult.Yes) { //Send it throug the datatier PharmacyDataTier bPharm = new PharmacyDataTier(); DataSet ds2 = new DataSet(); ds2 = bPharm.DeletePhysician(myPhysicianID); MessageBox.Show("Physician succesfully deleted.", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }