0% found this document useful (0 votes)
7 views22 pages

Pharmacy

The document outlines a project on a Pharmacy Management System developed by Yuvraj Singh Bisht and Sajan Kumar for the academic session 2024-2025. It includes a certificate of completion, acknowledgments, required hardware and software, an introduction to the system's objectives and features, Python source code, MySQL database structure, and references. The system aims to streamline pharmacy inventory management through an intuitive interface and automated record-keeping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views22 pages

Pharmacy

The document outlines a project on a Pharmacy Management System developed by Yuvraj Singh Bisht and Sajan Kumar for the academic session 2024-2025. It includes a certificate of completion, acknowledgments, required hardware and software, an introduction to the system's objectives and features, Python source code, MySQL database structure, and references. The system aims to streamline pharmacy inventory management through an intuitive interface and automated record-keeping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

CS Project File

Topic : Pharmacy Management System


Session (2024-2025)
Submitted by : Yuvraj Singh Bisht
Roll no :- 12141
And Sajan Kumar
Roll no :- 12145
CERTIFICATE
This is to certify that (SAJAN KUMAR AND YUVRAJ
SINGH BISHT) of Class XII A of SARVODAYA CO-ED
SENIOR SECONDARY SCHOOL has done his project on
PHARMACY MANAGEMENT SYSTEM under my
supervision. He has taken interest and has shown at
most sincerity in completion of this project. I certify this
project up to my expectation & as per guidelines issued
by CBSE, NEW DELHI.

Internal Examiner External Examiner

Principal
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my sincere
gratitude to our teacher MR. LOKENDRA SOLANKI
(PGT CS) who taught and undertook the
responsibility of teaching the subject computer
science. I have greatly benefited from his classes.
I am especially indebted to our Principal MR. AMIT
PANDYA who has always been a source of
encouragement and support and without whose
inspiration this project would not have been a
successful I would like to place on record heartfelt
thanks to him.

Finally, I would like to express my sincere


appreciation for all the other students in my batch,
their friendship & the fine time that we all shared
together.
HARDWARES AND
SOFTWARES REQUIRED

HARDWARES
1. Desktop Computer / Laptop
2. Mobile Phone

SOFTWARES
1. Python (latest version)
2. MySQL
3. Python connector module
4. tkinter module
5. tkbootstrap module
CONTENTS
S.NO TOPICs
1. Certificate
2. Acknowledgement
3. Hardware and Software required
4. Introduction
5. Python Source Code
6. MySQL Database
7. Outputs
8. References
INTRODUCTION
The Pharmacy Management System is a
comprehensive software application designed to
streamline the management of medicines in a
pharmacy. This project focuses on providing an
efficient, user-friendly interface for handling
essential operations such as adding new
medicines, viewing the inventory, searching for
specific medicines, and deleting outdated or
unwanted records. The system leverages Python
for backend processing, Tkinter for the graphical
user interface (GUI), and MySQL for robust
database management.
Objectives
The primary objective of this project is to facilitate
easy and accurate management of a pharmacy's
inventory. It aims to:
1. Automate Record-Keeping: Replace manual
tracking of medicine inventory with an organized
and searchable database.
2. Enhance Efficiency: Reduce time spent on
administrative tasks such as adding, searching, or
deleting medicines.
3. Improve Accuracy: Minimize errors
associated with manual record management.
4. Simplify Interaction: Provide a clean,
intuitive interface that requires minimal training to
use.
Features
1. Add Medicines: Users can add details of new
medicines, including name, company, quantity,
and price.
2. View Medicines: Displays a list of all
medicines stored in the database.
3. Search Medicines: Users can search for
medicines by name.
4. Delete Medicines: Allows users to delete
specific medicine records.
5. Responsive Design: Built with
ttkbootstrap for a modern and consistent
UI theme.
Code Structure
● Database Connection: The connect_to_db
function ensures seamless communication with
the MySQL database.

● Functionality Implementation: Each


operation (Add, View, Search, Delete) is
implemented as a separate function for
modularity and readability.

● Error Handling: Proper error handling


ensures that database errors and invalid inputs
are gracefully managed.

● GUI Design: The Tkinter interface includes


labeled fields, buttons, and a list display for user
interaction.
PYTHON
SOURCE
CODE
1. import mysql.connector

2. from tkinter import *

3. from tkinter import messagebox

4. import ttk bootstrap as ttk

5. # Database Connection

6. def connect_to_db():

7. return mysql.connector.connect(

8. host = "localhost", # Change to your MySQL server host

9. user = "root", # Your MySQL username

10. password = "sajan", # Your MySQL password

11. database = "pharmacy_db" )

12.

13. # Add Medicine

14. def add_medicine():

15. name = entry_name.get()

16. company = entry_company.get()

17. quantity = entry_quantity.get()

18. price = entry_price.get()

19.

20. if not (name and company and quantity and price):

