コード例 #1
0
ファイル: model.py プロジェクト: NatName/BD_2
 def read_items(self, value, word=None):
     if word and value == 1:
         strWord = Additional.addLogicOperation(word)
         return Additional.findWordInText(self.connection, strWord)
     elif value == 2:
         return Additional.findTextWithoutWord(self.connection, word)
     return baseData.select_all(self.connection, self.tableName)
コード例 #2
0
ファイル: model.py プロジェクト: NatName/BD_2
 def delete_shop(self, shopId):
     try:
         assert not Additional.findExistingIdOrderTable(self.connection, self.tableName, shopId), \
             '\033[91m shop id bind with order \033[0m'
         assert Additional.findExistingId(self.connection, self.tableName, shopId), \
             '\033[91m id isn\'t exist \033[0m'
         baseData.delete_one(self.connection, shopId, self.tableName)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #3
0
ファイル: model.py プロジェクト: NatName/BD_2
 def delete_customer(self, customerId):
     try:
         assert not Additional.findExistingIdOrderTable(self.connection, self.tableName, customerId),\
             '\033[91m You don\'t delete customer, because this customer bind with order \033[0m'
         assert Additional.findExistingId(self.connection, self.tableName, customerId), \
             '\033[91m id isn\'t exist \033[0m'
         baseData.delete_one(self.connection, customerId, self.tableName)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #4
0
ファイル: model.py プロジェクト: NatName/BD_2
 def create_order(self, itemId, shopId, customerId, date):
     try:
         assert Additional.findExistingId(
             self.connection, "Item",
             itemId), '\033[91m item id isn\'t exist \033[0m'
         assert Additional.findExistingId(
             self.connection, "Shop",
             shopId), '\033[91m shop id isn\'t exist \033[0m'
         assert Additional.findExistingId(self.connection, "Customer", customerId), \
             '\033[91m customer id isn\'t exist \033[0m'
         baseData.insert_one_order(self.connection, itemId, shopId,
                                   customerId, date)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #5
0
ファイル: model.py プロジェクト: NatName/BD_2
 def update_shop(self, shopId, name, street):
     try:
         assert Additional.findExistingId(self.connection, self.tableName, shopId), \
             '\033[91m id isn\'t exist \033[0m '
         baseData.update_one_shop(self.connection, shopId, name, street)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #6
0
ファイル: model.py プロジェクト: NatName/BD_2
 def delete_order(self, orderId):
     try:
         assert Additional.findExistingId(self.connection, self.tableName, orderId), \
             '\033[91m id isn\'t exist \033[0m'
         baseData.delete_one(self.connection, orderId, self.tableName)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #7
0
ファイル: model.py プロジェクト: NatName/BD_2
 def update_customer(self, customerId, name, phone, sex):
     try:
         assert (sex == "male" or sex == "female"), \
             '\033[91m sex isn\'t exist. You must input male or female \033[0m'
         assert Additional.findExistingId(self.connection, self.tableName, customerId), \
             '\033[91m id isn\'t exist \033[0m '
         baseData.update_one_customer(self.connection, customerId, name,
                                      phone, sex)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #8
0
ファイル: model.py プロジェクト: NatName/BD_2
 def update_item(self, itemId, name, price, quantity, color, material,
                 description):
     try:
         assert price > 0, '\033[91m price must be more zero \033[0m'
         assert quantity > 0, '\033[91m quantity must be > 0 \033[0m'
         assert Additional.findExistingId(self.connection, self.tableName, itemId), \
             '\033[91m id isn\'t exist \033[0m'
         baseData.update_one_item(self.connection, itemId, name, price,
                                  quantity, color, material, description)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #9
0
ファイル: model.py プロジェクト: NatName/BD_2
 def create_many_orders(self, count):
     try:
         itemId = Additional.findExistRow(self.connection, "Item")
         shopId = Additional.findExistRow(self.connection, "Shop")
         customerId = Additional.findExistRow(self.connection, "Customer")
         assert Additional.findExistingId(
             self.connection, "Item",
             itemId), '\033[91m item id isn\'t exist \033[0m'
         assert Additional.findExistingId(
             self.connection, "Shop",
             shopId), '\033[91m shop id isn\'t exist \033[0m'
         assert Additional.findExistingId(self.connection, "Customer", customerId), \
             '\033[91m customer id isn\'t exist \033[0m'
         baseData.insert_many_random_orders(self.connection, count, itemId,
                                            customerId, shopId)
         return True
     except Exception as err:
         print(err)
         return False
コード例 #10
0
ファイル: model.py プロジェクト: NatName/BD_2
 def read_order_itemName(self, name):
     return Additional.findItemName(self.connection, name)
コード例 #11
0
ファイル: model.py プロジェクト: NatName/BD_2
 def read_order_another_table(self, first, second=None):
     return Additional.findRowBetweenNumbers(self.connection, first, second)