def __init__(self): self.__select_user = User( [1, "", "", "", "", "", "", "", "", "", "", ""]) self.users = DataContext().User.load().list_model() self.__list_book = [] self.__search_sename = "" self.__observers = []
def __init__(self): self.__login = "" self.__password = "" self.__name = "" self.__sename = "" self.__midname = "" self.__type = "" self.__email = "" self.__phone = "" self.__comment = "" self.__class = "" self.__class_type = "" self.__select_user = User([1, "", "", "", "", "", "", "", "", "", "", ""]) self.users = DataContext().User.load().list_model() self.bilet_user = DataContext().Bilet.join(Book(), User(), [-4, -3, 1, 9, -1]) self.__observers = []
class DataContext(metaclass=Solide): __server = 'localhost' __database = 'library' __connect = pyodbc.connect("DRIVER={ODBC Driver 13 for SQL Server};" "Server=" + __server + ";" "Database=" + __database + ";" "Trusted_Connection=yes;") __link = __connect.cursor() User = EntityModel(User(), __link, __connect) Book = EntityModel(Book(), __link, __connect) Bilet = EntityModel(Bilet(), __link, __connect)
def load_list_book(self): date = datetime.date.today() for i in self.__model.list_book: DataContext().Bilet.add( BiletOrig([ 0, self.__model.select_user.id, i.id, date.strftime("%Y-%m-%d") ])) i.state = "T" DataContext().Book.update(i) DataContext().Bilet.save_change() DataContext().Book.save_change() self.__model.select_user = User( [1, "", "", "", "", "", "", "", "", "", "", ""]) self.__model.list_book = [] self.__model.search_sename = ""
def update(self): self.__model.users = DataContext().User.update( self.__model.select_user).save_change().load().list_model() self.__model.select_user = User( ["", "", "", "", "", "", "", "", "", "", "", ""])