From 2a8702e1a9b2a1f97949db9b7c32f9536f0936be Mon Sep 17 00:00:00 2001 From: kougyoku Date: Thu, 10 Oct 2019 10:13:30 -0700 Subject: [PATCH] More SQL stuff --- QueueSys/QueueSys.csproj | 2 + QueueSys/QueueSys.db | Bin 24576 -> 32768 bytes QueueSys/SqliteDataAccess.cs | 65 +++++++++++++++++++++++++++ QueueSys/frmEmployeeView.Designer.cs | 21 ++++----- 4 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 QueueSys/SqliteDataAccess.cs diff --git a/QueueSys/QueueSys.csproj b/QueueSys/QueueSys.csproj index da719c6..713910b 100644 --- a/QueueSys/QueueSys.csproj +++ b/QueueSys/QueueSys.csproj @@ -39,6 +39,7 @@ ..\packages\Dapper.2.0.30\lib\net461\Dapper.dll + ..\packages\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll @@ -74,6 +75,7 @@ + frmCustomerView.cs diff --git a/QueueSys/QueueSys.db b/QueueSys/QueueSys.db index e1c7944cca1245ad13088d2c5cde249f21ef7303..8c26d3d56f2ecfda7fcca33c747c29b5827a9cc9 100644 GIT binary patch delta 997 zcmZuv&ubGw6rR~>ve|8RCuz}*ZfS=|n*AV_uasqMU_%6TO)5S`O z1bn>cJQe%i@9Hx=|s`9XSX zD0F0tLtOw$xwnH__@;IWAFjM$M}E- z-r)2YZ1V?occ27!cGiLjMPQ2%e7){Bz`ub9pU~RxxYvUqM9AG41|g1fF$kYf4AtMj^!yLgl!++I JPrRS=`~~qH3{L<6 delta 272 zcmZo@U}`wPI6+#FnSp_U4TxcYWulI;I5UHuffXm!kuKm!i11S<)JAB E0NAfVKL7v# diff --git a/QueueSys/SqliteDataAccess.cs b/QueueSys/SqliteDataAccess.cs new file mode 100644 index 0000000..352eb30 --- /dev/null +++ b/QueueSys/SqliteDataAccess.cs @@ -0,0 +1,65 @@ +using Dapper; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SQLite; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace QueueSys +{ + public class customerView + { + public string customerName { get; } + public string status { get; } + public string timeElapsed { get; } + } + + public class employeeView + { + public int id { get; } + public string customer_name { get; set; } + public int num_bags { get; set; } + public string employee { get; set; } + public string status { get; set; } + } + + public class SqliteDataAccess + { + public static List loadEmployeeView() + { + string strQuery = "SELECT id,customer_name,num_bags,employee,status FROM active_customers;"; + + //A using statement protects us as a failsafe: it guarantees the connection to the + //database will be closed, even in event of an application or computer crash. + using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) + { + var output = cnn.Query(strQuery, new DynamicParameters()); + return output.ToList(); + } + } + + public static List loadCustomerView() + { + string strQuery = "SELECT customer_name,status FROM active_customers;"; + + using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) + { + var output = cnn.Query(strQuery, new DynamicParameters()); + return output.ToList(); + } + } + + public static void saveCustomer(employeeView customer) + { + + } + + private static string LoadConnectionString(string id="Default") + { + return ConfigurationManager.ConnectionStrings[id].ConnectionString; + } + } +} diff --git a/QueueSys/frmEmployeeView.Designer.cs b/QueueSys/frmEmployeeView.Designer.cs index e0fc02e..22a33a8 100644 --- a/QueueSys/frmEmployeeView.Designer.cs +++ b/QueueSys/frmEmployeeView.Designer.cs @@ -36,9 +36,9 @@ this.btnAdd = new System.Windows.Forms.Button(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.generateReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitAltF4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.generateReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tbEmployeeName = new System.Windows.Forms.TextBox(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -107,6 +107,7 @@ this.btnAdd.TabIndex = 4; this.btnAdd.Text = "Add"; this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); // // menuStrip1 // @@ -130,27 +131,27 @@ this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 29); this.fileToolStripMenuItem.Text = "&File"; // + // generateReportToolStripMenuItem + // + this.generateReportToolStripMenuItem.Name = "generateReportToolStripMenuItem"; + this.generateReportToolStripMenuItem.Size = new System.Drawing.Size(242, 34); + this.generateReportToolStripMenuItem.Text = "&Generate Report"; + this.generateReportToolStripMenuItem.Click += new System.EventHandler(this.generateReportToolStripMenuItem_Click); + // // optionsToolStripMenuItem // this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(270, 34); + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(242, 34); this.optionsToolStripMenuItem.Text = "Options"; this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); // // exitAltF4ToolStripMenuItem // this.exitAltF4ToolStripMenuItem.Name = "exitAltF4ToolStripMenuItem"; - this.exitAltF4ToolStripMenuItem.Size = new System.Drawing.Size(270, 34); + this.exitAltF4ToolStripMenuItem.Size = new System.Drawing.Size(242, 34); this.exitAltF4ToolStripMenuItem.Text = "E&xit (Alt-F4)"; this.exitAltF4ToolStripMenuItem.Click += new System.EventHandler(this.exitAltF4ToolStripMenuItem_Click); // - // generateReportToolStripMenuItem - // - this.generateReportToolStripMenuItem.Name = "generateReportToolStripMenuItem"; - this.generateReportToolStripMenuItem.Size = new System.Drawing.Size(270, 34); - this.generateReportToolStripMenuItem.Text = "&Generate Report"; - this.generateReportToolStripMenuItem.Click += new System.EventHandler(this.generateReportToolStripMenuItem_Click); - // // tbEmployeeName // this.tbEmployeeName.Location = new System.Drawing.Point(514, 117);