示例#1
0
 def _update(self):
     print('update')
     query = """UPDATE Deposits SET """
     for key in Deposit.__dict__.keys():
         if key[0] != '_' and key not in [
                 'DepositeCode', 'load', 'save', 'delete'
         ]:
             param = key + '=' + '\'' + str(getattr(self, key)) + '\''
             query += param
             query += ','
     query = query[:-1]
     whereParam = """DepositeCode = """ + str(self.DepositeCode)
     query += """WHERE """ + whereParam
     print(query)
     DbInitializer.inst().ExecQuery(query)
示例#2
0
 def _update(self, entity):
     print('update')
     query = """UPDATE Currencies SET """
     for key in Currency.__dict__.keys():
         if key[0] != '_' and key not in [
                 'CurrencyCode', 'load', 'save', 'delete'
         ]:
             param = key + '=' + '\'' + str(getattr(entity, key)) + '\''
             query += param
             query += ','
     query = query[:-1]
     whereParam = """CurrencyCode = """ + str(entity.CurrencyCode)
     query += """WHERE """ + whereParam
     print(query)
     DbInitializer.inst().ExecQuery(query)
示例#3
0
 def load(self, paramDict):
     query = """SELECT """
     for key in Deposit.__dict__.keys():
         if key[0] != '_' and key not in ['load', 'save', 'delete']:
             query += key
             query += ','
     query = query[:-1]
     query += " FROM Deposits WHERE "
     equal_substr = '{attr_name} = {attr_value}'
     counter = len(paramDict)
     for param in paramDict:
         query += equal_substr.format(attr_name=param,
                                      attr_value=paramDict[param])
         if counter == 1:
             query += ';'
         else:
             query += ' AND '
         counter -= 1
     print(query)
     resultRow = DbInitializer.inst().ExecAndReturn(query)[0]
     if resultRow is not None:
         attrCounter = 0
         for key in Deposit.__dict__.keys():
             if key[0] != '_' and key not in ['load', 'save', 'delete']:
                 valueOfCell = str(resultRow[attrCounter])
                 setattr(self, key, valueOfCell)
                 attrCounter += 1
     else:
         print("Row is not exist")
示例#4
0
 def _update(self, instanceToUpdate):
     print('update')
     query = """UPDATE Employees SET """
     for key in Employee.__dict__.keys():
         if key[0] != '_' and key not in [
                 'EmployeeCode', 'load', 'save', 'delete'
         ]:
             param = key + '=' + '\'' + str(getattr(instanceToUpdate,
                                                    key)) + '\''
             query += param
             query += ','
     query = query[:-1]
     whereParam = """EmployeeCode = """ + str(instanceToUpdate.EmployeeCode)
     query += """WHERE """ + whereParam
     print(query)
     DbInitializer.inst().ExecQuery(query)
示例#5
0
 def save(self):
     print('insert')
     if self.DepositeCode == 0:
         query = """INSERT INTO Deposits ("""
         for key in Deposit.__dict__.keys():
             if key[0] != '_' and key not in [
                     'DepositeCode', 'load', 'save', 'delete'
             ]:
                 query += key
                 query += ','
         query = query[:-1]
         query += """) VALUES ("""
         for key in Deposit.__dict__.keys():
             if key[0] != '_' and key not in [
                     'DepositeCode', 'load', 'save', 'delete'
             ]:
                 query += '\'' + str(getattr(self, key)) + '\''
                 query += ','
         query = query[:-1]
         query += ')'
         print(query)
         DbInitializer.inst().ExecQuery(query)
     else:
         self._update()
示例#6
0
 def save(self, instanceToSave):
     print('insert')
     if instanceToSave.EmployeeCode == 0:
         query = """INSERT INTO Employees ("""
         for key in Employee.__dict__.keys():
             if key[0] != '_' and key not in [
                     'EmployeeCode', 'load', 'save', 'delete'
             ]:
                 query += key
                 query += ','
         query = query[:-1]
         query += """) VALUES ("""
         for key in Employee.__dict__.keys():
             if key[0] != '_' and key not in [
                     'EmployeeCode', 'load', 'save', 'delete'
             ]:
                 query += '\'' + str(getattr(instanceToSave, key)) + '\''
                 query += ','
         query = query[:-1]
         query += ')'
         print(query)
         DbInitializer.inst().ExecQuery(query)
     else:
         self._update(instanceToSave)
