More SQL stuff

This commit is contained in:
kougyoku 2019-10-10 10:13:30 -07:00
parent 82596e4be0
commit 2a8702e1a9
4 changed files with 78 additions and 10 deletions

View File

@ -39,6 +39,7 @@
<HintPath>..\packages\Dapper.2.0.30\lib\net461\Dapper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll</HintPath>
@ -74,6 +75,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqliteDataAccess.cs" />
<EmbeddedResource Include="frmCustomerView.resx">
<DependentUpon>frmCustomerView.cs</DependentUpon>
</EmbeddedResource>

Binary file not shown.

View File

@ -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<employeeView> 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<employeeView>(strQuery, new DynamicParameters());
return output.ToList();
}
}
public static List<customerView> loadCustomerView()
{
string strQuery = "SELECT customer_name,status FROM active_customers;";
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
var output = cnn.Query<employeeView>(strQuery, new DynamicParameters());
return output.ToList();
}
}
public static void saveCustomer(employeeView customer)
{
}
private static string LoadConnectionString(string id="Default")
{
return ConfigurationManager.ConnectionStrings[id].ConnectionString;
}
}
}

View File

@ -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);