/// <summary> /// Export to XPS /// </summary> public void ExportToXPS() { // If there are no rows in the grid then we cannot export if (this.alertsDataSet.Tables[0].Rows.Count == 0) { MessageBox.Show("There is no data to Export", "Export Error"); } else { // First browse for the folder / file that we will save SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.ValidateNames = false; saveFileDialog.FileName = "alertlog.xps"; saveFileDialog.Filter = "XML Paper Specification (*.xps)|*.xps"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { UltraGridExporter.Export(saveFileDialog.FileName , "AuditWizard Alert Log" , "Generated by AuditWizard from Layton Technology, Inc." , DataStrings.Disclaimer , alertsGridView , Infragistics.Documents.Reports.Report.FileFormat.XPS); DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'"); } } }
public static void ExportUltraGridToExcel(UltraGrid grid, string fileName) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.ValidateNames = true; saveFileDialog.FileName = fileName + ".xls"; saveFileDialog.Filter = "Microsoft Excel Spreadsheet (*.xls)|*.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { if (File.Exists(saveFileDialog.FileName)) { if (MessageBox.Show(saveFileDialog.FileName + " already exists." + Environment.NewLine + Environment.NewLine + "Do you want to replace it?", "Save As", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { return; } } int columnsCount = grid.DisplayLayout.Bands[0].Columns.Count; int rowsCount = grid.DisplayLayout.Rows.Count; if (columnsCount <= 256 && rowsCount <= 65535) { UltraGridExcelExporter exporter = new UltraGridExcelExporter(); Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets.Add("Sheet1"); // 8.3.4 - CMD - Hardwire Excel sheet name exporter.Export(grid, worksheet); try { workbook.Save(saveFileDialog.FileName); } catch (IOException ex) { Utility.DisplayApplicationErrorMessage(ex.Message); return; } DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'"); } else { MessageBox.Show( "The maximum amount of data that can be exported to Excel has been exceeded." + Environment.NewLine + Environment.NewLine + "Please reduce the number of rows and/or coulumns to be exported.", "Export limit reached" , MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Called to send a test email using the credential specified /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void emailButton_Click(object sender, EventArgs e) { try { SaveEmailSettings(); EmailController emailer = new EmailController(); emailer.SendStatusEmail(true, true, null); DesktopAlert.ShowDesktopAlert("An email has been sent to the specified address."); //MessageBox.Show("An email has been sent to the specified address.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Error sending email: " + ex.Message, "Error Sending Sample Email", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export to PDF /// </summary> public void ExportToPDF() { // If there are no rows in the grid then we cannot export if (this.alertsDataSet.Tables[0].Rows.Count == 0) { MessageBox.Show("There is no data to Export", "Export Error"); } else { // We need to temporarily set the grid view to 'Resize all columns' in order to get // the resultant PDF file formatted correctly. AutoFitStyle oldStyle = alertsGridView.DisplayLayout.AutoFitStyle; alertsGridView.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; // First browse for the folder / file that we will save SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.ValidateNames = false; saveFileDialog.FileName = "alertlog.pdf"; saveFileDialog.Filter = "Adobe Acrobat Document (*.pdf)|*.pdf"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { UltraGridExporter.Export(saveFileDialog.FileName , "AuditWizard Alert Log" , "Generated by AuditWizard from Layton Technology, Inc." , DataStrings.Disclaimer , alertsGridView , Infragistics.Documents.Reports.Report.FileFormat.PDF); DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'"); } // Populate the old autofit style this.alertsGridView.DisplayLayout.AutoFitStyle = oldStyle; } }
private void bnSaveEmailSettings_Click(object sender, EventArgs e) { SaveEmailSettings(); DesktopAlert.ShowDesktopAlert("Email settings saved okay."); }