示例#7
0
 def save(self, entity):
     print('insert')
     if entity.RoleCode == 0:
         query = """INSERT INTO Roles ("""
         for key in Role.__dict__.keys():
             if key[0] != '_' and key not in [
                     'RoleCode', 'load', 'save', 'delete'
             ]:
                 query += key
                 query += ','
         query = query[:-1]
         query += """) VALUES ("""
         for key in Role.__dict__.keys():
             if key[0] != '_' and key not in [
                     'RoleCode', 'load', 'save', 'delete'
             ]:
                 query += '\'' + str(getattr(entity, key)) + '\''
                 query += ','
         query = query[:-1]
         query += ')'
         print(query)
         DbInitializer.inst().ExecQuery(query)
     else:
         self._update(entity)
示例#8
0
 def getAll(self):
     query = """SELECT """
     for key in Currency.__dict__.keys():
         if key[0] != '_' and key not in ['load', 'save', 'delete']:
             query += key
             query += ','
     query = query[:-1]
     query += " FROM Roles"
     print(query)
     resultRows = DbInitializer.inst().ExecAndReturn(query)
     if resultRows is not None:
         for resultRow in resultRows:
             attrCounter = 0
             currentEntity = Role()
             for key in Role.__dict__.keys():
                 if key[0] != '_' and key not in ['load', 'save', 'delete']:
                     valueOfCell = str(resultRow[attrCounter])
                     setattr(currentEntity, key, valueOfCell)
                     attrCounter += 1
             self.Entities.append(currentEntity)
         return self.Entities
     else:
         print("Rows is not exist")
示例#9
0
 def delete(self):
     print('delete')
     query = """DELETE FROM Deposits WHERE DepositeCode="""
     query += str(self.DepositeCode)
     DbInitializer.inst().ExecQuery(query)
示例#10
0
 def delete(self):
     print('delete')
     query = """DELETE FROM Employees WHERE EmployeeCode="""
     query += str(self.EmployeeCode)
     DbInitializer.inst().ExecQuery(query)
示例#11
0
 def delete(self):
     print('delete')
     query = """DELETE FROM Investors WHERE InvestorCode="""
     query += str(self.InvestorCode)
     DbInitializer.inst().ExecQuery(query)
示例#12
0
 def delete(self):
     print('delete')
     query = """DELETE FROM Currencies WHERE CurrencyCode="""
     query += str(self.CurrencyCode)
     DbInitializer.inst().ExecQuery(query)
示例#13
0
 def delete(self, entity):
     print('delete')
     query = """DELETE FROM Roles WHERE RoleCode="""
     query += str(entity.RoleCode)
     DbInitializer.inst().ExecQuery(query)
示例#14
0
from BankDomain.Investor import Investor
from BankDomain.Currency import Currency
from BankDomain.Deposits import Deposit
from BankDomain.Role import Role
from BankDomain.Employee import Employee
from BankDomain.BankUOW import domainUOW
from BankDomain.DBInitializer import DbInitializer
from BankDomain.DAOs import EmployeeDAO

initializer = DbInitializer.inst()
initializer.CreateTables()
#initializer.CreateTables();

uow = domainUOW()
empDAO = EmployeeDAO()
inst = Employee()
inst.EmployeeCode = 20
inst.Pib = 'Kosobutskiy Bogdan'
inst.PassportData = 'Tu354352'
inst.Address = "Jitomir st."

inst.Age = 23
inst.RoleCode = 3

#uow.registerNew(inst)
#empDAO.save(inst);
insert = Employee()
insert.RoleCode = 2
insert.Pib = 'Lazuto Maxim'
insert.PassportData = 'MK233433'
insert.Address = 'Kyiv'