-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_db.py
More file actions
73 lines (59 loc) · 2.35 KB
/
view_db.py
File metadata and controls
73 lines (59 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from tkinter import *
from tkinter import ttk
import sqlite3
class View_Db:
def __init__(self):
pass
def view(self):
root = Tk()
root.title("Melsons Stock Inventory Management System")
root.geometry("1250x800")
Label(root, text="Melsons Stock Inventory Management System", fg="white",
font="arial 24 bold", bg="black").place(x=5, y=10)
titles = ('Primary Key', 'Item', 'Cost of Good', 'Quantity', 'Total Cost', 'Sale Price')
database = ttk.Treeview(root, columns=titles, show='headings', height=35)
def viewdb():
view = View_Db()
view.view()
def editpage():
from edit_data import Edit_data
edit = Edit_data()
edit.edit()
def addpage():
from add_page import Add_page
Add = Add_page()
Add.add()
def findb():
from fin_db import Fin_Db
findb = Fin_Db()
findb.fin_db()
nav = Menu(root)
root.config(menu=nav)
file = Menu(nav)
nav.add_cascade(label="File", menu=file)
file.add_command(label="Open Current Stock", command=viewdb)
file.add_command(label="Open Financial Record", command=findb)
file.add_separator()
file.add_command(label="Exit", command=root.destroy)
edit = Menu(nav)
nav.add_cascade(label="Edit", menu=edit)
edit.add_command(label="Add New Item", command=addpage)
edit.add_command(label="Update Current Stock", command=editpage)
for title in titles:
database.heading(title, text=title)
database.grid(row=1, column=0, columnspan=2)
database.place(x=10, y=70)
def rundb():
for child in database.get_children():
database.delete(child)
con = sqlite3.connect('inventory.db')
cur = con.cursor()
cur.execute('''SELECT * , oid FROM stock''')
content = cur.fetchall()
for child in content:
database.insert('', 'end', values=(
child[5], child[0], child[1], child[2], child[3], child[4])) # Input data into treeview from database... child 5 is ID
con.close()
rundb()
Button(root, text="Refresh", command=rundb).place(x=600, y=10)
root.mainloop()