private void btnExport_Click(object sender, RoutedEventArgs e) { try { switch (cboData.SelectedValue) { case "Customer": CustomerManager.ExportExcel(customers); lblStatus.Content = "Successfully Exported Customers"; break; case "Employee": EmployeeManager.ExportExcel(employees); lblStatus.Content = "Successfully Exported Employees"; break; case "Appointment": AppointmentManager.ExportExcel(appointments); lblStatus.Content = "Successfully Exported Appointments"; break; case "Service Type": ServiceTypeManager.ExportExcel(serviceTypes); lblStatus.Content = "Successfully Exported Service Types"; break; case "Invoice": if (grdData.SelectedValue == null) { //export the whole grid to excel InvoiceManager.ExportExcel(invoices); lblStatus.Content = "Successfully Exported Invoices"; } else { //export a selected item to PDF string invoicePDF = "Invoice" + "-" + invoice.ServiceDate.ToString("MM-dd-yyyy") + "-" + invoice.CustomerFullName; InvoiceManager.InvoicePDF(invoicePDF, invoice); } break; case "User": UserManager.ExportExcel(users); lblStatus.Content = "Successfully Exported Users"; break; } } catch (Exception ex) { lblStatus.Foreground = new SolidColorBrush(Colors.Red); lblStatus.Content = ex.Message; } }