diff --git a/src/educoder/database/database.py b/src/educoder/database/database.py index 3c47b1f..5d4ed1b 100644 --- a/src/educoder/database/database.py +++ b/src/educoder/database/database.py @@ -1,5 +1,36 @@ class Database(object): def connection(self): pass - def createAccount(self,id,userName): + + def init(self): + pass + + def addBook(self, unique_id, isbn, state): + pass + + def removeBook(self, unique_id): + pass + + def addUser(self, user_id, userpass_word, permission, nick_name): + pass + + def removeUser(self, unique_id): + pass + + def addBookInformation(self, isbn, author, description, price, made_time, image, category): + pass + + def removeBookInformation(self, isbn): + pass + + def brownBook(self, unique_id, brownuser): + pass + + def stillBook(self, unique_id): + pass + + def addCategory(self, category): + pass + + def removeCategory(self, category): pass \ No newline at end of file diff --git a/src/educoder/database/database_sqlite.py b/src/educoder/database/database_sqlite.py index 90d032c..224e35c 100644 --- a/src/educoder/database/database_sqlite.py +++ b/src/educoder/database/database_sqlite.py @@ -1,6 +1,6 @@ import database import sqlite3 - +import datetime class DatabaseSQLite(database.Database): conn = sqlite3.connect @@ -8,6 +8,107 @@ class DatabaseSQLite(database.Database): def connection(self): self.conn = sqlite3.connect("../../../data/lib_manager.db") - def createAccount(self,id,userName): - cursor = self.conn.cursor() - cursor.execute("") \ No newline at end of file + def init(self): + self.conn.cursor().execute('''CREATE TABLE user(account INTEGER, userid INTEGER, password INTEGER, + permission VARCHAR, nickname VARCHAR, PRIMARY KEY(account))''') + self.conn.cursor().execute('''CREATE TABLE book_type(type CHAR, PRIMARY KEY(type))''') + self.conn.cursor().execute( + '''CREATE TABLE book_main(unique_id INTEGER, isbn INTEGER, state INTEGER, PRIMARY KEY(unique_id))''') + self.conn.cursor().execute( + '''CREATE TABLE book_loc(unique_id INTEGER, loc INTEGER, PRIMARY KEY(unique_id) FOREIGN KEY(unique_id) + REFERENCES book_main)''') + self.conn.cursor().execute( + '''CREATE TABLE book_record(unique_id INTEGER, brown_time INTEGER, real_still_time INTEGER, + expect_still_time INTEGER, brown_user VARCHAR, PRIMARY KEY(unique_id) FOREIGN KEY(unique_id)REFERENCES + book_main)''') + self.conn.cursor().execute( + '''CREATE TABLE book_information(isbn INTEGER, author VARCHAR, description, price INTEGER, made_time + INTEGER, image VARCHAR, type CHAR ,PRIMARY KEY(isbn) FOREIGN KEY(type)REFERENCES book_type) FOREIGN KEY( + isbn)REFERENCES book_main)''') + + self.conn.commit() + + def addBook(self, unique_id, isbn, state): + self.conn.cursor().execute("INSERT INTO book_main(unique_id, isbn, state) VALUES('+unique_id+', '+isbn+', " + "'+state+')") + + self.conn.commit() + return True + + def removeBook(self, unique_id): + self.conn.cursor().execute("DELETE FORM book_main WHERE unique_id = '+unique_id+'") + + self.conn.commit() + return True + + def addUser(self, user_id, userpass_word, permission, nick_name): + self.conn.cursor().execute("INSERT INTO user(user_id, userpass_word, permission, nick_name) VALUES (" + "'+user_id+', +userpass_word+', '+permission+', '+nick_name+')") + + self.conn.commit() + return True + + def removeUser(self, unique_id): + self.conn.cursor().execute("DELETE FORM user WHERE unique_id = '+unique_id+'") + + self.conn.commit() + return True + + def addBookInformation(self, isbn, author, description, price, made_time, image, category): + self.conn.cursor().execute("INSERT INTO book_information(isbn, author, description, price, made_time, image, " + "category) VALUES ('+isbn+', '+author+', '+description+','+price+', '+made_time+', " + "'+image+','+category+')") + + self.conn.commit() + return True + + def removeBookInformation(self, isbn): + self.conn.cursor().execute("DELETE FORM book_information WHERE isbn = 'isbn'") + + self.conn.commit() + return True + + def brownBook(self, unique_id, brown_user): + flag = self.conn.cursor().execute("SELECT state FROM book_main") + if flag: + self.conn.cursor().execute("UPDATE book_main SET state = false") + self.conn.cursor().execute( + "INSERT INTO book_record(unique_id, brown_time, real_still_time, expect_still_time, brown_user) " + "VALUES('+unique_id+', '+datetime.datetime.now()+',+0+, +30+, '+brown_user+')") + self.conn.commit() + return True + else: + return False + + def stillBook(self, unique_id): + flag = self.conn.cursor().execute("SELECT state FROM book_main") + if not flag: + self.conn.cursor().execute("UPDATE book_main SET state = true") + self.conn.cursor().execute("UPDATE book_record SET real_still_time = '+datetime.datetime.now()+'") + self.conn.commit() + return True + else: + return False + + def addCategory(self, category): + self.conn.cursor().execute("INSERT INTO book_type (type) VALUES (type = '+category+')") + + + + + + + + + + + + + + + + + + + + diff --git a/src/educoder/gui/uis/pages/ui_main_pages.py b/src/educoder/gui/uis/pages/ui_main_pages.py index f7cbd0a..0882988 100644 --- a/src/educoder/gui/uis/pages/ui_main_pages.py +++ b/src/educoder/gui/uis/pages/ui_main_pages.py @@ -167,10 +167,10 @@ class Ui_MainPages(object): def retranslateUi(self, MainPages): MainPages.setWindowTitle(QCoreApplication.translate("MainPages", u"Form", None)) - self.label.setText(QCoreApplication.translate("MainPages", u"Welcome To PyOneDark GUI", None)) - self.title_label.setText(QCoreApplication.translate("MainPages", u"Custom Widgets Page", None)) - self.description_label.setText(QCoreApplication.translate("MainPages", u"Here will be all the custom widgets, they will be added over time on this page.\n" -"I will try to always record a new tutorial when adding a new Widget and updating the project on Patreon before launching on GitHub and GitHub after the public release.", None)) + self.label.setText(QCoreApplication.translate("MainPages", u"欢迎使用现代图书管理系统", None)) + self.title_label.setText(QCoreApplication.translate("MainPages", u"数据库监控面板", None)) + #self.description_label.setText(QCoreApplication.translate("MainPages", u"Here will be all the custom widgets, they will be added over time on this page.\n" +#"I will try to always record a new tutorial when adding a new Widget and updating the project on Patreon before launching on GitHub and GitHub after the public release.", None)) self.empty_page_label.setText(QCoreApplication.translate("MainPages", u"Empty Page", None)) # retranslateUi diff --git a/src/educoder/main.py b/src/educoder/main.py index 9012f11..f6a3bb2 100644 --- a/src/educoder/main.py +++ b/src/educoder/main.py @@ -78,6 +78,7 @@ class MainWindow(QMainWindow): # GET BT CLICKED btn = SetupMainWindow.setup_btns(self) + # Remove Selection If Clicked By "btn_close_left_column" if btn.objectName() != "btn_settings": self.ui.left_menu.deselect_all_tab()