Change status field of employee view model to integer.
Add SQL query to LoadEmployeeView() Add: SaveCustomer() and ArchiveCustomer() functions.
This commit is contained in:
parent
963c3ff3a5
commit
d6d3e0ca0d
@ -23,19 +23,19 @@ namespace QueueSys
|
||||
public string customer_name { get; set; }
|
||||
public int num_bags { get; set; }
|
||||
public string employee { get; set; }
|
||||
public string status { get; set; }
|
||||
public int 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()))
|
||||
{
|
||||
string strQuery = "SELECT id,customer_name,num_bags,employee,status FROM active_customers;";
|
||||
|
||||
var output = cnn.Query<EmployeeView>(strQuery, new DynamicParameters());
|
||||
return output.ToList();
|
||||
}
|
||||
@ -54,7 +54,23 @@ namespace QueueSys
|
||||
|
||||
public static void SaveCustomer(EmployeeView customer)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "INSERT INTO active_customers (customer_name, num_bags, employee, status_id) VALUES (@customer_name, @num_bags, @employee, @status)";
|
||||
cnn.Execute(strQuery, customer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArchiveCustomer(EmployeeView customer)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "INSERT INTO archive(id, customer_name,num_bags,employee,status,start_time) SELECT id,customer_name,num_bags,employee,status,start_time WHERE id=@id";
|
||||
cnn.Execute(strQuery, customer);
|
||||
|
||||
// strQuery = "DELETE FROM active_customers WHERE id=@id";
|
||||
// cnn.Execute(strQuery, customer);
|
||||
}
|
||||
}
|
||||
|
||||
private static string LoadConnectionString(string id="Default")
|
||||
|
20
QueueSys/frmEmployeeView.Designer.cs
generated
20
QueueSys/frmEmployeeView.Designer.cs
generated
@ -40,7 +40,9 @@
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitAltF4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tbEmployeeName = new System.Windows.Forms.TextBox();
|
||||
this.dgvEmployeeView = new System.Windows.Forms.DataGridView();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvEmployeeView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblCustomerName
|
||||
@ -158,11 +160,24 @@
|
||||
this.tbEmployeeName.Size = new System.Drawing.Size(199, 26);
|
||||
this.tbEmployeeName.TabIndex = 6;
|
||||
//
|
||||
// dgvEmployeeView
|
||||
//
|
||||
this.dgvEmployeeView.AllowUserToAddRows = false;
|
||||
this.dgvEmployeeView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvEmployeeView.Location = new System.Drawing.Point(22, 181);
|
||||
this.dgvEmployeeView.Name = "dgvEmployeeView";
|
||||
this.dgvEmployeeView.RowHeadersWidth = 62;
|
||||
this.dgvEmployeeView.RowTemplate.Height = 28;
|
||||
this.dgvEmployeeView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.dgvEmployeeView.Size = new System.Drawing.Size(843, 352);
|
||||
this.dgvEmployeeView.TabIndex = 7;
|
||||
//
|
||||
// frmEmployeeView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(882, 692);
|
||||
this.ClientSize = new System.Drawing.Size(882, 554);
|
||||
this.Controls.Add(this.dgvEmployeeView);
|
||||
this.Controls.Add(this.tbEmployeeName);
|
||||
this.Controls.Add(this.btnAdd);
|
||||
this.Controls.Add(this.cbNumBags);
|
||||
@ -171,6 +186,7 @@
|
||||
this.Controls.Add(this.lblNumBags);
|
||||
this.Controls.Add(this.lblCustomerName);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "frmEmployeeView";
|
||||
@ -178,6 +194,7 @@
|
||||
this.Load += new System.EventHandler(this.frmEmployeeView_Load);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvEmployeeView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -197,6 +214,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem exitAltF4ToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem generateReportToolStripMenuItem;
|
||||
private System.Windows.Forms.TextBox tbEmployeeName;
|
||||
private System.Windows.Forms.DataGridView dgvEmployeeView;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user