Add: Update end_time attribute in sqlite db when customer is marked 'ready'
This commit is contained in:
parent
c603d8fed6
commit
8f0d8e509c
@ -39,6 +39,11 @@ namespace QueueSys
|
|||||||
public string status { get; set; }
|
public string status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class endTimeModel
|
||||||
|
{
|
||||||
|
public string end_time { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class SqliteDataAccess
|
public class SqliteDataAccess
|
||||||
{
|
{
|
||||||
public List<EmployeeView> LoadEmployeeView()
|
public List<EmployeeView> LoadEmployeeView()
|
||||||
@ -90,7 +95,21 @@ namespace QueueSys
|
|||||||
{
|
{
|
||||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||||
{
|
{
|
||||||
string strQuery = "INSERT INTO archive(id, customer_name,num_bags,employee,status_id,start_time) SELECT id,customer_name,num_bags,employee,status_id,start_time FROM active_customers WHERE id=@id";
|
//Check to see if the customer already has an end_time
|
||||||
|
string strQuery = "SELECT end_time FROM active_customers WHERE id=@id";
|
||||||
|
|
||||||
|
List<endTimeModel> etm = new List<endTimeModel>();
|
||||||
|
var output = cnn.Query<endTimeModel>(strQuery, new { id = customer.id });
|
||||||
|
etm = output.ToList();
|
||||||
|
|
||||||
|
if(etm[0].end_time != null)
|
||||||
|
{
|
||||||
|
strQuery = "INSERT INTO archive(id, customer_name,num_bags,employee,status_id,start_time,end_time) SELECT id,customer_name,num_bags,employee,status_id,start_time,end_time FROM active_customers WHERE id=@id";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strQuery = "INSERT INTO archive(id, customer_name,num_bags,employee,status_id,start_time) SELECT id,customer_name,num_bags,employee,status_id,start_time FROM active_customers WHERE id=@id";
|
||||||
|
}
|
||||||
cnn.Execute(strQuery, customer);
|
cnn.Execute(strQuery, customer);
|
||||||
|
|
||||||
strQuery = "DELETE FROM active_customers WHERE id=@id";
|
strQuery = "DELETE FROM active_customers WHERE id=@id";
|
||||||
@ -118,6 +137,28 @@ namespace QueueSys
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateEndTime(int customer_id_in, string trans)
|
||||||
|
{
|
||||||
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||||
|
{
|
||||||
|
switch(trans)
|
||||||
|
{
|
||||||
|
case "add":
|
||||||
|
{
|
||||||
|
string strQuery = "UPDATE active_customers SET end_time = datetime() WHERE id=@customer_id";
|
||||||
|
cnn.Execute(strQuery, new { customer_id = customer_id_in });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "remove":
|
||||||
|
{
|
||||||
|
string strQuery = "UPDATE active_customers SET end_time = NULL WHERE id=@customer_id";
|
||||||
|
cnn.Execute(strQuery, new { customer_id = customer_id_in });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<ReportView> QueryReports()
|
public List<ReportView> QueryReports()
|
||||||
{
|
{
|
||||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||||
|
Loading…
Reference in New Issue
Block a user