Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
18 views

Medical Store Management System Project in Python - CopyAssignment

Uploaded by

Sanjai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Medical Store Management System Project in Python - CopyAssignment

Uploaded by

Sanjai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment

HOME WRITE FOR US 1000+ PROJECTS CONTACT US Search here...

Medical Store Management System Project


in Python
 AYUSH PURAWR  NOVEMBER 27, 2022

We, the Python rebels, are again back with one another article. Today, we will talk
about the project of Medical Store Management System Project in Python. We all
have been to medical stores and have seen the various software they use in order to
keep track of all the medicines and their location in the store. All the software
provides almost the same features. Now think that how great it would be if we can
develop this system and can provide it to some medical stores. So basically, let us
bring that idea into action.

Today with the motive of building our own Medical Store Management System we will
explain a full code and along with that, we will also provide you with some reference

https://copyassignment.com/medical-store-management-system-project-in-python/ 1/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
materials and links that might turn out to be a great source of information for you. So
without wasting a minute let us start our tutorial with the basic idea of what we have
to develop then a list of basic features and finally will move on to the actual code of
the Medical Store Management System Project in Python

Project Overview: Medical Store


Management System Project in Python

Project Name: Medical Store Management System Project in Python

Abstract: A GUI-based program in python that basically includes the use of the
Tkinter and Sqlite3 database for the execution.

Language/Technologies Python, Tkinter


SEARCH…. Used:

Search … Search IDE Pycharm(Recommended)

Database SQLite3

Python version 3.8 or 3.9


(Recommended):

Type/Category: Final Year Project using Python

We will create a Medical Store Management System for small enterprises based on
Python MySQL Database Access for this project. The software’s user-friendly
interface has been created to provide electronic billing documentation, database
access, and stock maintenance with valued customer assistance. These attributes
have now been employed to calculate consumer discounts, daily revenues, and
procedures to avoid possible income loss. This project on Medical Store
SITEMAP
Management System may be utilized by a wide range of retail and wholesale shops
to automate the task of manually keeping the records and cash flows since its design
Python
was made with ease of use in mind. The conclusions could be generalizable.

Machine Learning
Features of Medical Store Management
Pygame
System

Basically, the main features of the Medical Store Management System Project
Data Structures and
Algorithms(Python) in Python are as follows:

Login and Logout


Python Turtle Dedicated Feature for stock maintenance
Feature to access the database
Various options to generate bills and handle cash
Games with Python

All Blogs On-Site Complete Code for Medical Store


Management System Project in Python
Python Compiler(Interpreter)

Online Java Editor

Online C++ Editor


https://copyassignment.com/medical-store-management-system-project-in-python/ 2/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
Below is the complete code for Medical Store Management System Project
in Python, we have used comments for easy explanation.
Online C Editor

1 from tkinter import *


2 import time
All Editors 3 import sqlite3
4 import random
5 import tempfile
6 import win32api
Services(Freelancing) 7 import win32print
8
9 f = ''
10 flag = ''
11 flags = ''
12 #This is the details for getting access to the system
13 #Username: admin
14 #Password: admin
RECENT POSTS
15
16 login = sqlite3.connect("admin.db")
17 l = login.cursor()
Simple Code to compare Speed of 18
19 c = sqlite3.connect("medicine.db")
Python, Java, and C++? 20 cur = c.cursor()
21
22 # A dataabse with the following columns will bec created for Medical Store Management System
Falling Stars Animation on Python.Hub 23 columns = ('Sl No', 'Name', 'Type', 'Quantity Left', 'Cost', 'Purpose', 'Expiry Date', 'Rack location', 'M
24
October 2024 25 #This function will basically be called once the user logs in.
26 #This function is responsible for the overall display of various option
27 def open_win():
Most Underrated Database Trick | Life- 28 global apt, flag
29 flag = 'apt'
Saving SQL Command 30 apt = Tk()
31
32 #The below is for displaying the basic project labels. We used Label() function.
Python List Methods 33 apt.geometry('950x500')
34 apt.title('CopyAssignment')
35 Label(apt, text="CopyAssignment", font=('ariel', 45, ), fg='blue').grid(row=1, column=1)
36 Label(apt, text="MEDICAL STORE MANAGEMENT", font=('ariel', 25, ), fg='red').grid(row=2, colu
Top 5 Free HTML Resume Templates in 37 Label(apt, text="Easily manage all your medicines", font=('ariel', 17, ), fg='green').grid(row=3, co
2024 | With Source Code 38
39 #This is the first column of over options list. This column displays all the options relating to stock
40 Label(apt, text="Stock Maintenance", bg='black', fg='white',font=('ariel', 12 ),).grid(row=7, column
41 Button(apt, text='New V.C.', width=25, bg='green', font=('ariel', 12 ),fg='white', command=val_cus
42 Button(apt, text='Add product to Stock', bg='green', font=('ariel', 12 ),fg='white', width=25, comma
43 Button(apt, text='Delete product from Stock', bg='red', font=('ariel', 12 ),fg='white', width=25, com
44
45 #This is for the second column that will hold all the options relating to accessing database.
46 #In order to modify the font size, color etc we used the various propoerties of Button() fuction.
47 Label(apt, text="Access Database", bg='black',font=('ariel', 12 ), fg='white').grid(row=7, column=1
48 Button(apt, text='Modify', width=15, bg='blue',font=('ariel', 12 ), fg='white', command=modify).grid
49 Button(apt, text='Search', width=15, bg='blue', font=('ariel', 12 ),fg='white', command=search).gri
50 Button(apt, text='Expiry Check', bg='red', fg='white',font=('ariel', 12 ), width=15, command=exp_d
51
52 #The last column display the options relating to bll generation and logout option
53 Label(apt, text="Handle Cash Flows", font=('ariel', 12 ),bg='black', fg='white').grid(row=7, column
54 Button(apt, text="Check Today's Revenue", font=('ariel', 12 ),bg='skyblue', fg='black', width=20, c
55 Button(apt, text='Billing', width=20, bg='skyblue',font=('ariel', 12 ), fg='black', command=billing).g
56 Button(apt, text='Logout', bg='red', fg='white', font=('ariel', 12 ), width=20, command=again).grid(
57 apt.mainloop()
58
59 #This below is the function to display the window for deletion of stock.
60 #A new window will get popped up when the user will choose delete stock option.
61 def delete_stock():
62 global cur, c, flag, lb1, d
63 apt.destroy()
64 flag = 'd'
65 d = Tk()
66 d.title("Delete a product from Stock")
67 Label(d, text='Enter Product to delete:').grid(row=0, column=0)
68 Label(d, text='', width=30, bg='white').grid(row=0, column=1)
69 Label(d, text='Product').grid(row=2, column=0)
70 Label(d, text='Qty. Exp.dt. Cost ').grid(row=2, column=1)
71 ren()
72 b = Button(d, width=20, text='Delete', bg='red', fg='white', command=delt).grid(row=0, column=3)
73 b = Button(d, width=20, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row
74 d.mainloop()
75
76 #The below are some of the functions that are basically defined to handle the operation of the optio
77 def ren():
78 global lb1, d, cur, c
79
80 def onvsb(*args):
81 lb1.yview(*args)
82 lb2.yview(*args)
83 #this function will simply handle the mousewheel functionality if the user scrolls using mouse hee
84 def onmousewheel():
85 lb1.ywiew = ('scroll', event.delta, 'units')
86 lb2.ywiew = ('scroll', event.delta, 'units')

https://copyassignment.com/medical-store-management-system-project-in-python/ 3/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
87 return 'break'
88
89 cx = 0
90 vsb = Scrollbar(orient='vertical', command=onvsb)
91 lb1 = Listbox(d, width=25, yscrollcommand=vsb.set)
92 lb2 = Listbox(d, width=30, yscrollcommand=vsb.set)
93 vsb.grid(row=3, column=2, sticky=N + S)
94 lb1.grid(row=3, column=0)
95 lb2.grid(row=3, column=1)
96 lb1.bind('<MouseWheel>', onmousewheel)
97 lb2.bind('<MouseWheel>', onmousewheel)
98 cur.execute("select *from med")
99 for i in cur:
100 cx += 1
101 s1 = [str(i[0]), str(i[1])]
102 s2 = [str(i[3]), str(i[6]), str(i[4])]
103 lb1.insert(cx, '. '.join(s1))
104 lb2.insert(cx, ' '.join(s2))
105 c.commit()
106 lb1.bind('<<ListboxSelect>>', sel_del)
107
108
109 def sel_del(e):
110 global lb1, d, cur, c, p, sl2
111 p = lb1.curselection()
112 print(p)
113 x=0
114 sl2 = ''
115 cur.execute("select * from med")
116 for i in cur:
117 print(x, p[0])
118 if x == int(p[0]):
119 sl2 = i[0]
120 break
121 x += 1
122 c.commit()
123 print(sl2)
124 Label(d, text=' ', bg='white', width=20).grid(row=0, column=1)
125 cur.execute('Select * from med')
126 for i in cur:
127 if i[0] == sl2:
128 Label(d, text=i[0] + '. ' + i[1], bg='white').grid(row=0, column=1)
129 c.commit()
130
131
132 def delt():
133 global p, c, cur, d
134 cur.execute("delete from med where sl_no=?", (sl2,))
135 c.commit()
136 ren()
137
138 #This fuction will be called when a user choose to modify the data
139 def modify():
140 global cur, c, accept, flag, att, up, n, name_, apt, st, col, col_n
141 col = ('', '', 'type', 'qty_left', 'cost', 'purpose', 'expdt', 'loc', 'mfg')
142 col_n = ('', '', 'Type', 'Quantity Left', 'Cost', 'Purpose', 'Expiry Date', 'Rack location', 'Manufacture')
143 flag = 'st'
144 name_ = ''
145 apt.destroy()
146 n = []
147 #This is the sqlite3 query to select all the medicines in the of Medical Store Management System
148 cur.execute("select * from med")
149 for i in cur:
150 n.append(i[1])
151 c.commit()
152 st = Tk()
153 st.title('MODIFY')
154 Label(st, text='-' * 48 + ' MODIFY DATABASE ' + '-' * 48).grid(row=0, column=0, columnspan=6)
155
156 def onvsb(*args):
157 name_.yview(*args)
158
159 def onmousewheel():
160 name_.ywiew = ('scroll', event.delta, 'units')
161 return 'break'
162
163 cx = 0
164 vsb = Scrollbar(orient='vertical', command=onvsb)
165 vsb.grid(row=1, column=3, sticky=N + S)
166 name_ = Listbox(st, width=43, yscrollcommand=vsb.set)
167 cur.execute("select *from med")
168 for i in cur:
169 cx += 1
170 name_.insert(cx, (str(i[0]) + '. ' + str(i[1])))
171 name_.grid(row=1, column=1, columnspan=2)
172 c.commit()
173 name_.bind('<MouseWheel>', onmousewheel)
174 name_.bind('<<ListboxSelect>>', sel_mn)
175
176
177 Label(st, text='Enter Medicine Name: ').grid(row=1, column=0)

https://copyassignment.com/medical-store-management-system-project-in-python/ 4/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
178 Label(st, text='Enter changed Value of: ').grid(row=2, column=0)
179 att = Spinbox(st, values=col_n)
180 att.grid(row=2, column=1)
181 up = Entry(st)
182 up.grid(row=2, column=2)
183 Button(st, width=10, text='Submit', bg='green', fg='white', command=save_mod).grid(row=2, colu
184 Button(st, width=10, text='Reset', bg='red', fg='white', command=res).grid(row=2, column=5)
185 Button(st, width=10, text='Show data', bg='blue', fg='white', command=show_val).grid(row=1, co
186 Label(st, text='-' * 120).grid(row=3, column=0, columnspan=6)
187 Button(st, width=10, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=5
188 st.mainloop()
189
190
191 def res():
192 global st, up
193 up = Entry(st)
194 up.grid(row=2, column=2)
195 Label(st, width=20, text=' ').grid(row=5, column=i)
196
197 #This function will allow a user to select the medicine he/she wants to modify in Medical Store Man
198 def sel_mn(e):
199 global n, name_, name_mn, sl, c, cur
200 name_mn = ''
201 p = name_.curselection()
202 print(p)
203 x=0
204 sl = ''
205 cur.execute("select * from med")
206 for i in cur:
207 print(x, p[0])
208 if x == int(p[0]):
209 sl = i[0]
210 break
211 x += 1
212 c.commit()
213 print(sl)
214 name_nm = n[int(sl)]
215 print(name_nm)
216
217 #This is to display the data of selected medicine that is existing in the datbase
218 def show_val():
219 global st, name_mn, att, cur, c, col, col_n, sl
220 for i in range(3):
221 Label(st, width=20, text=' ').grid(row=5, column=i)
222 cur.execute("select * from med")
223 for i in cur:
224 for j in range(9):
225 if att.get() == col_n[j] and sl == i[0]:
226 Label(st, text=str(i[0])).grid(row=5, column=0)
227 Label(st, text=str(i[1])).grid(row=5, column=1)
228 Label(st, text=str(i[j])).grid(row=5, column=2)
229 c.commit()
230
231 # save modified data
232 def save_mod():
233 global cur, c, att, name_mn, st, up, col_n, sl
234 for i in range(9):
235 if att.get() == col_n[i]:
236 a = col[i]
237 sql = "update med set '%s' = '%s' where sl_no = '%s'" % (a, up.get(), sl)
238 cur.execute(sql)
239 c.commit()
240 Label(st, text='Updated!').grid(row=5, column=4)
241
242 #he below function comes into picture when the user choose the Add new product option.
243 def stock():
244 global cur, c, columns, accept, flag, sto, apt
245 apt.destroy()
246 flag = 'sto'
247 accept = [''] * 10
248 sto = Tk()
249 sto.title('STOCK ENTRY')
250 Label(sto, text='ENTER NEW PRODUCT DATA TO THE STOCK').grid(row=0, column=0, column
251 Label(sto, text='-' * 50).grid(row=1, column=0, columnspan=2)
252 for i in range(1, len(columns)):
253 Label(sto, width=15, text=' ' * (14 - len(str(columns[i]))) + str(columns[i]) + ':').grid(row=i + 2, co
254 accept[i] = Entry(sto)
255 accept[i].grid(row=i + 2, column=1)
256 Button(sto, width=15, text='Submit', bg='blue', fg='white', command=submit).grid(row=12, column
257 Label(sto, text='-' * 165).grid(row=13, column=0, columnspan=7)
258 Button(sto, width=15, text='Reset', bg='red', fg='white', command=reset).grid(row=12, column=0)
259 Button(sto, width=15, text='Refresh stock', bg='skyblue', fg='black', command=ref).grid(row=12, c
260 for i in range(1, 6):
261 Label(sto, text=columns[i]).grid(row=14, column=i - 1)
262 Label(sto, text='Exp Rack Manufacturer ').grid(row=14, column=5)
263 Button(sto, width=10, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=
264 ref()
265 sto.mainloop()
266
267
268 def ref():

https://copyassignment.com/medical-store-management-system-project-in-python/ 5/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
269 global sto, c, cur
270
271 def onvsb(*args):
272 lb1.yview(*args)
273 lb2.yview(*args)
274 lb3.yview(*args)
275 lb4.yview(*args)
276 lb5.yview(*args)
277 lb6.yview(*args)
278
279 def onmousewheel():
280 lb1.ywiew = ('scroll', event.delta, 'units')
281 lb2.ywiew = ('scroll', event.delta, 'units')
282 lb3.ywiew = ('scroll', event.delta, 'units')
283 lb4.ywiew = ('scroll', event.delta, 'units')
284 lb5.ywiew = ('scroll', event.delta, 'units')
285 lb6.ywiew = ('scroll', event.delta, 'units')
286
287 return 'break'
288
289 cx = 0
290 vsb = Scrollbar(orient='vertical', command=onvsb)
291 lb1 = Listbox(sto, yscrollcommand=vsb.set)
292 lb2 = Listbox(sto, yscrollcommand=vsb.set)
293 lb3 = Listbox(sto, yscrollcommand=vsb.set, width=10)
294 lb4 = Listbox(sto, yscrollcommand=vsb.set, width=7)
295 lb5 = Listbox(sto, yscrollcommand=vsb.set, width=25)
296 lb6 = Listbox(sto, yscrollcommand=vsb.set, width=37)
297 vsb.grid(row=15, column=6, sticky=N + S)
298 lb1.grid(row=15, column=0)
299 lb2.grid(row=15, column=1)
300 lb3.grid(row=15, column=2)
301 lb4.grid(row=15, column=3)
302 lb5.grid(row=15, column=4)
303 lb6.grid(row=15, column=5)
304 lb1.bind('<MouseWheel>', onmousewheel)
305 lb2.bind('<MouseWheel>', onmousewheel)
306 lb3.bind('<MouseWheel>', onmousewheel)
307 lb4.bind('<MouseWheel>', onmousewheel)
308 lb5.bind('<MouseWheel>', onmousewheel)
309 lb6.bind('<MouseWheel>', onmousewheel)
310 cur.execute("select *from med")
311 for i in cur:
312 cx += 1
313 seq = (str(i[0]), str(i[1]))
314 lb1.insert(cx, '. '.join(seq))
315 lb2.insert(cx, i[2])
316 lb3.insert(cx, i[3])
317 lb4.insert(cx, i[4])
318 lb5.insert(cx, i[5])
319 lb6.insert(cx, i[6] + ' ' + i[7] + ' ' + i[8])
320 c.commit()
321
322 #This will handle the functionality of reseting the data that was entered in the text boxes
323 def reset():
324 global sto, accept
325 for i in range(1, len(columns)):
326 Label(sto, width=15, text=' ' * (14 - len(str(columns[i]))) + str(columns[i]) + ':').grid(row=i + 2, co
327 accept[i] = Entry(sto)
328 accept[i].grid(row=i + 2, column=1)
329
330 #This will handle the submimission functionality
331 def submit():
332 global accept, c, cur, columns, sto
333
334 x = [''] * 10
335 cur.execute("select * from med")
336 for i in cur:
337 y = int(i[0])
338 for i in range(1, 9):
339 x[i] = accept[i].get()
340 #Thisis the sqlite3 query to add all the field to the database
341 sql = "insert into med values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (
342 y + 1, x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8])
343 cur.execute(sql)
344 cur.execute("select * from med")
345 c.commit()
346
347 top = Tk()
348 Label(top, width=20, text='Success!').pack()
349 top.mainloop()
350 main_menu()
351
352
353 def chk():
354 global cur, c, accept, sto
355 cur.execute("select * from med")
356 for i in cur:
357 if accept[6].get() == i[6] and i[1] == accept[1].get():
358 sql = "update med set qty_left = '%s' where name = '%s'" % (
359 str(int(i[3]) + int(accept[3].get())), accept[1].get())

https://copyassignment.com/medical-store-management-system-project-in-python/ 6/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
360 cur.execute(sql)
361 c.commit()
362 top = Tk()
363 Label(top, width=20, text='Modified!').pack()
364 top.mainloop()
365 main_menu()
366 else:
367 submit()
368 c.commit()
369
370 #This will work on checking the expiry date of the medcines that are entered in the database of Me
371 global exp, s, c, cur, flag, apt, flags
372 apt.destroy()
373 flag = 'exp'
374 from datetime import date
375 now = time.localtime()
376 n = []
377 cur.execute("select *from med")
378 for i in cur:
379 n.append(i[1])
380 c.commit()
381 exp = Tk()
382 exp.title('EXPIRY CHECK')
383 Label(exp, text='Today : ' + str(now[2]) + '/' + str(now[1]) + '/' + str(now[0])).grid(row=0, column=0
384 columnspan=3)
385 Label(exp, text='Selling Expired Medicines and Drugs is Illegal').grid(row=1, column=0, columns
386 Label(exp, text='-' * 80).grid(row=2, column=0, columnspan=3)
387 s = Spinbox(exp, values=n)
388 s.grid(row=3, column=0)
389 Button(exp, text='Check Expiry date', bg='red', fg='white', command=s_exp).grid(row=3, column=
390 Label(exp, text='-' * 80).grid(row=4, column=0, columnspan=3)
391 if flags == 'apt1':
392 Button(exp, text='Main Menu', bg='green', fg='white', command=main_cus).grid(row=5, colum
393 else:
394 Button(exp, width=20, text='Check Products expiring', bg='red', fg='white', command=exp_dt).
395 column=0)
396 Button(exp, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=5, colu
397 exp.mainloop()
398
399
400 def s_exp():
401 global c, cur, s, exp, top
402 from datetime import date
403 now = time.localtime()
404 d1 = date(now[0], now[1], now[2])
405 cur.execute("select * from med")
406 for i in cur:
407 if (i[1] == s.get()):
408 q = i[6]
409 d2 = date(int('20' + q[8:10]), int(q[3:5]), int(q[0:2]))
410 if d1 > d2:
411 Label(exp, text='EXPIRED! on ' + i[6]).grid(row=3, column=2)
412 top = Tk()
413 Label(top, text='EXPIRED!').pack()
414 else:
415 Label(exp, text=i[6]).grid(row=3, column=2)
416 c.commit()
417
418
419 def exp_dt():
420 global c, cur, exp, top
421 x=0
422 z=1
423 from datetime import datetime, timedelta
424 N=7
425 dt = datetime.now() + timedelta(days=N)
426 d = str(dt)
427 from datetime import date
428 now = time.localtime()
429 d1 = date(now[0], now[1], now[2])
430 d3 = date(int(d[0:4]), int(d[5:7]), int(d[8:10]))
431 Label(exp, text='S.No' + ' ' + 'Name' + ' Qty. ' + 'Exp_date').grid(row=6, column=0, columns
432 cur.execute("select * from med")
433 for i in cur:
434 s = i[6]
435 d2 = date(int('20' + s[8:10]), int(s[3:5]), int(s[0:2]))
436
437 if d1 < d2 < d3:
438 Label(exp, text=str(z) + '. ' + str(i[1]) + ' ' + str(i[3]) + ' ' + str(i[6])).grid(row=x + 7,
439 column=0,
440 columnspan=2)
441 x += 1
442 z += 1
443 elif d1 > d2:
444 top = Tk()
445 Label(top, width=20, text=str(i[1]) + ' is EXPIRED!').pack()
446 c.commit()
447
448 #This function will simply work on displaying the billing winsow. We madeuse of variousbuttons as w
449 #The loogic for bill generation will be in the upcoming function.
450 def billing():

https://copyassignment.com/medical-store-management-system-project-in-python/ 7/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
451 global c, cur, apt, flag, t, name, name1, add, st, names, qty, sl, qtys, vc_id, n, namee, lb1
452 t=0
453 vc_id = ''
454 names = []
455 qty = []
456 sl = []
457 n = []
458 qtys = [''] * 10
459 cur.execute("select *from med")
460 for i in cur:
461 n.append(i[1])
462 c.commit()
463 if flag == 'st':
464 st.destroy()
465 else:
466 apt.destroy()
467 flag = 'st'
468 st = Tk()
469 st.title('BILLING SYSTEM')
470 Label(st, text='-' * 48 + 'BILLING SYSTEM' + '-' * 49).grid(row=0, column=0, columnspan=7)
471 Label(st, text='Enter Name: ').grid(row=1, column=0)
472 name1 = Entry(st)
473 name1.grid(row=1, column=1)
474 Label(st, text='Enter Address: ').grid(row=2, column=0)
475 add = Entry(st)
476 add.grid(row=2, column=1)
477 Label(st, text="Value Id (if available)").grid(row=3, column=0)
478 vc_id = Entry(st)
479 vc_id.grid(row=3, column=1)
480 Button(st, text='Check V.C.', bg='green', fg='white', command=blue).grid(row=4, column=0)
481 Label(st, text='-' * 115).grid(row=6, column=0, columnspan=7)
482 Label(st, text='SELECT PRODUCT', width=25, relief='ridge').grid(row=7, column=0)
483 Label(st, text=' RACK QTY LEFT COST ', width=25, relief='ridge').grid(row=7, column=1
484 Button(st, text='Add to bill', bg='blue', fg='white', width=15, command=append2bill).grid(row=8, c
485 Label(st, text='QUANTITY', width=20, relief='ridge').grid(row=7, column=5)
486 qtys = Entry(st)
487 qtys.grid(row=8, column=5)
488 refresh()
489 Button(st, width=15, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=1
490 Button(st, width=15, text='Refresh Stock', bg='skyblue', fg='black', command=refresh).grid(row=3
491 Button(st, width=15, text='Reset Bill', bg='red', fg='white', command=billing).grid(row=4, column=
492 Button(st, width=15, text='Print Bill', bg='orange', fg='white', command=print_bill).grid(row=5, colu
493 Button(st, width=15, text='Save Bill', bg='blue', fg='white', command=make_bill).grid(row=7, colu
494
495 st.mainloop()
496
497 #Whenever the stocs are added, there is a need to refresh the db. In order to do so, we made a ref
498
499 def refresh():
500 global cur, c, st, lb1, lb2, vsb
501
502 def onvsb(*args):
503 lb1.yview(*args)
504 lb2.yview(*args)
505
506 def onmousewheel():
507 lb1.ywiew = ('scroll', event.delta, 'units')
508 lb2.ywiew = ('scroll', event.delta, 'units')
509 return 'break'
510
511 cx = 0
512 vsb = Scrollbar(orient='vertical', command=onvsb)
513 lb1 = Listbox(st, width=25, yscrollcommand=vsb.set)
514 lb2 = Listbox(st, width=25, yscrollcommand=vsb.set)
515 vsb.grid(row=8, column=2, sticky=N + S)
516 lb1.grid(row=8, column=0)
517 lb2.grid(row=8, column=1)
518 lb1.bind('<MouseWheel>', onmousewheel)
519 lb2.bind('<MouseWheel>', onmousewheel)
520 cur.execute("select *from med")
521 for i in cur:
522 cx += 1
523 lb1.insert(cx, str(i[0]) + '. ' + str(i[1]))
524 lb2.insert(cx, ' ' + str(i[7]) + ' ' + str(i[3]) + ' PHP ' + str(i[4]))
525 c.commit()
526 lb1.bind('<<ListboxSelect>>', select_mn)
527
528
529 def select_mn(e):
530 global st, lb1, n, p, nm, sl1
531 p = lb1.curselection()
532 x=0
533 sl1 = ''
534 from datetime import date
535 now = time.localtime()
536 d1 = date(now[0], now[1], now[2])
537 cur.execute("select * from med")
538 for i in cur:
539 if x == int(p[0]):
540 sl1 = int(i[0])
541 break

https://copyassignment.com/medical-store-management-system-project-in-python/ 8/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
542 x += 1
543 c.commit()
544 print(sl1)
545 nm = n[x]
546 print(nm)
547
548
549 def append2bill():
550 global st, names, nm, qty, sl, cur, c, sl1
551 sl.append(sl1)
552 names.append(nm)
553 qty.append(qtys.get())
554 print(qty)
555 print(sl[len(sl) - 1], names[len(names) - 1], qty[len(qty) - 1])
556
557
558 def blue():
559 global st, c, cur, named, addd, t, vc_id
560 cur.execute("select * from cus")
561 for i in cur:
562 if vc_id.get() != '' and int(vc_id.get()) == i[2]:
563 named = i[0]
564 addd = i[1]
565 Label(st, text=named, width=20).grid(row=1, column=1)
566 Label(st, text=addd, width=20).grid(row=2, column=1)
567 Label(st, text=i[2], width=20).grid(row=3, column=1)
568 Label(st, text='Valued Customer!').grid(row=4, column=1)
569 t=1
570 break
571 c.commit()
572
573 #A bill is made in the form of text file. Wdeveloped this function in order to make bills
574 def make_bill():
575 global t, c, B, cur, st, names, qty, sl, named, addd, name1, add, det, vc_id
576 price = [0.0] * 10
577 q=0
578 det = ['', '', '', '', '', '', '', '']
579 det[2] = str(sl)
580 for i in range(len(sl)):
581 print(sl[i], ' ', qty[i], ' ', names[i])
582 for k in range(len(sl)):
583 cur.execute("select * from med where sl_no=?", (sl[k],))
584 for i in cur:
585 price[k] = int(qty[k]) * float(i[4])
586 print(qty[k], price[k])
587 #All the medicines that are taken along with its quanity are added in the bill using this query
588 cur.execute("update med set qty_left=? where sl_no=?", (int(i[3]) - int(qty[k]), sl[k]))
589 c.commit()
590 det[5] = str(random.randint(100, 999))
591 B = 'bill_' + str(det[5]) + '.txt'
592 total = 0.00
593 for i in range(10):
594 if price[i] != '':
595 total += price[i] # totalling
596 m = '\n\n\n'
597 m += "===============================================\n"
598 m += " No :%s\n\n" % det[5]
599 m += " MEDICAL STORE COMPANY\n"
600 m += " CopyAssignment Project of Medical Store Management System\n\n"
601 m += "-------------------------- ---------------------\n"
602 if t == 1:
603 m += "Name: %s\n" % named
604 m += "Address: %s\n" % addd
605 det[0] = named
606 det[1] = addd
607 cur.execute('select * from cus')
608 for i in cur:
609 if i[0] == named:
610 det[7] = i[2]
611 else:
612 m += "Name: %s\n" % name1.get()
613 m += "Address: %s\n" % add.get()
614 det[0] = name1.get()
615 det[1] = add.get()
616 m += "-----------------------------------------------\n"
617 m += "Product Qty. Price\n"
618 m += "-----------------------------------------------\n"
619 for i in range(len(sl)):
620 if names[i] != 'nil':
621 s1 = ' '
622 s1 = (names[i]) + (s1 * (27 - len(names[i]))) + s1 * (3 - len(qty[i])) + qty[i] + s1 * (
623 15 - len(str(price[i]))) + str(price[i]) + '\n'
624 m += s1
625 m += "\n-----------------------------------------------\n"
626 if t == 1:
627 ntotal = total * 0.8
628 m += 'Total' + (' ' * 25) + (' ' * (15 - len(str(total)))) + str(total) + '\n'
629 m += "Valued customer Discount" + (' ' * (20 - len(str(total - ntotal)))) + '-' + str(total - ntotal) + '
630 m += "-----------------------------------------------\n"
631 m += 'Total' + (' ' * 25) + (' ' * (12 - len(str(ntotal)))) + 'PHP ' + str(ntotal) + '\n'
632 det[3] = str(ntotal)

https://copyassignment.com/medical-store-management-system-project-in-python/ 9/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
633 else:
634 m += 'Total' + (' ' * 25) + (' ' * (12 - len(str(total)))) + 'PHP ' + str(total) + '\n'
635 det[3] = str(total)
636
637 m += "-----------------------------------------------\n\n"
638 m += "Dealer 's signature:___________________________\n"
639 m += "===============================================\n"
640 print(m)
641 p = time.localtime()
642 det[4] = str(p[2]) + '/' + str(p[1]) + '/' + str(p[0])
643 det[6] = m
644 bill = open(B, 'w')
645 bill.write(m)
646 bill.close()
647 cb = ('cus_name', 'cus_add', 'items', 'Total_cost', 'bill_dt', 'bill_no', 'bill', 'val_id')
648 cur.execute('insert into bills values(?,?,?,?,?,?,?,?)',
649 (det[0], det[1], det[2], det[3], det[4], det[5], det[6], det[7]))
650 c.commit()
651
652
653 def print_bill():
654 win32api.ShellExecute(0, "print", B, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
655
656
657 def show_rev():
658 global c, cur, flag, rev
659 apt.destroy()
660 cb = ('cus_name', 'cus_add', 'items', 'Total_cost', 'bill_dt', 'bill_no', 'bill', 'val_id')
661 flag = 'rev'
662 rev = Tk()
663 total = 0.0
664 today = str(time.localtime()[2]) + '/' + str(time.localtime()[1]) + '/' + str(time.localtime()[0])
665 Label(rev, text='Today: ' + today).grid(row=0, column=0)
666 cur.execute('select * from bills')
667 for i in cur:
668 if i[4] == today:
669 total += float(i[3])
670 print(total)
671 Label(rev, width=22, text='Total revenue: PHP ' + str(total), bg='blue', fg='white').grid(row=1, colu
672 cx = 0
673 vsb = Scrollbar(orient='vertical')
674 lb1 = Listbox(rev, width=25, yscrollcommand=vsb.set)
675 vsb.grid(row=2, column=1, sticky=N + S)
676 lb1.grid(row=2, column=0)
677 vsb.config(command=lb1.yview)
678 cur.execute("select * from bills")
679 for i in cur:
680 if i[4] == today:
681 cx += 1
682 lb1.insert(cx, 'Bill No.: ' + str(i[5]) + ' : PHP ' + str(i[3]))
683 c.commit()
684 Button(rev, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=15, colum
685 rev.mainloop()
686
687 #The functionality to search for medicnes is made possible through this function
688 def search():
689 global c, cur, flag, st, mn, sym, flags
690 flag = 'st'
691 apt.destroy()
692 cur.execute("Select * from med")
693 symp = ['nil']
694 med_name = ['nil']
695 for i in cur:
696 symp.append(i[5])
697 med_name.append(i[1])
698 st = Tk()
699 st.title('SEARCH')
700 Label(st, bg='green', fg='white', text=' SEARCH FOR MEDICINE ').grid(row=0, column=0, colum
701 Label(st, text='~' * 40).grid(row=1, column=0, columnspan=3)
702 Label(st, text='Symptom Name').grid(row=3, column=0)
703 sym = Spinbox(st, values=symp)
704 sym.grid(row=3, column=1)
705 Button(st, width=15, text='Search', bg='blue', fg='white', command=search_med).grid(row=3, col
706 Label(st, text='-' * 70).grid(row=4, column=0, columnspan=3)
707 if flags == 'apt1':
708 Button(st, width=15, text='Main Menu', bg='green', fg='white', command=main_cus).grid(row=6
709 else:
710 Button(st, width=15, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row
711 st.mainloop()
712
713
714 def search_med():
715 global c, cur, st, sym, columns
716 cur.execute("select * from med")
717 y = []
718 x=0
719 for i in cur:
720 if i[5] == sym.get():
721 y.append(
722 str(i[0]) + '. ' + str(i[1]) + ' PHP ' + str(i[4]) + ' Rack : ' + str(i[7]) + ' Mfg : ' + str(
723 i[8]))

https://copyassignment.com/medical-store-management-system-project-in-python/ 10/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
724 x=x+1
725 top = Tk()
726 for i in range(len(y)):
727 Label(top, text=y[i]).grid(row=i, column=0)
728 Button(top, text='OK', command=top.destroy).grid(row=5, column=0)
729 c.commit()
730 top.mainloop()
731
732 #Adding the customer details is handles by this fuhction.
733 def val_cus():
734 global val, flag, dbt, name_vc, add_vc, cur, c, vc_id
735 apt.destroy()
736 cur.execute("select * from cus")
737 flag = 'val'
738 val = Tk()
739 Label(val, bg='blue', fg='white', text="****ENTER VALUED CUSTOMER DETAILS****").grid(row=
740 Label(val, text="-" * 60).grid(row=1, column=0, columnspan=3)
741 Label(val, text="Name: ").grid(row=2, column=0)
742 name_vc = Entry(val)
743 name_vc.grid(row=2, column=1)
744 Label(val, text="Address: ").grid(row=3, column=0)
745 add_vc = Entry(val)
746 add_vc.grid(row=3, column=1)
747 Label(val, text="Value Id: ").grid(row=4, column=0)
748 vc_id = Entry(val)
749 vc_id.grid(row=4, column=1)
750 Button(val, text='Submit', bg='blue', fg='white', command=val_get).grid(row=5, column=1)
751 Button(val, text='Main Menu', bg='green', fg='white', command=main_menu).grid(row=5, column
752 Label(val, text='-' * 60).grid(row=6, column=0, columnspan=3)
753 val.mainloop()
754
755
756 def val_get():
757 global name_vc, add_vc, val, dbt, c, cur, apt, vc_id
758 cur.execute("insert into cus values(?,?,?)", (name_vc.get(), add_vc.get(), vc_id.get()))
759 l.execute("insert into log values(?,?)", (name_vc.get(), vc_id.get()))
760 cur.execute("select * from cus")
761 for i in cur:
762 print(i[0], i[1], i[2])
763 c.commit()
764 login.commit()
765
766 #This fucntion works for the home window.
767 #The authentication of the user is done here.
768 def again():
769 global un, pwd, flag, root, apt
770 if flag == 'apt':
771 apt.destroy()
772 root = Tk()
773 root.geometry('720x400')
774 root.title('CopyAssignment')
775 Label(root, text="CopyAssignment", font=('ariel', 45, ), fg='blue').grid(row=3, column=1)
776 Label(root, text="MEDICAL STORE MANAGEMENT", font=('ariel', 25, ), fg='red').grid(row=4, col
777 Label(root, text="Easily manage all your medicines", font=('ariel', 17, ), fg='green').grid(row=5, co
778
779 Label(root, text='----------------------------------------------------------', font=('ariel', 15, ),).grid(row=7, col
780 Label(root, text='Username',font=('ariel', 15, ),).grid(row=8, column=0)
781 un = Entry(root, width=30)
782 un.grid(row=8, column=1)
783 Label(root, text='Password', font=('ariel', 15, ),).grid(row=9, column=0)
784 pwd = Entry(root, width=30)
785 pwd.grid(row=9, column=1)
786 Button(root, width=6, bg='green', fg='white', text='Enter', font=('ariel', 15, ),command=check).grid
787 Button(root, width=6, bg='red', fg='white', text='Close', font=('ariel', 15, ),command=root.destroy)
788
789
790 root.mainloop()
791
792 #This is to check the credentials of the user. If the credentials are wrong that simply all the widgets
793 def check():
794 global un, pwd, login, l, root
795 u = un.get()
796 p = pwd.get()
797 l.execute("select * from log")
798 for i in l:
799 if i[0] == u and i[1] == p and u == 'admin':
800 root.destroy()
801 open_win()
802 elif i[0] == u and i[1] == p:
803 root.destroy()
804 open_cus()
805 login.commit()
806
807
808 def main_menu():
809 global sto, apt, flag, root, st, val, exp, st1, rev
810 if flag == 'sto':
811 sto.destroy()
812 if flag == 'rev':
813 rev.destroy()
814 elif flag == 'st':

https://copyassignment.com/medical-store-management-system-project-in-python/ 11/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
815 st.destroy()
816 elif flag == 'st1':
817 st1.destroy()
818 elif flag == 'val':
819 val.destroy()
820 elif flag == 'exp':
821 exp.destroy()
822 elif flag == 'd':
823 d.destroy()
824 open_win()
825
826
827 def main_cus():
828 global st, flag, exp
829 if flag == 'exp':
830 exp.destroy()
831 elif flag == 'st':
832 st.destroy()
833 open_cus()
834
835
836 def open_cus():
837 global apt, flag, flags
838 flags = 'apt1'
839 apt = Tk()
840 apt.title("Interface")
841 Label(apt, text="*** MEDICAL DRUG STORE ***", bg='blue', fg='white').grid(row=0, column=0)
842 Label(apt, text='*' * 40).grid(row=1, column=0)
843 Label(apt, text='* WELCOME CUSTOMER SERVICES *', bg='green', fg='white').grid(row=2, co
844 Label(apt, text='-' * 40).grid(row=3, column=0)
845
846 Label(apt, text='-' * 40).grid(row=5, column=0)
847 Button(apt, text='Search', bg='blue', fg='white', width=15, command=search).grid(row=6, column
848 Button(apt, text='Expiry Check', bg='red', fg='white', width=15, command=exp_date).grid(row=7,
849
850 Label(apt, text='-' * 40).grid(row=8, column=0)
851 Button(apt, text='Logout', bg='green', fg='white', command=again1).grid(row=9, column=0)
852 apt.mainloop()
853
854

Output for Medical Store Management


System Project in Python:

https://copyassignment.com/medical-store-management-system-project-in-python/ 12/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment

View PDF (Free) Download PDF Connect AI Models

Ad Easy PDF Manuals Ad EasySmartPDF Ad aixplain.com

Reference Materials and Links

Files
Below are the two database files that will basically store all the data of your
medicines. You simply have to put these two files in the same folder where you put
your main.py file (the above code file)

Links
Beginners to Advanced Tkinter Projects: List of projects

https://copyassignment.com/medical-store-management-system-project-in-python/ 13/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
Tkinter Tutorials: Click here
SQLite Tutorials: Click here
Tkinter Documentation: Tkinter Official Docs
SQLite Documentation: SQLite Official Docs

Summary

We made an effort to describe every aspect of the Medical Store Management


System Project in Python. Building Python projects is the only way to comprehend
Python’s numerous concepts and libraries, in our opinion at CopyAssignments.
Continue to learn, act, and develop until you have another lesson to share. We
appreciate you visiting our website.

Best 100+ Python Projects with source code

Also Read:

Create your own ChatGPT SQLite | CRUD Operations Event Management System
with Python in Python Project in Python

Ticket Booking and Hostel Management Sales Management System


Management in Python System Project in Python Project in Python

Bank Management System Python Download File from Python Programming


Project in C++ URL | 4 Methods Examples | Fundamental
Programs in Python

Spell Checker in Python Portfolio Management Stickman Game in Python


System in Python

Contact Book project in Loan Management System Cab Booking System in


Python Project in Python Python

Brick Breaker Game in Tank game in Python GUI Piano in Python


Python

Ludo Game in Python Rock Paper Scissors Game Snake and Ladder Game in
in Python Python

Puzzle Game in Python Medical Store Management Creating Dino Game in


System Project in Python Python

Tic Tac Toe Game in Test Typing Speed using Scientific Calculator in
Python Python App Python

GUI To-Do List App in Scientific Calculator in GUI Chat Application in


Python Tkinter Python using Tkinter Python Tkinter

Share:       

Author: Ayush Purawr

https://copyassignment.com/medical-store-management-system-project-in-python/ 14/15
11/9/24, 6:42 PM Medical Store Management System Project In Python - CopyAssignment
← Restaurant Management System Project in Java Best JavaScript Roadmap for Beginners 2023 →

© Copyright 2019-2024 www.copyassignment.com. All rights reserved. Developed by copyassignment

https://copyassignment.com/medical-store-management-system-project-in-python/ 15/15

You might also like