-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pharmacy_POS.py
215 lines (172 loc) · 10.4 KB
/
Pharmacy_POS.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import sqlite3, time
import tkinter as tk
from tkinter import messagebox
from tkinter.font import BOLD
class Employee:
def __init__(self, name, level):
self.name = name
self.level = level
class LoginScreen(tk.Frame):
def __init__(self):
tk.Frame.__init__(self)
self.pack()
self.master.title('Generic POS 1.0')
height = self.master.winfo_screenheight()
width = self.master.winfo_screenwidth()
self.master.geometry(f'{int(width * 0.2)}x{int(height * 0.2)}+{int(width * 0.4)}+{int(height * 0.3)}')
self.master.config(borderwidth='20')
self.master.resizable(False, False)
self.user_var = tk.StringVar()
self.pass_var = tk.StringVar()
title = tk.Label(self, text='Software Login', font=('Trebuchet MS', 20, BOLD), bd=5)
title.grid(columnspan = 2)
username = tk.Label(self, text='Username: ', font=('Trebuchet MS', 15))
username.grid(row=1)
username1 = tk.Entry(self, textvariable=self.user_var, font=('Trebuchet MS', 15),
bd=2, relief=tk.SUNKEN)
username1.grid(row=1, column=1)
password = tk.Label(self, text='Password: ', font=('Trebuchet MS', 15))
password.grid(row=2)
password1 = tk.Entry(self, textvariable=self.pass_var, font=('Trebuchet MS', 15), show='●',
bd=2, relief=tk.SUNKEN)
password1.bind('<Return>', lambda x: self.verify(self.user_var.get(), self.pass_var.get()))
password1.grid(row=2, column=1)
login = tk.Button(self, text='Submit', font=('Trebuchet MS', 15), bd=5, relief=tk.RAISED,
command=lambda: self.verify(self.user_var.get(), self.pass_var.get()))
login.grid(row=3, columnspan=2, pady=10)
def verify(self, username, password):
try:
software_user = 'Administrator'
software_pass = 'Admin@123'
if username == software_user and password == software_pass:
self.master.destroy()
MainInterface()
else:
self.errorMessage()
except ValueError:
self.errorMessage()
except TypeError:
self.errorMessage()
def errorMessage(self):
messagebox.showinfo("Login Error", "Incorrect username or password.")
self.user_var.set('')
self.pass_var.set('')
class MainInterface(tk.Frame):
def __init__(self):
tk.Frame.__init__(self)
self.pack()
self.master.title('Generic POS 1.0')
self.master.protocol('WM_DELETE_WINDOW', lambda: self.exitApplication())
height = self.master.winfo_screenheight()
width = self.master.winfo_screenwidth()
self.master.geometry(f'{int(width * 0.5)}x{int(height * 0.5)}+{int(width * 0.25)}+{int(height * 0.2)}')
self.master.config(pady=150, bg='sky blue')
#======================================MENU======================================
self.menu_bar = tk.Menu(self)
self.shift_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='Shift', underline=0, menu=self.shift_menu)
self.shift_menu.add_command(label='Substitute Cashier', underline=0, command=lambda: self.doNothing())
self.shift_menu.add_command(label='End Shift', underline=0, command=lambda: self.doNothing())
self.shift_menu.add_command(label='End-of-Day Shift', underline=8, command=lambda: self.doNothing())
self.shift_menu.add_separator()
self.shift_menu.add_command(label='Exit Application', underline=1, command=lambda: self.exitApplication())
self.customer_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='Customers', underline=0, menu=self.customer_menu)
self.customer_menu.add_command(label='Customers', underline=0, command=lambda: self.doNothing())
self.customer_menu.add_command(label='Add Customer', underline=0, command=lambda: self.doNothing())
self.customer_menu.add_command(label='Remove Customer', underline=0, command=lambda: self.doNothing())
self.customer_menu.add_command(label='Update Customer', underline=0, command=lambda: self.doNothing())
self.product_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='Inventory', underline=0, menu=self.product_menu)
self.product_menu.add_command(label='Products', underline=0, command=lambda: self.doNothing())
self.product_menu.add_command(label='Add Product', underline=0, command=lambda: self.doNothing())
self.product_menu.add_command(label='Remove Product', underline=0, command=lambda: self.doNothing())
self.product_menu.add_command(label='Update Product', underline=0, command=lambda: self.doNothing())
self.transactions_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='Transactions', underline=0, menu=self.transactions_menu)
self.transactions_menu.add_command(label='View History', underline=5, command=lambda: self.doNothing())
self.transactions_menu.add_command(label='Product Statistics', underline=8, command=lambda: self.doNothing())
self.transactions_menu.add_command(label='Reports', underline=0, command=lambda: self.doNothing())
self.transactions_menu.add_command(label='Logs', underline=0, command=lambda: self.doNothing())
self.help_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='Help', underline=0, menu=self.help_menu)
self.help_menu.add_command(label='Transactions', underline=0, command=lambda: self.doNothing())
self.help_menu.add_command(label='Administration', underline=0, command=lambda: self.doNothing())
self.help_menu.add_command(label='Send Report', underline=0, command=lambda: self.doNothing())
self.about_menu = tk.Menu(self.menu_bar, tearoff=False)
self.menu_bar.add_cascade(label='About', underline=0, menu=self.about_menu)
self.about_menu.add_cascade(label='Program', underline=0, command=lambda: self.doNothing())
self.about_menu.add_cascade(label='Creator', underline=0, command=lambda: self.doNothing())
self.master.config(borderwidth='20', menu=self.menu_bar)
self.master.resizable(False, False)
#====================================LOGIN====================================
self.loginFrame = tk.Frame(self.master)
self.loginFrame.pack()
self.user_var = tk.StringVar()
self.pass_var = tk.StringVar()
self.title = tk.Label(self.loginFrame, text='GENERIC POS 1.0', font=('Trebuchet MS', 20, BOLD))
self.title.grid(columnspan=2)
self.title1 = tk.Label(self.loginFrame, text='Employee Log-In', font=('Trebuchet MS', 15))
self.title1.grid(row=1, columnspan=2)
self.username = tk.Label(self.loginFrame, text='ID Number:', font=('Trebuchet MS', 15))
self.username.grid(row=2, sticky=tk.E, padx=10)
self.username1 = tk.Entry(self.loginFrame, textvariable=self.user_var, font=('Trebuchet MS', 15),
bd=2, relief=tk.SUNKEN)
self.username1.grid(row=2, column=1, padx=10)
self.password = tk.Label(self.loginFrame, text='Password:', font=('Trebuchet MS', 15))
self.password.grid(row=3, sticky=tk.E, padx=10)
self.password1 = tk.Entry(self.loginFrame, textvariable=self.pass_var, font=('Trebuchet MS', 15), show='●',
bd=2, relief=tk.SUNKEN)
self.password1.bind('<Return>', lambda x: self.verifyEmployee(self.user_var.get(), self.pass_var.get()))
self.password1.grid(row=3, column=1, padx=10)
prompt = self.login = tk.Button(self.loginFrame, text='Submit', font=('Trebuchet MS', 15), bd=5, relief=tk.RAISED,
command=lambda: self.verifyEmployee(self.user_var.get(), self.pass_var.get()))
self.login.grid(row=4, columnspan=2, pady=10)
#===================================POINT=OF=SALES===================================
employeesC.execute(f'SELECT * FROM Employees WHERE employeeID = {int(self.user_var.get())}')
employeeInfo = employeesC.fetchone()
self.user = Employee(employeeInfo[2], employeeInfo[4])
self.posFrame = tk.Frame(self.master)
self.posFrame.pack()
self.title = tk.Label(self.posFrame, text=f'Welcome, {self.user.name}', font=('Trebuchet MS', 20, BOLD))
self.title.grid(columnspan=2)
def verifyEmployee(self, username, password):
try:
employeesC.execute(f'SELECT * FROM Employees WHERE employeeID = {int(username)}')
employeeData = employeesC.fetchone()
if int(username) == employeeData[0] and password == employeeData[1]:
self.loginFrame.destroy()
else:
self.errorMessage()
except ValueError:
self.errorMessage()
except TypeError:
self.errorMessage()
def errorMessage(self):
messagebox.showinfo("Login Error", "Incorrect username or password.")
self.user_var.set('')
self.pass_var.set('')
def doNothing(self):
pass
def exitApplication(self):
prompt = messagebox.askyesno('Exit Program', 'Are you sure you want to exit the program?')
if prompt:
self.master.quit()
if __name__ == '__main__':
employeesDB = sqlite3.connect('employees.db')
employeesC = employeesDB.cursor()
employeesC.execute('CREATE TABLE IF NOT EXISTS Employees (employeeID INTEGER, password TEXT, firstName TEXT, lastName TEXT, authorityLevel INTEGER)')
customerDB = sqlite3.connect('customers.db')
customerC = customerDB.cursor()
customerC.execute(
'CREATE TABLE IF NOT EXISTS Accounts (customerID INTEGER, firstName TEXT, lastName TEXT, age INTEGER, emailAdd TEXT)')
customerC.execute('CREATE TABLE IF NOT EXISTS Points (customerID INTEGER, points INTEGER)')
transactionDB = sqlite3.connect('transactions.db')
transactionC = transactionDB.cursor()
transactionC.execute(
'CREATE TABLE IF NOT EXISTS Transactions (date TEXT, customerID INTEGER, transactionCode TEXT)')
transactionC.execute('CREATE TABLE IF NOT EXISTS Reports (date TEXT, sales REAL, stats REAL)')
productDB = sqlite3.connect('products.db')
productC = productDB.cursor()
productC.execute('CREATE TABLE IF NOT EXISTS Products (categoryCode TEXT, barCode INTEGER, productName TEXT, sellingPrice REAL)')
LoginScreen().mainloop()