21. messagebox.showerror("Error", "All fields are


required!")

22. return

23.
24. try:

25. db = connect_to_db()

26. cursor = db.cursor()

27. cursor.execute("INSERT INTO medicines (name,


company, quantity, price) VALUES (%s, %s, %s, %s)",

28. (name, company, quantity, price))

29. db.commit()

30. messagebox.showinfo("Success", "Medicine added


successfully!")

31. db.close()

32. clear_entries()

33. view_medicines()

34. except mysql.connector.Error as e:

35. messagebox.showerror("Database Error", str(e))

36.

37. # View Medicines

38. def view_medicines():

39. try:

40. db = connect_to_db()

41. cursor = db.cursor()

42. cursor.execute("SELECT * FROM medicines")

43. rows = cursor.fetchall()

44. db.close()

45.
46. listbox.delete(0, END)

47. for row in rows:

48. listbox.insert(END, row)

49. except mysql.connector.Error as e:

50. messagebox.showerror("Database Error", str(e))

51.

52.

53. # Search Medicine

54. def search_medicine():

55. search_query = entry_search.get()

56.

57. if not search_query:

58. messagebox.showerror("Error", "Search field is


empty!")

59. return

60.

61. try:

62. db = connect_to_db()

63. cursor = db.cursor()

64. cursor.execute("SELECT * FROM medicines WHERE name


LIKE %s", ('%' + search_query + '%',))

65. rows = cursor.fetchall()

66. db.close()

67.
68. listbox.delete(0, END)

69. for row in rows:

70. listbox.insert(END, row)

71. except mysql.connector.Error as e:

72. messagebox.showerror("Database Error", str(e))

73.

74.

75. # Delete Medicine

76. def delete_medicine():

77. selected_item = listbox.curselection()

78. if not selected_item:

79. messagebox.showerror("Error", "No medicine


selected!")

80. return

81. medicine_id = listbox.get(selected_item)[0]

82.

83. try:

84. db = connect_to_db()

85. cursor = db.cursor()

86. cursor.execute("DELETE FROM medicines WHERE id =


%s", (medicine_id,))

87. db.commit()

88. db.close()

89. messagebox.showinfo("Success", "Medicine deleted


successfully!")
90. view_medicines()

91. except mysql.connector.Error as e:

92. messagebox.showerror("Database Error", str(e))

93.

94.

95. # Clear Entries

96. def clear_entries():

97. entry_name.delete(0, END)

98. entry_company.delete(0, END)

99. entry_quantity.delete(0, END)

100. entry_price.delete(0, END)

101. entry_search.delete(0, END)

102.

103.

104. # Tkinter GUI

105. root = Tk()

106. style = ttk.Style('solar')

107. root.title("Pharmacy Management System")

108.

109. # Input Fields

110. Label(root, text="Medicine Name").grid(row = 0, column = 0,


padx = 10, pady = 5)

111. entry_name = Entry(root)

112. entry_name.grid(row = 0, column = 1, padx = 10, pady = 5)


113.

114. Label(root, text="Company").grid(row = 1, column = 0, padx =


10, pady = 5)

115. entry_company = Entry(root)

116. entry_company.grid(row = 1, column = 1, padx = 10, pady = 5)

117. Label(root, text="Quantity").grid(row = 2, column = 0, padx


= 10, pady = 5)

118. entry_quantity = Entry(root)

119. entry_quantity.grid(row = 2, column = 1, padx = 10, pady =


5)

120.

121. Label(root, text="Price").grid(row = 3, column = 0, padx =


10, pady = 5)

122. entry_price = Entry(root)

123. entry_price.grid(row = 3, column = 1, padx = 10, pady = 5)

124. # Buttons

125. Button(root, text="Add Medicine",


command=add_medicine).grid(row = 4, column = 0, padx = 10, pady =
5)

126. Button(root, text="View Medicines",


command=view_medicines).grid(row = 4, column = 1, padx = 10, pady
= 5)

127. Button(root, text="Search",


command=search_medicine).grid(row = 5, column = 0, padx = 10,
pady = 5)
128. Button(root, text="Delete Medicine",
command=delete_medicine).grid(row = 5, column = 1, padx = 10,
pady = 5)

129. Label(root, text="Search by Name").grid(row = 6, column = 0,


padx = 10, pady = 5)

130. entry_search = Entry(root)

131. entry_search.grid(row = 6, column = 1, padx = 10, pady = 5)

132. # Listbox

133. listbox = Listbox(root, width = 50)

134. listbox.grid(row = 7, column = 0, columnspan = 2, padx = 10,


pady = 5)

135. # Start the GUI

136. view_medicines()

137. root.mainloop()
MYSQL
DATABASE
MySQL database with a table
structure:
CREATE TABLE medicines (id INT AUTO_INCREMENT
PRIMARY KEY,name VARCHAR(255),company
VARCHAR(255), quantity INT,price float);

MEDICINE TABLE
OUTPUTS
REFERENCES
1. GITHUB

2. Geeks for Geeks - https://www.geeksforgeeks.org

3. Preeti Arora Book Class 11

4. Preeti Arora Book Class 12

You might also like