private void printPreview_PrintClick(object sender, EventArgs e) { try { printDialog1.Document = printDocument1; if (printDialog1.ShowDialog() == DialogResult.OK) { printDocument1.Print(); printPreviewDialog1.Close(); foreach (var pres in prescriptionService.GetPatientPrescriptionByPatientId(appointment.patient_id)) { prescriptionService.DeletePatientPrescription(pres); } drugCost = 0; } } catch (Exception ex) { return; } }