Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
v2.0 commit
Browse files Browse the repository at this point in the history
Changes
Redesigned main form to have more 'flow' to it
Added ability to see what application has an Unassigned Application installed on it
Moved 'Rules' form to under the Application List instead of making it a pop up
Added SQL Authentication
Added SQL Connection Test
Added search by Manufacturer and Family Name on Application List
Added option to Export to CSV for large amounts of data that are not suitable for Excel XLSX
Added Settings Page
Allows XLSX Customization
Allows user to define default hidden columns
Allows user to disable or enable DoubleBuffer on Grid Views to prevent lag or performance impact
Known Issues
When exporting data hidden columns are included in the export.
  • Loading branch information
Laim McKenzie committed Jul 5, 2020
1 parent 8383584 commit f423642
Show file tree
Hide file tree
Showing 34 changed files with 15,916 additions and 0 deletions.
9 changes: 9 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
</configuration>
104 changes: 104 additions & 0 deletions Classes/Local.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace SRD
{
public class Local
{

public static readonly string AppConfig = "app.config";

/// <summary>
/// Populate a datagridview
/// </summary>
/// <param name="dgv">The datagridview</param>
/// <param name="dt">The datatable you want to populate the dgv with</param>
/// <param name="vs">A list of columns to hide</param>
public static void DgvOnLoadPopulator(DataGridView dgv, System.Data.DataTable dt, List<string> vs = null)
{
dgv.DataSource = dt;
foreach (DataGridViewColumn col in dgv.Columns)
{
if (vs.Contains(col.Name))
{
col.Visible = false;
}
}
}

/// <summary>
/// Populate the search column selector
/// </summary>
/// <param name="dgv">Your datagridview with columns</param>
/// <param name="combo">The combo box you want to populate </param>
public static void ColumnPopulator(DataGridView dgv, ComboBox combo)
{
if (combo.Items.Count > 0)
{
combo.Items.Clear();
}
foreach (DataGridViewColumn col in dgv.Columns)
{
combo.Items.Add(col.Name);
}
}

/// <summary>
/// Export a datagridview to xlsx using EPPlus
/// </summary>
/// <param name="dgv">Datagridview</param>
/// <param name="Directory">Save Directory</param>
/// <param name="ReportingTableDesign">Table Style</param>
/// <param name="ReportingWorksheetName">Name of the workbook</param>
public static void ExportXlsx(
DataGridView dgv,
string Directory,
OfficeOpenXml.Table.TableStyles ReportingTableDesign,
string ReportingWorkbookTitle,
string ReportingWorkbookCompany,
string ReportingWorksheetName)
{
FileInfo file = new FileInfo(Directory + "\\" + dgv.Name + DateTime.Now.ToString("ddMMyyyy-HHmmss") + ".xlsx");
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage ep = new ExcelPackage(file))
{
ExcelWorksheet ew = ep.Workbook.Worksheets.Add(ReportingWorksheetName);
ew.Cells["A1"].LoadFromDataTable((DataTable)dgv.DataSource, true, ReportingTableDesign);
ew.Cells.AutoFitColumns(40);
ep.Workbook.Properties.Application = Application.ProductName;
ep.Workbook.Properties.AppVersion = Application.ProductVersion;
ep.Workbook.Properties.Author = Environment.UserName;
ep.Workbook.Properties.Title = ReportingWorkbookTitle + " Export";
ep.Workbook.Properties.Company = ReportingWorkbookCompany;
ep.Workbook.Properties.Comments = "https://laim.scot";
ep.Save();
}
}

public static void ExportCsv(DataGridView dgv, string Directory)
{
int columnCount = dgv.ColumnCount;
string columnNames = "";
string[] output = new string[dgv.RowCount + 1];
for (int i = 0; i < columnCount; i++)
{
columnNames += dgv.Columns[i].Name.ToString().Replace(",","") + ",";
}
output[0] += columnNames;
for (int i = 1; (i - 1) < dgv.RowCount; i++)
{
for (int j = 0; j < columnCount; j++)
{
output[i] += dgv.Rows[i - 1].Cells[j].Value.ToString().Replace(",", "") + ",";
}
}
File.WriteAllLines(Directory + "\\" + dgv.Name + DateTime.Now.ToString("ddMMyyyy-HHmmss") + ".csv", output, Encoding.UTF8);
}
}
}
126 changes: 126 additions & 0 deletions Forms/FrmAbout.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Forms/FrmAbout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace SRD.Forms
{
public partial class FrmAbout : Form
{
public FrmAbout()
{
InitializeComponent();
}

private void FrmAbout_Load(object sender, EventArgs e)
{
lblAppName.Text = Application.ProductName;
lblAppVersion.Text = string.Format("Version: {0}", Application.ProductVersion);
lblAppCopyright.Text = "Copyright © Laim McKenzie 2020";
}

private void linkDeveloperLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://laim.scot");
}
}
}
Loading

0 comments on commit f423642

Please sign in to comment.