heavily simplified imports and using directives
This commit is contained in:
23
Customer.cpp
23
Customer.cpp
@ -1,5 +1,4 @@
|
||||
#include "headers/Customer.h"
|
||||
#include <iostream>
|
||||
|
||||
// constructors
|
||||
Customer::Customer(string name_, Verhicle_type verhicle_):
|
||||
@ -20,6 +19,10 @@ Customer::Customer(int id_, string name_, string card_code_, Verhicle_type verhi
|
||||
|
||||
}
|
||||
|
||||
Customer::~Customer(){
|
||||
update_db();
|
||||
}
|
||||
|
||||
|
||||
// clock in/out methods ====================================================================================
|
||||
/*
|
||||
@ -37,13 +40,13 @@ void Customer::clock_out(int s_id) { park_instances[park_instances.size() - 1].c
|
||||
|
||||
// report gen
|
||||
void Customer::gen_monthly() {
|
||||
std::cout << "NAME: " << name << " card code: " << card_code << "\n";
|
||||
std::cout << "-------------------------------------------------\n";
|
||||
cout << "NAME: " << name << " card code: " << card_code << "\n";
|
||||
cout << "-------------------------------------------------\n";
|
||||
for (auto& i : park_instances) {
|
||||
// TODO: need some logic to only include from this month
|
||||
std::cout << i;
|
||||
// TODO: need some logic to only include from this month. scratch that, need to remove gen monthly
|
||||
cout << i;
|
||||
}
|
||||
std::cout << "-------------------------------------------------\n\n";
|
||||
cout << "-------------------------------------------------\n\n";
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +56,7 @@ void Customer::gen_monthly() {
|
||||
void Customer::save_db() {
|
||||
string statement{"insert into Customer values (, '', '', );"};
|
||||
// after ( = 28)
|
||||
statement.insert(38, std::to_string(int(verhicle)));
|
||||
statement.insert(38, to_string(int(verhicle)));
|
||||
statement.insert(36, card_code);
|
||||
statement.insert(32, name);
|
||||
statement.insert(29, to_string(id));
|
||||
@ -64,17 +67,15 @@ void Customer::save_db() {
|
||||
|
||||
void Customer::update_db() {
|
||||
string statement = "UPDATE Customer SET name = '', card_code = '' where id = '';";
|
||||
statement.insert(58, std::to_string(id));
|
||||
statement.insert(58, to_string(id));
|
||||
statement.insert(44, card_code);
|
||||
statement.insert(28, name);
|
||||
// std::cout << statement; TODO: set some logging here
|
||||
data::db.exec(statement);
|
||||
}
|
||||
|
||||
void Customer::delete_db() {
|
||||
string statement = "delete from Customer where id= ;";
|
||||
statement.insert(statement.length() - 2, std::to_string(id));
|
||||
// std::cout << statement;
|
||||
statement.insert(statement.length() - 2, to_string(id));
|
||||
SQLite::Transaction transaction(data::db);
|
||||
data::db.exec(statement);
|
||||
transaction.commit();
|
||||
|
Reference in New Issue
Block a user