def run(self):
            """Create and initialize the database and add company information."""
            db_man = DBManager()
            db_created, result = db_man.create_database(
                self._company.name, self._username, self._password)

            if not db_created:
                self.sig_failure.emit("Database Creation Failure!", result)
            else:
                # Save the company info.
                company_created = CompanyDao.create_company(self._company)
                if company_created:
                    self.sig_success.emit("Database Created!", result)
                else:
                    self.sig_failure.emit("Save Company Error!",
                                          "Failed to save company details.")
Esempio n. 2
0
 def create_company(company):
     """Create a company record."""
     db = DBManager()
     if db.Session is not None:
         try:
             session = db.Session()
             session.add(company)
             session.commit()
             return True
         except ProgrammingError as e:
             logging.error(
                 "Unable to create the company information: {0}".format(
                     str(e)))
             return False
     else:
         logging.error(
             "Invalid connection information. Make sure the database is created."
         )
         return False
Esempio n. 3
0
    def open_button_click(self):
        if self.validate():
            db_name = self.dbList.currentItem().text()
            user = self.usernameText.text()
            pwd = self.passwordText.text()

            if not DBManager.check_user_permissions(db_name, user, pwd):
                QMessageBox.critical(self, "Invalid Credentials",
                                     "Invalid username password combination.",
                                     QMessageBox.Ok, QMessageBox.Ok)
            else:
                is_success, result = DBManager().connect_database(
                    db_name, user, pwd)
                if is_success:
                    QMessageBox.information(self, "Connection Success", result,
                                            QMessageBox.Ok, QMessageBox.Ok)
                    self.close()
                else:
                    QMessageBox.critical(self, "Connection Failed", result,
                                         QMessageBox.Ok, QMessageBox.Ok)
Esempio n. 4
0
 def init_database(self):
     """Create and initialize the database and add company information.
     This method should be run on a thread for maximum efficiency."""
     if self.validate() is True:
         # Create the database.
         db_man = DBManager()
         db_created = db_man.create_database(self.nameText.text(), self.userText.text(), self.passText.text())
         if not db_created:
             self.show_error_dialog("Database creation failed.")
         else:
             # Save the company info.
             company_created = CompanyDao.create_company(self, self.nameText.text(), self.addressText.toPlainText(),
                                                         self.taxNumText.text())
             if company_created:
                 self.show_info_dialog("Database created successfully.")
                 self.close()
             else:
                 self.show_error_dialog("Couldn't save customer information.")
     else:
         print("Invalid")
 def create_account_type(description):
     """Create an Account record"""
     db = DBManager()
     if db.Session is not None:
         try:
             session = db.Session()
             accountType = AccountType(description=description)
             session.add(accountType)
             session.commit()
             return True
         except ProgrammingError as e:
             logging.error(
                 "Unable to create the account information: {0}".format(
                     str(e)))
             return False
     else:
         logging.error(
             "Invalid connection information. Make sure the database is created."
         )
         return False
Esempio n. 6
0
 def list_databases(self):
     db = DBManager()
     self.dbList.addItems(db.list_databases())