Exemplo n.º 1
0
 def event_tot(event):
     if len(entry_tot.get()) == 0:
         add_item()
     else:
         i, u = entry_item.get(), entry_unit.get()
         if len(i) != 0 and len(u) != 0:
             x = backend.search_data(i, u)
             x = x[0]
             qty = round((float(entry_tot.get()) / x[3]), 2)
             entry_qty.delete(0, END)
             entry_qty.insert(END, qty)
Exemplo n.º 2
0
 def event_qty(event):
     if len(entry_qty.get()) == 0:
         entry_tot.focus_set()
     else:
         i, u = entry_item.get(), entry_unit.get()
         if len(i) != 0 and len(u) != 0:
             x = backend.search_data(i, u)
             x = x[0]
             tot = float(entry_qty.get()) * x[3]
             entry_tot.delete(0, END)
             entry_tot.insert(END, tot)
Exemplo n.º 3
0
 def delete_data():
     i, u = entry_item.get(), entry_unit.get()
     if len(i) != 0 and len(u) != 0:
         k = backend.search_data(i, u)
         k = k[0][0]
         backend.delete_record(k)
         self.update_data_list()
         clear_entries()
         display_data()
     else:
         messagebox.showwarning(
             'Warning', '"Item" and "Unit" should not be empty')
Exemplo n.º 4
0
        def search():
            i, u = entry_item.get(), entry_unit.get()

            if len(i) != 0 or len(u) != 0:
                searched_data = backend.search_data(i, u)

                data = []
                for row in searched_data:
                    d = [row[1], row[2], row[3], row[4]]
                    data.append(d)

                self.clear_tv(tv_data)
                self.display(tv_data, data)
Exemplo n.º 5
0
        def search_item():
            i, u = entry_item.get(), entry_unit.get()
            if len(i) == 0 and len(u) == 0:
                display_all()
            else:
                searched_data = backend.search_data(i, u)

                data = []
                for i in searched_data:
                    d = [i[1], i[2], i[3], i[4]]
                    data.append(d)

                self.clear_tv(tv_left)
                self.display(tv_left, data)
Exemplo n.º 6
0
 def tv_select(event):
     global k
     f = tv_data.focus()
     i = tv_data.item(f)
     x = i['values']
     k = backend.search_data(x[0], x[1])
     k = k[0][0]
     entry_item.delete(0, END)
     entry_item.insert(END, x[0])
     entry_unit.delete(0, END)
     entry_unit.insert(END, x[1])
     entry_price.delete(0, END)
     entry_price.insert(END, x[2])
     entry_stock.delete(0, END)
     entry_stock.insert(END, x[3])
Exemplo n.º 7
0
    def stop(self):

        x = messagebox.askyesno(
            'Exit Application', 'Confirm if you want to exit')

        if x > 0:
            if self.items:
                data = self.items
                for k, v in data.items():
                    i, u = k.split('|')
                    x = backend.search_data(i, u)
                    x = x[0]
                    s = x[4] + v[0]
                    backend.update_data(x[0], i, u, x[3], s)

            self.root.destroy()
Exemplo n.º 8
0
 def cancel():
     if self.items:
         a = messagebox.askyesno(
             'Cancel', 'Confirm if you want to cancel the transaction')
         if a > 0:
             data = self.items
             for k, v in data.items():
                 i, u = k.split('|')
                 x = backend.search_data(i, u)
                 x = x[0]
                 s = x[4] + v[0]
                 backend.update_data(x[0], i, u, x[3], s)
             self.items.clear()
             clear_item()
         display_all()
         display_items()
Exemplo n.º 9
0
 def add_item():
     data_keys = self.sort_data_dict()
     i, u, q, t, d = entry_item.get(), entry_unit.get(
     ), entry_qty.get(), entry_tot.get(), entry_discnt.get()
     if len(i) != 0 and len(u) != 0:
         x = backend.search_data(i, u)
         x = x[0][0]
         key = f'{i}|{u}'
         if key in data_keys:
             if len(q) != 0 and len(t) != 0:
                 tot = float(t)
                 qty = float(q)
                 if self.data_dict[key][1] >= qty:
                     s = self.data_dict[key][1] - qty
                     sub = self.data_dict[key][0] * qty
                     if key in self.items:
                         nq = self.items[key][0] + qty
                         tot = tot + self.items[key][3]
                         sub = sub + self.items[key][1]
                     else:
                         nq = qty
                     d = sub - tot
                     self.items[key] = [
                         round(nq, 2), sub, round(d), tot]
                     backend.update_data(
                         x, i, u, self.data_dict[key][0], s)
                 else:
                     messagebox.showwarning(
                         'Warning', f'Not enough stock for {i} in {u}')
             else:
                 messagebox.showwarning(
                     'Warning', '"Quantity" and "Total" should not be empty')
         else:
             messagebox.showwarning(
                 'Warning', f'{i} in {u} is not in the database')
     else:
         messagebox.showwarning(
             'Warning', '"Item" and "Unit" should not be empty')
     display_items()
     display_all()
Exemplo n.º 10
0
 def delete_item():
     i, u, q = entry_item.get(), entry_unit.get(), entry_qty.get()
     if len(i) != 0 and len(u) != 0 and len(q) != 0:
         k = f'{i}|{u}'
         x = backend.search_data(i, u)
         x = x[0]
         if self.items[k][0] >= float(q):
             nq = self.items[k][0] - float(q)
             p = self.items[k][3] / self.items[k][0]
             d = float(q) * p
             nt = self.items[k][3] - d
             if nq == 0:
                 self.items.pop(k)
             else:
                 sub = self.items[k][1] - x[3] * float(q)
                 self.items[k] = [nq, sub, sub - nt, nt]
             s = x[4] + float(q)
             backend.update_data(x[0], i, u, x[3], s)
         else:
             messagebox.showwarning(
                 'Warning', 'Invalid "Quantity" value')
     display_items()
     display_all()
Exemplo n.º 11
0
def search_command():
    list_box.delete(0, END)
    for row in backend.search_data(title_text.get(), author_text.get(),
                                   year_text.get(), isbn_text.get()):
        list_box.insert(END, row)
Exemplo n.º 12
0
def searchitem():
    listbox1.delete(0, END)
    for rows in backend.search_data(IsbnText.get()):
        listbox1.insert(END, rows)