summaryrefslogtreecommitdiffstats
path: root/db.vala
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-05-16 21:32:42 +0200
committerSebastian Reichel <sre@ring0.de>2012-05-16 21:32:42 +0200
commit0a2c6b377209b8bf29fa53fa1a2c6ebf13a7c570 (patch)
tree496f2a0f36b863a003af13af14615a943bdcf04c /db.vala
parent496fc7e418d8798565efd65a26280c05368c08dd (diff)
downloadserial-barcode-scanner-0a2c6b377209b8bf29fa53fa1a2c6ebf13a7c570.tar.bz2
code refactor + changed status led meaning
Diffstat (limited to 'db.vala')
-rw-r--r--db.vala26
1 files changed, 17 insertions, 9 deletions
diff --git a/db.vala b/db.vala
index 6467e6c..5679eb7 100644
--- a/db.vala
+++ b/db.vala
@@ -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) {