Python - Fancystore System (1)
Python - Fancystore System (1)
SYNOPSI
S
PGDCA 2nd sem
INDEX
Main Report
Objectives & Scope of the project
Theoretical Background of Project
Definition of problem
System Analysis & Design
System Planning (PERT Chart)
Methodology adopted, system Implementation & Detail of Hardware
& Software used.
System maintenance & Evaluation.
Cost and benefit Analysis
Detailed Life Cycle of the project
ERD,DFD
Input and Output Screen Design
Process involved
Methodology used for testing
Test Report, Printout of the code sheet
User/Operational Manual- including security aspects, access rights,
back up, Controls etc.
Conclusion
References
Soft copy of the project on CD
PGDCA 2nd sem
MAIN REPORT
PGDCA 2nd sem
There are so many disadvantages in the existing system because they want to a
log of paper work in the system and many people engage to maintain of the system.
But the technology is growing fatly and researches a new technology.
So the cost of the control is very less and we also find previous information in a
few seconds on the computerization by this Software. It improve efficiency of their
bill according to the customer satisfaction.
The major objective for implementing a computerized Sofware in an organization
is:-
To manage the resources of the Stock efficiently.
To reduce the losses incurred due to wrong entries.
To manage the Customer/member data in a proper manner.
Also, manage the asset.
To maintain the daily expense in efficient manner.
Preparation of various analysis reports.
Generation of report that help management for making effective and
timely decisions.
Tracking: Tracking the progress of your projects and programs is important for the
long term success of your business. A project management software system will give
you the visibility to see if a project is running to its predetermined time frame, what
has been done and what still needs to be complete. The software reduces the need for
paper or electronic updates from the project team members to their project manager.
Resourcing: The project management system ensures that the optimal resources are
working on the right projects by examining the level of skills and abilities needed to
successfully complete the project. Assigning resources to tasks or projects through the
project management system will ensure that each resource knows all the information
needed for them to complete the project.
Financial Control: A critical item in the management of projects is the budget and
the way in which the budget is managed could ultimately decide the future of the
business. The project management software gives the project manager a visual on the
project costs, project budget (actual Vs planned), project cost data etc to ensure that
projects and programs run to their assigned budgets, money is ultimately saved and
not lost and generating a clear Return on Investment (ROI) on all projects.
PGDCA 2nd sem
Where are we now?: A PM software solution can easily tell an organization if they are
in line with their initial requirements by taking a snapshot of the project at that point
in time and examining some of the following:
Who is working on each task or project
Is there any time delays
Is the project keeping to its budget etc
Decision Making: When making a decision in project management all aspects of the
project need to be taken into consideration. By using a project management system the
decision making process is improved, as the information is all in clearly presented in
one place.
The Edge: By having a project management system in place it could ultimately give
you a competitive edge over your competitors. If you can complete a project more
efficiently than the rest you it can give you that extra push ahead of your competitors.
Risk management: Out of nowhere a risk can throw a spanner in the works and cause
severe problems resulting in the project failing. Project management software system
can give you a platform by which risks can be flagged, tracked and correctly resolved
to ensure that the risk has the lowest possible negative effect on the project.
Keeping the boss happy: Ok this won’t provide the company with benefits however
it will give you some peace and reassurance at your next meeting with the boss. The
project management system provides you with all the tools to help your project come
in on time and too budget keeping all involved happy.
.USER INFORMATION:
o The project is designed in such a manner that it can provide all the detail
information of USERS
DATABASE INFORMATION
o This project is designed in such a manner that it can provide all the detail
information of record of database.
REPORT GENERATION:
o This project is designed to provide us various Summary and detailed
report of stored data we can also filter our report using various filter.
PGDCA 2nd sem
The scope of the project includes that what all future enhancements can be done in this
system to make it more feasible to use :
Databases for different products range and storage can be provided.
Multilingual support can be provided so that it can be understandable by the
person of any language.
More graphics can be added to make it more user- friendly and
understandable.
Manage and backup versions of documents online.
Scope creep management is important for effective project management. Projects are
expected to meet strict deadlines with resource restraints, and an unvetted and
unapproved change in the scope can affect the success of the project. Scope creep
sometimes causes cost overrun.
Scope creep is a term which refers to the incremental expansion of the scope of a
project, which may include and introduce more requirements that may not have been a
part of the initial planning of the project, while nevertheless failing to adjust schedule
and budget. There are two distinct ways to separate scope creep management. The
first is business scope creep, and the second is called features (also technology)
scope creep. The type of scope creep management is always dependent on the people
who create the changes.
Business scope creep occurs when decisions that are made with reference to a project
are designed to solve or meet the requirements and needs of the business. Business
scope creep changes may be a result of poor requirements definition early in
development, or the failure to include the users of the project until the later stage of
the systems development life cycle. Management system. Items deemed out of scope
go directly through the change control process and are not automatically added to the
project work items. The Project Scope Management plan is included in as one of the
sections in the overall Project Management plan. It can be very detailed and formal or
loosely framed and informal depending on the communication needs of the project.
Features (Technology) scope creep occurs when the scope creep is introduced by
technologists adding features not originally contemplated. Customer-pleasing scope
creep occurs when the desire to please the customer through additional product
features adds more work to the current project rather than to a new project proposal.
Gold- plating scope creep occurs when technologists augment the original
requirements
PGDCA 2nd sem
because of a bias toward "technical perfectionism" or because the initial requirements
were insufficiently clear or detailed.
PGDCA 2nd sem
PYTHON
Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics. Its high-level built in data structures, combined with dynamic typing and
dynamic binding, make it very attractive for Rapid Application Development, as well as
for use as a scripting or glue language to connect existing components together.
Python's simple, easy to learn syntax emphasizes readability and therefore reduces the
cost of program maintenance. Python supports modules and packages, which
encourages program modularity and code reuse. The Python interpreter and the
extensive standard library are available in source or binary form without charge for all
major platforms, and can be freely distributed.
Often, programmers fall in love with Python because of the increased productivity it provides. Since
there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is
easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers
an error, it raises an exception. When the program doesn't catch the exception, the interpreter prints a
stack trace. A source level debugger allows inspection of local and global variables, evaluation of
arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The
debugger is written in Python itself, testifying to Python's introspective power. On the other hand, often
the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-
debug cycle makes this simple approach very effective.
PGDCA 2nd sem
BACK END (MY SQL)
Structured query language (SQL) is a programming language for storing and processing
information in a relational database. A relational database stores information in tabular form,
with rows and columns representing different data attributes and the various relationships
between the data values. You can use SQL statements to store, update, remove, search, and
retrieve information from the database. You can also use SQL to maintain and optimize
database performance.
PGDCA 2nd sem
DEFINITION OF PROBLEM
As we know manual system are quite tedious, time consuming and less
efficient and accurate in comparison to the computerized system. So
following are some advantages of the old system:
1. Time consuming
2. Less accurate
3. Less efficient
4. Lots of paper work
5. Slow data processing
6. Not user friendly environment
7. Difficult to keep old records
PGDCA 2nd sem
SYSTEM ANALYSIS
AND
DESIGN
PGDCA 2nd sem
FEASIBILITY STUDY:-
The proposed system has technical capacity of required to hold the data.
This project is efficient and responds quickly for various enquires
regardless
Of number of locations.
The system proposed could be expanded easily and Efficiency,
whenever required.
PERT CHART
PGDCA 2nd sem
HARDWARE USED:-
SOFTWARE USED:-
Design. Software design is actually a multiuse process that focuses on four distinct
attributes of a program: data structure, software architecture, interface representations,
and procedural (algorithmic) detail. The design process translates requirements into a
representation of the software that can be assessed for quality before coding begins.
Like requirements, the design is documented and becomes part of the software
configuration.
Testing. Once code has been generated, program testing begins. The testing process
focuses on the logical internals of the software, ensuring that all statements have been
tested, and on the functional externals; that is, conducting tests to uncover errors and
ensure that defined input will produce actual results that agree with required results.
ER DIAGRAM
PGDCA 2nd sem
E-R DIAGRAM
Available_qty
ID
Stock
Bill_no
Order_no
Total amt
Date
qty
Sale
qty
Purchase
billDate
Total amt
Customer
Vender
ID ph
C_name ID Ph_no
Name
PGDCA 2nd sem
PGDCA 2nd sem
PGDCA 2nd sem
CUSTOMER
stockb Detail
CUSTOMERTBL
SALE to customer
Pay BILL
Print Bill
PGDCA 2nd sem
Login Form
PROCESS INVOLVED
WaterFall Model:The stages of “The Waterfall Model” are:
SOURCE CODE
def drawHeadFrame():
global mainFrame
headerFrame = Frame(mainFrame, bg="#c5717f")
headerFrame.pack(side=TOP, fill=X)
titleFrame = Frame(headerFrame, bg="#c5717f")
titleFrame.pack(side=LEFT)
Label(titleFrame, text="Fancy Store", font=("Harrington", 24, "bold"), fg=
"pink",bg="#c5717f").pack(side=LEFT, padx=(8,0))
btnFrame = Frame(headerFrame, bg="#c5717f", pady=4)
btnFrame.pack(side=TOP)
Button(btnFrame, cursor="hand2", text="Home", command=lambda:HomeScreen(),
bg="#a5315f", fg="white", padx=14, pady=4).pack(side=LEFT,padx=6, pady=4)
Button(btnFrame, cursor="hand2", text="Stock Entry", command=lambda:StockEntry(),
bg="#a5315f", fg="white", padx=14, pady=4).pack(side=LEFT,padx=6, pady=4)
Button(btnFrame, cursor="hand2", text="Customer Entry",
command=lambda:CustomerEntry(), bg="#a5315f", fg="white", padx=14,
pady=4).pack(side=LEFT,padx=6, pady=4)
Button(btnFrame, cursor="hand2", text="Sales Entry", command=lambda:SalesEntry(),
bg="#a5315f", fg="white", padx=14, pady=4).pack(side=LEFT,padx=6, pady=4)
Button(btnFrame, cursor="hand2", text="Logout", command=lambda:FancyStoreLogin(),
bg="red", fg="white", padx=14, pady=4).pack(side=LEFT,padx=6, pady=4)
class HomeScreen:
productCount = -1
lowProducts = []
customerCount = -1
salesCount = -1
activeCustomers = -1
def __init__(self):
global mainFrame
if(mainFrame and isinstance(mainFrame, Frame)):
mainFrame.destroy()
self.showHomeScreen()
def showHomeScreen(self):
global mainFrame
self.getSats()
mainFrame = Frame(root, bg=bgcolor)
mainFrame.pack(fill=BOTH, expand=True)
drawHeadFrame()
homeFrame = Frame(mainFrame, bg=bgcolor)
PGDCA 2nd sem
homeFrame.pack(side=TOP)
Label(homeFrame, text="Welcome, Admin", font=("Helvetica", 12, "underline",
"bold"),bg=bgcolor).pack(pady=8)
Label(homeFrame, text="Shop Stats:", font=("Helvetica", 11, "underline",
"bold"),bg=bgcolor).pack(pady=8)
statFrame = Frame(homeFrame, bg=bgcolor)
statFrame.pack()
Label(statFrame, text=f"{self.productCount} Products in store",
font=("Helvetica", 11),bg=bgcolor).grid(row=0,column=0, pady=8, columnspan=2)
Label(statFrame, text=f"{len(self.lowProducts)} products low in stock",
font=("Helvetica", 11),bg=bgcolor).grid(row=1,column=0, pady=8, sticky="e")
#Button(statFrame, cursor="hand2",
text="View",bg=bgcolor,fg="blue",font=("Helvetica", 10, "underline"),
relief=FLAT).grid(row=1, column=1, sticky="w")
Label(statFrame, text=f"{self.customerCount} registered customers",
font=("Helvetica", 11),bg=bgcolor).grid(row=2,column=0, pady=8, columnspan=2)
Label(statFrame, text=f"{self.salesCount} sales made till now",
font=("Helvetica", 11),bg=bgcolor).grid(row=3,column=0, pady=8, columnspan=2)
Label(statFrame, text=f"{self.activeCustomers} of {self.customerCount} customers
have bought from the shop", font=("Helvetica", 11),bg=bgcolor).grid(row=4,column=0,
pady=8, columnspan=2)
def getSats(self):
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "select count(id) from products"
cursor.execute(query)
count = cursor.fetchone()
self.productCount = count[0]
query = "select * from products where qty < 10"
cursor.execute(query)
self.lowProducts = cursor.fetchall()
query = "select distinct(billno) from sales"
cursor.execute(query)
self.salesCount = len(cursor.fetchall())
query = "select distinct(customer_id) from sales"
cursor.execute(query)
self.activeCustomers = len(cursor.fetchall())
query = "select count(id) from customer"
cursor.execute(query)
count = cursor.fetchone()
self.customerCount = count[0]
connection.commit()
connection.close()
class FancyStoreLogin:
global mainFrame, root
username = ""
password = ""
def __init__(self):
global mainFrame
if(mainFrame and isinstance(mainFrame, Frame)):
mainFrame.destroy()
PGDCA 2nd sem
self.username = StringVar()
self.password = StringVar()
self.showLoginScreen()
def showLoginScreen(self):
global mainFrame
mainFrame = Frame(root, bg=bgcolor)
mainFrame.pack(fill=BOTH, expand=True)
loginFrame = Frame(mainFrame, bg=bgcolor)
loginFrame.place(relx=0.5, rely=0.5, anchor='center')
def login(self):
if self.username.get() == '':
messagebox.showinfo('Info', 'Username is needed.')
return
if self.password.get() == '':
messagebox.showinfo('Info', 'Password is needed.')
return
if self.username.get() == "admin" and self.password.get() == "password":
HomeScreen()
else:
messagebox.showerror("Login Error", "Invalid username or password")
def __init__(self):
global mainFrame
PGDCA 2nd sem
if(mainFrame and isinstance(mainFrame, Frame)):
mainFrame.destroy()
mainFrame = Frame(root, bg=bgcolor)
mainFrame.pack(fill=BOTH, expand=True)
self.name = StringVar()
self.price = StringVar()
self.qty = StringVar()
self.showStockEntry()
def showStockEntry(self):
global mainFrame
drawHeadFrame()
self.bodyFrame = Frame(mainFrame, bg="purple")
self.bodyFrame.pack(fill=BOTH, expand=True)
self.showStockEntryForm()
def showStockEntryForm(self):
self.products = getAllProducts()
productnames = []
for product in self.products:
productnames.append(f" {product[1]} - \u20B9{product[2]} ({product[3]})")
self.bodyFrame.grid_columnconfigure(0, weight=1, uniform="group1")
self.bodyFrame.grid_columnconfigure(1, weight=1, uniform="group1")
self.bodyFrame.grid_rowconfigure(0, weight=1)
addStockFrame = Frame(self.bodyFrame, bg=bgcolor)
addStockFrame.grid(row=0, column=0,sticky='nsew')
self.showStockFrame = Frame(self.bodyFrame, bg=bgcolor)
self.showStockFrame.grid(row=0, column=1,sticky='nsew')
inputFrame = Frame(addStockFrame, bg=bgcolor)
inputFrame.pack(side=TOP, padx=36, pady=24, anchor=W)
Label(inputFrame, text="Stock Entry:",font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=0, padx=0, pady=5, sticky=W)
Label(inputFrame, text="Product:",font=("Helvetica", 11, "underline"),
bg=bgcolor).grid(row=1, column=0, padx=5, pady=5, sticky=W)
Label(inputFrame, text="Name", font=("Helvetica", 10),bg=bgcolor).grid(row=2,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.name, width=26,bd=2,
relief="groove").grid(row=2, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Price", font=("Helvetica", 10),bg=bgcolor).grid(row=3,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.price, width=26,bd=2,
relief="groove").grid(row=3, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Quantity", font=("Helvetica",
10),bg=bgcolor).grid(row=4, column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.qty, width=26,bd=2,
relief="groove").grid(row=4, column=1, pady=6, ipadx=4, ipady=5)
Button(inputFrame, cursor="hand2", text="Save",
command=lambda:self.addUpdateProduct(),bg="blue",fg="white",font=("Helvetica",
9)).grid(row=5, column=1,pady=8,ipady=2,ipadx=12, sticky="e")
listFrame= Frame(self.showStockFrame, bg=bgcolor)
listFrame.pack(pady=26)
Label(listFrame, text="Products:", font=("Helvetica", 12),bg=bgcolor).pack()
listvar = Variable(value=productnames)
self.listBox = Listbox(listFrame, listvariable=listvar, height=12, width=30,
font=("Helvetica", 10), selectmode=BROWSE)
self.listBox.pack(pady=14)
PGDCA 2nd sem
btnFrame = Frame(listFrame, bg=bgcolor)
btnFrame.pack()
Button(btnFrame, cursor="hand2", text="Edit", command=lambda:self.editProduct(),
bg="blue",fg="white",font=("Helvetica", 9)).grid(row=0, column=0,
sticky=E,pady=8,ipady=2,ipadx=12,padx=4)
Button(btnFrame, cursor="hand2", text="Delete",
command=lambda:self.delProduct(),bg="red",fg="white",font=("Helvetica", 9)).grid(row=0,
column=1, sticky=W,pady=8,ipady=2,ipadx=12,padx=4)
def editProduct(self):
selected = self.listBox.curselection()
if selected:
index = selected[0]
selectedProduct = self.products[index]
self.name.set(selectedProduct[1])
self.price.set(selectedProduct[2])
self.qty.set(selectedProduct[3])
self.editingProductId = selectedProduct[0]
def addUpdateProduct(self):
name = self.name.get()
price = self.price.get()
qty = self.qty.get()
if name.strip() == "":
messagebox.showwarning("Invalid Input", "name cannot be empty")
if not (price.isdigit() or price.isdecimal()):
messagebox.showwarning("Invalid Input", "price should contain only decimal
values")
return
elif not (qty.isdigit()):
messagebox.showwarning("Invalid Input", "quantity should contain only
decimal values")
return
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
if(self.editingProductId < 0):
query = "insert into products(name, price, qty) values(?,?,?)"
cursor.execute(query, [name, price, qty])
messagebox.showinfo("Success", "Saved successfully")
else:
query = "update products set name=?, price=?, qty=? where id=?"
cursor.execute(query, [name, price, qty, self.editingProductId])
messagebox.showinfo("Success", "Updated successfully")
connection.commit()
connection.close()
self.editingProductId = -1
if self.showStockFrame and isinstance(self.showStockFrame, Frame):
self.showStockFrame.destroy()
self.showStockEntryForm()
name = self.name.set("")
price = self.price.set("")
qty = self.qty.set("")
def delProduct(self):
selected = self.listBox.curselection()
if selected:
PGDCA 2nd sem
index = selected[0]
selectedProduct = self.products[index]
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "delete from products where id = ?"
cursor.execute(query, [selectedProduct[0]])
connection.commit()
connection.close()
if self.showStockFrame and isinstance(self.showStockFrame, Frame):
self.showStockFrame.destroy()
self.showStockEntryForm()
def __init__(self):
global mainFrame
if(mainFrame and isinstance(mainFrame, Frame)):
mainFrame.destroy()
mainFrame = Frame(root, bg=bgcolor)
mainFrame.pack(fill=BOTH, expand=True)
self.name = StringVar()
self.address = StringVar()
self.phno = StringVar()
self.showCustomerEntry()
def showCustomerEntry(self):
drawHeadFrame()
self.bodyFrame = Frame(mainFrame, bg="purple")
self.bodyFrame.pack(fill=BOTH, expand=True)
self.showCustomerEntryForm()
def showCustomerEntryForm(self):
self.customers = getAllCustomers()
customernames = []
for customer in self.customers:
customernames.append(f" {customer[1]} - [{customer[3]}]")
self.bodyFrame.grid_columnconfigure(0, weight=1, uniform="group1")
self.bodyFrame.grid_columnconfigure(1, weight=1, uniform="group1")
self.bodyFrame.grid_rowconfigure(0, weight=1)
addCustomerFrame = Frame(self.bodyFrame, bg=bgcolor)
addCustomerFrame.grid(row=0, column=0,sticky='nsew')
self.showCustomerFrame = Frame(self.bodyFrame, bg=bgcolor)
self.showCustomerFrame.grid(row=0, column=1,sticky='nsew')
inputFrame = Frame(addCustomerFrame, bg=bgcolor)
PGDCA 2nd sem
inputFrame.pack(side=TOP, padx=36, pady=24, anchor=W)
Label(inputFrame, text="Customer Entry:",font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=0, padx=0, pady=5, sticky=W)
Label(inputFrame, text="Customer:",font=("Helvetica", 11, "underline"),
bg=bgcolor).grid(row=1, column=0, padx=5, pady=5, sticky=W)
Label(inputFrame, text="Name", font=("Helvetica", 10),bg=bgcolor).grid(row=2,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.name, width=26,bd=2,
relief="groove").grid(row=2, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Address", font=("Helvetica", 10),bg=bgcolor).grid(row=3,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.address, width=26,bd=2,
relief="groove").grid(row=3, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Contact", font=("Helvetica", 10),bg=bgcolor).grid(row=4,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.phno, width=26,bd=2,
relief="groove").grid(row=4, column=1, pady=6, ipadx=4, ipady=5)
Button(inputFrame, cursor="hand2", text="Save",
command=lambda:self.addUpdateCustomer(),bg="blue",fg="white",font=("Helvetica",
9)).grid(row=5, column=1,pady=8,ipady=2,ipadx=12, sticky="e")
listFrame= Frame(self.showCustomerFrame, bg=bgcolor)
listFrame.pack(pady=26)
Label(listFrame, text="Customers:", font=("Helvetica", 12),bg=bgcolor).pack()
listvar = Variable(value=customernames)
self.listBox = Listbox(listFrame, listvariable=listvar, height=12, width=30,
font=("Helvetica", 10), selectmode=BROWSE)
self.listBox.pack(pady=14)
btnFrame = Frame(listFrame, bg=bgcolor)
btnFrame.pack()
Button(btnFrame, cursor="hand2", text="Edit",
command=lambda:self.editCustomer(), bg="blue",fg="white",font=("Helvetica",
9)).grid(row=0, column=0, sticky=E,pady=8,ipady=2,ipadx=12,padx=4)
Button(btnFrame, cursor="hand2", text="Delete",
command=lambda:self.delCustomer(),bg="red",fg="white",font=("Helvetica", 9)).grid(row=0,
column=1, sticky=W,pady=8,ipady=2,ipadx=12,padx=4)
def editCustomer(self):
selected = self.listBox.curselection()
if selected:
index = selected[0]
selectedCustomer = self.customers[index]
self.name.set(selectedCustomer[1])
self.address.set(selectedCustomer[2])
self.phno.set(selectedCustomer[3])
self.editingCustomerId = selectedCustomer[0]
def addUpdateCustomer(self):
name = self.name.get()
address = self.address.get()
phno = self.phno.get()
if name.strip() == "":
messagebox.showwarning("Invalid Input", "name cannot be empty")
if address.strip() == "":
messagebox.showwarning("Invalid Input", "address cannot be empty")
if phno.strip() == "":
messagebox.showwarning("Invalid Input", "phone number cannot be empty")
if not (phno.isdigit()):
messagebox.showwarning("Invalid Input", "phone number should contain digits
PGDCA 2nd sem
only")
return
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
if(self.editingCustomerId < 0):
query = "insert into customer(name, address, contact) values(?,?,?)"
cursor.execute(query, [name, address, phno])
messagebox.showinfo("Success", "Saved successfully")
else:
query = "update customer set name=?, address=?, contact=? where id=?"
cursor.execute(query, [name, address, phno, self.editingCustomerId])
messagebox.showinfo("Success", "Updated successfully")
connection.commit()
connection.close()
self.editingCustomerId = -1
if self.showCustomerFrame and isinstance(self.showCustomerFrame, Frame):
self.showCustomerFrame.destroy()
self.showCustomerEntryForm()
name = self.name.set("")
address = self.address.set("")
phno = self.phno.set("")
def delCustomer(self):
selected = self.listBox.curselection()
if selected:
index = selected[0]
selectedCustomer = self.customers[index]
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "delete from customer where id = ?"
cursor.execute(query, [selectedCustomer[0]])
connection.commit()
connection.close()
if self.showCustomerFrame and isinstance(self.showCustomerFrame, Frame):
self.showCustomerFrame.destroy()
self.showCustomerEntryForm()
def __init__(self):
global mainFrame
self.showSalesEntry()
def showSalesEntry(self):
drawHeadFrame()
self.drawSubHeadFrame()
self.bodyFrame = Frame(mainFrame, bg="purple")
self.bodyFrame.pack(fill=BOTH, expand=True)
self.showSalesEntryForm()
def drawSubHeadFrame(self):
subHeadFrame = Frame(mainFrame, bg="Yellow")
subHeadFrame.pack(fill=X, expand=True)
PGDCA 2nd sem
subHeadFrame.grid_columnconfigure(0, weight=1, uniform="group1")
subHeadFrame.grid_columnconfigure(1, weight=1, uniform="group1")
subHeadFrame.grid_columnconfigure(2, weight=1, uniform="group1")
subHeadFrame.grid_columnconfigure(3, weight=1, uniform="group1")
Label(subHeadFrame, text="Bill Number: ",font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=0, padx=0, pady=2, ipady=3, sticky="e")
Label(subHeadFrame, textvariable=self.billno, font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=1, padx=0, pady=2, ipady=3, sticky="w")
Label(subHeadFrame, text="Customer: ",font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=2, padx=0, pady=2, ipady=3, sticky="e")
Label(subHeadFrame, textvariable=self.customer, font=("Helvetica", 12),
bg=bgcolor).grid(row=0, column=3, padx=0, pady=2, ipady=3, sticky="w")
self.billno.set(self.generateBillNo())
def generateBillNo(self):
return f"#{datetime.now().strftime('%Y%m%d%H%M%S')}"
def selectCustomer(self):
name = ""
selection = self.listBox.curselection()
print("sc" , selection)
if selection:
self.selectedCustomer = self.customers[selection[0]]
name = self.selectedCustomer[1]
self.customer.set(name.title())
def selectProduct(self):
selection = self.listBox2.curselection()
print("selection:", selection)
if selection:
self.selectedProduct = self.products[selection[0]]
self.price.set(self.selectedProduct[2])
self.product.set(self.selectedProduct[1])
self.quantity.set("1")
self.amount.set(f"\u20B9{self.selectedProduct[2]}")
def showSalesEntryForm(self):
self.customers = getAllCustomers()
self.products = getAllProducts()
customernames = []
for customer in self.customers:
customernames.append(f" {customer[1]} - [{customer[3]}]")
self.bodyFrame.grid_columnconfigure(0, weight=1, uniform="group1")
self.bodyFrame.grid_columnconfigure(1, weight=1, uniform="group1")
self.bodyFrame.grid_rowconfigure(0, weight=1)
listContainerFrame = Frame(self.bodyFrame, bg=bgcolor)
listContainerFrame.grid(row=0, column=0,sticky='nsew')
salesEntryFrame = Frame(self.bodyFrame, bg=bgcolor)
salesEntryFrame.grid(row=0, column=1,sticky='nsew')
def setProductsToList(self):
productnames = []
self.products = getAllProducts()
for product in self.products:
productnames.append(f" {product[1]} - \u20B9{product[2]} [{product[3]}]")
self.productList.set(productnames)
def addUpdateSales(self):
qty = self.quantity.get()
if qty.strip == "" and not qty.isdigit:
messagebox.showwarning("Invalid Input", "Quantity must be a valid number")
return
if int(qty) < 1:
messagebox.showwarning("Invalid Input", "Quantity must be greater than
zero")
return
if not self.selectedProduct:
messagebox.showwarning("Invalid Input", "Please select a product before
proceeding")
return
if not self.selectedCustomer:
messagebox.showwarning("Invalid Input", "Please select a customer before
proceeding")
return
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "select * from sales where billno=? and product_id=? and customer_id=?"
cursor.execute(query, [self.billno.get(), self.selectedProduct[0],
self.selectedCustomer[0]])
salesEntry = cursor.fetchone()
if salesEntry:
presentQty = int(salesEntry[2])
newQty = presentQty + int(qty)
query = "update sales set quantity=? where billno=? and product_id=? and
customer_id=?"
cursor.execute(query, [newQty, self.billno.get(), self.selectedProduct[0],
self.selectedCustomer[0]])
else:
query = "insert into sales(billno, quantity, product_id, customer_id)
values(?,?,?,?)"
cursor.execute(query, [self.billno.get(), int(qty), self.selectedProduct[0],
self.selectedCustomer[0]])
self.product.set("")
self.quantity.set("")
self.amount.set("")
self.selectedProduct = ()
PGDCA 2nd sem
connection.commit()
connection.close()
self.showCartItems()
def showCartItems(self):
cartList = []
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "select sales.id, sales.quantity, products.name, products.price,
sales.product_id from sales inner join products on sales.product_id = products.id where
billno=? and customer_id=? order by sales.id desc"
cursor.execute(query,[self.billno.get(), self.selectedCustomer[0]])
self.cartEntries = cursor.fetchall()
for entry in self.cartEntries:
cartList.append(f"{entry[2]} (\u20B9{entry[3]}) - Qty. {entry[1]} -
Total. {int(entry[1])* int(entry[3])}")
self.cartItems.set(cartList)
connection.commit()
connection.close()
def removeCartItem(self):
selection = self.listBoxCart.curselection()
print("selection:", selection)
if selection:
index = selection[0]
salesEntryId = self.cartEntries[index][0]
productId = self.cartEntries[index][4]
opQty = self.cartEntries[index][1]
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
cursor.execute("delete from sales where id=?",[salesEntryId])
query = "select qty from products where id=?"
cursor.execute(query, [productId])
currentQty = cursor.fetchone()[0]
updatedQty = int(currentQty)+int(opQty)
query = "update products set qty=? where id=?"
cursor.execute(query, [updatedQty, productId])
connection.commit()
connection.close()
self.setProductsToList()
self.showCartItems()
class BillScreen:
billno = None
cartEntries = []
cartItems = None
gTotal = None
customerId = -1
name = None
address = None
contact = None
PGDCA 2nd sem
def __init__(self, billno):
global mainFrame
if(mainFrame and isinstance(mainFrame, Frame)):
mainFrame.destroy()
mainFrame = Frame(root, bg=bgcolor)
mainFrame.pack(fill=BOTH, expand=True)
self.cartItems = StringVar(value=[])
self.billno = billno
self.gTotal = StringVar(value=0)
self.name = StringVar()
self.address = StringVar()
self.contact = StringVar()
self.showBill()
def showBill(self):
drawHeadFrame()
bodyFrame = Frame(mainFrame, bg=bgcolor)
bodyFrame.pack(side=TOP, fill=BOTH, expand=True)
Label(bodyFrame, text=f"Bill No. {self.billno}", font=("Helvetica", 11,
"bold"),bg=bgcolor).pack(anchor="w", pady=(24,8), padx=16)
firstContainer = Frame(bodyFrame, bg=bgcolor)
firstContainer.pack(side=TOP, fill=X, anchor="n")
cartListFrame = Frame(bodyFrame, bg=bgcolor)
cartListFrame.pack(side=TOP, fill=BOTH, anchor="ne", pady=(20,0))
firstContainer.grid_columnconfigure(0, weight=1, uniform="group1")
firstContainer.grid_columnconfigure(1, weight=1, uniform="group1")
customerDetailFrame = Frame(firstContainer, bg=bgcolor)
customerDetailFrame.grid(row=0, column=0, sticky="nw")
Label(customerDetailFrame, text="Customer:", font=("Helvetica", 11,
"underline"),bg=bgcolor).grid(row=0, column=0, padx=20, pady=4, sticky="nw")
Label(customerDetailFrame, textvariable=self.name, font=("Helvetica",
10),bg=bgcolor).grid(row=1, column=0, padx=20, sticky="w")
Label(customerDetailFrame, textvariable=self.address, font=("Helvetica",
10),bg=bgcolor).grid(row=2, column=0, padx=20, sticky="w")
Label(customerDetailFrame, textvariable=self.contact, font=("Helvetica",
10),bg=bgcolor).grid(row=3, column=0, padx=20, sticky="w")
grandTotalFrame = Frame(firstContainer, bg=bgcolor)
grandTotalFrame.grid(row=0, column=1, sticky="e")
Label(grandTotalFrame, text="Grand Total:", font=("Helvetica", 11,
"underline"),bg=bgcolor).grid(row=0, column=0, padx=20, sticky="ne")
Label(grandTotalFrame, textvariable=self.gTotal, font=("Helvetica",
20),bg=bgcolor).grid(row=1, column=0, padx=20, sticky="e")
Label(cartListFrame, text="Products:", font=("Helvetica", 11,
"underline"),bg=bgcolor).grid(row=0, column=0, padx=20, pady=4, sticky="w")
listBox = Listbox(cartListFrame, listvariable=self.cartItems, height=18,
width=130, font=("Helvetica", 10), selectmode=BROWSE)
listBox.grid(row=1, column=0)
self.getAllCartItems()
self.getCustomerDetails()
def getCustomerDetails(self):
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "select * from customer where id=?"
cursor.execute(query,[self.customerId])
customer = cursor.fetchone()
PGDCA 2nd sem
self.name.set(f"Name: {customer[1]}")
self.address.set(f"Address: {customer[2]}")
self.contact.set(f"Contact: {customer[3]}")
connection.commit()
connection.close()
def getAllCartItems(self):
cartList = []
gTotal = 0
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
query = "select sales.id, sales.quantity, products.name, products.price,
sales.customer_id from sales inner join products on sales.product_id = products.id where
billno=? order by sales.id desc"
cursor.execute(query,[self.billno])
self.cartEntries = cursor.fetchall()
if self.cartEntries:
self.customerId = self.cartEntries[0][4]
for entry in self.cartEntries:
cartList.append(f" Product.- {entry[2]} Price.- (\
u20B9{entry[3]}) Qty.- {entry[1]} Total.- {int(entry[1])*
float(entry[3])}")
gTotal += (int(entry[1]) * float(entry[3]))
self.cartItems.set(cartList)
self.gTotal.set(f"\u20B9{gTotal}")
connection.commit()
connection.close()
def getAllCustomers():
customers = ()
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
cursor.execute("select * from customer order by id desc")
customers = cursor.fetchall()
return customers
def getAllProducts():
products = ()
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
cursor.execute("select * from products order by id desc")
products = cursor.fetchall()
return products
def createTables():
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
cursor.execute("PRAGMA foreign_keys = ON")
cursor.execute("create table if not exists products(id INTEGER PRIMARY KEY
AUTOINCREMENT, name TEXT NOT NULL, price REAL NOT NULL, qty INTEGER NOT NULL)")
cursor.execute("create table if not exists customer(id INTEGER PRIMARY KEY
AUTOINCREMENT, name TEXT NOT NULL, address TEXT NOT NULL, contact TEXT NOT NULL)")
cursor.execute("create table if not exists wholesaler(id INTEGER PRIMARY KEY
AUTOINCREMENT, name TEXT NOT NULL, address TEXT NOT NULL, contact TEXT NOT NULL)")
PGDCA 2nd sem
cursor.execute("create table if not exists purchase(id INTEGER PRIMARY KEY
AUTOINCREMENT, billno TEXT NOT NULL, quantity INTEGER NOT NULL, product_id INTEGER,
wholesaler_id INTEGER, FOREIGN KEY (product_id) REFERENCES products(id), FOREIGN KEY
(wholesaler_id) REFERENCES wholesaler(id))")
cursor.execute("create table if not exists sales(id INTEGER PRIMARY KEY
AUTOINCREMENT, billno TEXT NOT NULL, quantity INTEGER NOT NULL, product_id INTEGER,
customer_id INTEGER, FOREIGN KEY (product_id) REFERENCES products(id), FOREIGN KEY
(customer_id) REFERENCES customer(id))")
connection.commit()
connection.close()
def insertData():
products = [("Ponds cream", 20),
("Hair clips", 15),
("Lipstick", 175),
("Hair oil", 50),
("Kajal", 25),
("Perfume",260),
("Bangals",60),
("Eyeliner",30),
("Bindi",10),
("Foundation",210),
("Concealar",215),
("Eyeshadow",150),
("Blush",180),
("Mascara",85)]
connection = sqlite3.connect("Fancystore.db")
cursor = connection.cursor()
check = "select * from products"
cursor.execute(check)
if cursor.fetchone():
pass
else:
i=0
for product in products:
i +=1
qty = 50
#print(i)
print(i%2)
if i%2:
qty = 10
cursor.execute("insert into products(name, price, qty) values(?,?,?)",
[product[0], product[1],qty])
connection.commit()
connection.close()
if __name__ == "__main__":
createTables()
insertData()
root = Tk()
root.title("Fancy Store")
root.geometry("800x575+0+10")
root.resizable(width=False, height=False)
bgcolor="#d7837f"
currentScreen = None
PGDCA 2nd sem
mainFrame = Frame(root, bg=bgcolor)
FancyStoreLogin()
#FancyStoreBilling(root)
root.mainloop()
PGDCA 2nd sem
CONCLUSION
REFRENCES
References are always needed for the development of any System / Software
development. Through the system development life cycle, I refer the following books
and manuals for related sources.