private void btnAddRefill_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to add this refill?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (confirmResult == DialogResult.Yes) { try { //get the values string prescriptionID = txtPrescriptionID.Text.Trim(); DateTime time = dtpTime.Value; //Send it throug the datatier PharmacyDataTier bPharm = new PharmacyDataTier(); DataSet ds1 = new DataSet(); ds1 = bPharm.AddRefill(prescriptionID, time); //Update DataGrid UpdateRefillDatagrid(); } catch (Exception ex) { string myException = ex.ToString(); if (myException.Contains("No refills remaining")) { MessageBox.Show("Prescription is out of refills", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { } }