示例#1
0
    def extend(self):
        # CURRENT ITEM'S BORROW RECORD
        borrow = self.get()
        period = self.entries['period']

        # UPDATE BORROW RECORD
        # Increase Extended Counter
        # Update BorrowDeadline
        update = Borrow(id=borrow.id,
                        deadline=self.getDeadline(),
                        extended=Borrow.extended + 1)

        # Check If Maximum Number of Extensions Has Been Reached
        if borrow.extended <= self.maxExtend + 1:
            # Check If Lending Period Has Been Set
            if period.get():
                # Insert Data To DB
                session.merge(update)
                session.commit()
                messagebox.showinfo('Hosszabbítás',
                                    'Sikeresen meghosszabbítva')
        else:
            messagebox.showwarning('Hosszabbítás',
                                   'A kölcsönzés többet nem hosszabbítható.')

        # RESET SELECT PERIOD FIELD
        period.set('')
示例#2
0
    def borrow(self):
        # Delete Old Borrow
        self.delete()

        # Create New Borrow Record
        borrow = Borrow(readers=self.reader, deadline=self.getDeadline())

        # Set Borrowed Item
        setattr(borrow, self.item.__tablename__, self.item)

        # Number of Borrowed Items
        count = session.query(Borrow).filter_by(
            reader_id=self.reader.id).count()

        # Check If Number of Borrowed Items Less Than 5
        if count < 5:
            if self.reader:
                # Insert Data To DB
                session.merge(borrow)
                session.commit()
                self.extendButton()  # Reset

            messagebox.showinfo('Kölcsönzés', 'Kikölcsönözve.')
        else:
            messagebox.showerror(
                'Kölcsönzés',
                'A maxiumum kölcsönözhető dokumentumok meghaladva.')

        # RESET SELECT PERIOD FIELD
        self.entries['period'].set('')
示例#3
0
    def readers():
        for row in Import.readcsv(Import.openfile()):
            code, name, *_ = row
            reader = Reader(code=code, name=name)
            try:
                session.merge(reader)
                session.commit()
            except:
                session.rollback()

        messagebox.showinfo('Importálás', 'Adatok beolvasva.')
示例#4
0
 def saveDetails(self):
     try:
         session.merge(self.getDetails())
         session.commit()
         self.itemsList.reload()
         messagebox.showinfo('Mentés', 'Mentés sikeres.')
     except:
         session.rollback()
         messagebox.showinfo(
             'Mentés',
             'Hiba lépett fel a mentésnél. Ne használjon ismétlődő azonosítókat.'
         )
    def removeReader(self):
        reader = self.selectedReader()
        message = 'Biztosan ki szeretné törölni:\n' + reader.name
        dialog = messagebox.askyesno('Törlés', message, icon='warning')

        if dialog:
            try:
                session.delete(reader)
                session.commit()
                self.reload()
            except:
                session.rollback()
                messagebox.showerror('Hiba',
                                     'Ennek az olvasónak még tartozása van.')
示例#6
0
    def documents():
        for row in Import.readcsv(Import.openfile()):
            code, tag, *params = row

            params = list(params) + [None]*6

            if tag == 'K':
                title, value, author, publisher, isbn, category, *_ = params

                volume = Book(
                        code        = code,
                        title       = title,
                        value       = value,
                        author      = author,
                        publisher   = publisher,
                        isbn        = isbn,
                        category    = category
                    )

            if tag == 'F':
                title, value, publisher, issue, volume, *_ = params
                volume = Magazine(
                        code        = code,
                        title       = title,
                        value       = value,
                        publisher   = publisher,
                        issue       = issue,
                        volume      = volume
                    )

            if tag == 'M':
                type, title, value, release, lengthOrColor, *_ = params
                volume = Medium(
                        code        = code,
                        type        = type,
                        title       = title,
                        value       = value,
                        release     = release,
                        length      = type != 'DIA' and lengthOrColor,
                        color       = type == 'DIA' and lengthOrColor
                    )

            try:
                session.merge(volume)
                session.commit()
            except:
                session.rollback()

        messagebox.showinfo('Importálás', 'Adatok beolvasva.')
示例#7
0
    def removeVolume(self):
        volume = self.getSelected()
        message = 'Biztosan ki szeretné törölni:\n' + volume.title
        dialog = messagebox.askyesno('Törlés', message, icon='warning')

        if dialog:
            try:
                session.delete(volume)
                session.commit()
                self.library.frame('right')
                self.reload()
            except:
                session.rollback()
                messagebox.showerror('Törlés',
                                     'Kölcsönzött dokumentum nem törölhető.')
示例#8
0
 def add(borrow):
     try:
         session.merge(borrow)
         session.commit()
     except:
         session.rollback()
示例#9
0
 def delete(self):
     # Remove Returned Item from Borrows List
     item = self.get()
     item and session.delete(item)
     session.commit()