diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-08-06 21:52:27 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-08-06 21:52:27 +0200 |
commit | ebe5ee94ef47f74117184175bfd98175d31e558a (patch) | |
tree | 517c56fc605ebffc7852401274b2d4f76328afdd | |
parent | 1100250ffd1f484ba7f69990170a678aee5d7ffd (diff) | |
download | serial-barcode-scanner-ebe5ee94ef47f74117184175bfd98175d31e558a.tar.bz2 |
use new restock variant
-rw-r--r-- | db.vala | 29 | ||||
-rw-r--r-- | main.vala | 30 |
2 files changed, 2 insertions, 57 deletions
@@ -11,9 +11,7 @@ public class Database { private Sqlite.Statement stock_stmt2; private Sqlite.Statement price_stmt; int32 user = 0; - uint64 product = 0; bool logged_in = false; - bool stock_mode = false; private static string product_query = "SELECT name FROM products WHERE id = ?"; private static string products_query = "SELECT id, name FROM products"; private static string purchase_query1 = "INSERT INTO purchases ('user', 'product', 'timestamp') VALUES (?, ?, ?)"; @@ -93,7 +91,6 @@ public class Database { public bool logout() { this.user = 0; - this.stock_mode = false; this.logged_in = false; return true; } @@ -216,22 +213,6 @@ public class Database { return false; } - public bool choose_stock_product(uint64 id) { - if(is_in_stock_mode()) { - product = id; - return true; - } - return false; - } - - public bool add_stock_product(uint64 amount) { - if(is_in_stock_mode() && product != 0) { - return restock(this.product, amount); - } - - return false; - } - public bool restock(uint64 product, uint64 amount) { if(is_logged_in()) { int rc = 0; @@ -261,17 +242,7 @@ public class Database { return false; } - public bool go_into_stock_mode() { - if(is_logged_in()) - stock_mode = true; - return stock_mode; - } - public bool is_logged_in() { return this.logged_in; } - - public bool is_in_stock_mode() { - return this.stock_mode; - } } @@ -77,34 +77,8 @@ public static bool interpret(string data) { stdout.printf("[%lld] You must be logged in to go into the stock mode\n", timestamp); return false; } else { - stdout.printf("[%lld] Going into stock mode!\n", timestamp); - return db.go_into_stock_mode(); - } - } else if(db.is_in_stock_mode()) { - if(!data.has_prefix("AMOUNT")) { - uint64 id = uint64.parse(data); - - /* check if data has valid format */ - if(data != "%llu".printf(id)) { - stdout.printf("[%lld] ungültiges Produkt: %s\n", timestamp, data); - return false; - } - - stdout.printf("[%lld] wähle Produkt: %s\n", timestamp, db.get_product_name(id)); - - return db.choose_stock_product(id); - } else { - uint64 amount = uint64.parse(data.substring(7)); - - /* check if data has valid format */ - if(data != "AMOUNT %llu".printf(amount)) { - stdout.printf("[%lld] ungültiges Produkt: %s\n", timestamp, data); - return false; - } - - stdout.printf("[%lld] zum Bestand hinzufügen: %llu\n", timestamp, amount); - - return db.add_stock_product(amount); + restock_dialog(); + return true; } } else { uint64 id = uint64.parse(data); |