diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-05-16 21:32:42 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-05-16 21:32:42 +0200 |
commit | 0a2c6b377209b8bf29fa53fa1a2c6ebf13a7c570 (patch) | |
tree | 496f2a0f36b863a003af13af14615a943bdcf04c /db.vala | |
parent | 496fc7e418d8798565efd65a26280c05368c08dd (diff) | |
download | serial-barcode-scanner-0a2c6b377209b8bf29fa53fa1a2c6ebf13a7c570.tar.bz2 |
code refactor + changed status led meaning
Diffstat (limited to 'db.vala')
-rw-r--r-- | db.vala | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -25,23 +25,31 @@ public class Database { } } - public void login(uint64 id) { + public bool login(uint64 id) { this.user = id; + return true; } - public void logout() { + public bool logout() { this.user = 0; + return true; } - public void buy(uint64 article) { - this.insert_stmt.reset(); - this.insert_stmt.bind_text(1, "%llu".printf(user)); - this.insert_stmt.bind_text(2, "%llu".printf(article)); + public bool buy(uint64 article) { + if(is_logged_in()) { + this.insert_stmt.reset(); + this.insert_stmt.bind_text(1, "%llu".printf(user)); + this.insert_stmt.bind_text(2, "%llu".printf(article)); - int rc = this.insert_stmt.step(); + int rc = this.insert_stmt.step(); - if(rc != Sqlite.DONE) - error("[interner Fehler: %d]".printf(rc)); + if(rc != Sqlite.DONE) + error("[interner Fehler: %d]".printf(rc)); + else + return true; + } else { + return false; + } } public string get_product_name(uint64 article) { |