0% found this document useful (0 votes)
3 views

Python - Fancystore System (1)

The project aims to create a computerized system for managing cosmetic stock, prices, customer records, and supplier information, which will streamline transactions and reduce paperwork. It includes features such as report generation, user information management, and database handling, utilizing Python and MySQL for development. The project also addresses the inefficiencies of manual systems and outlines future enhancements for improved usability.

Uploaded by

Bindu Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python - Fancystore System (1)

The project aims to create a computerized system for managing cosmetic stock, prices, customer records, and supplier information, which will streamline transactions and reduce paperwork. It includes features such as report generation, user information management, and database handling, utilizing Python and MySQL for development. The project also addresses the inefficiencies of manual systems and outlines future enhancements for improved usability.

Uploaded by

Bindu Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 54

PGDCA 2nd sem

SYNOPSI
S
PGDCA 2nd sem

SYNOPSIS OF THE PROJECT

THIS PROJECT CAN MANAGE ALL INFORMATION ABOUT COSMETIC


STOCK, PRICE, STOCK AVAILIBILITY, CUSTOMER RECOREDS, SUPLIER
RECORD LIKE CONTACT NO OF SUPLIER, IT ALSO MAINTAIN PURCHASE
AND SALES DETAILS AND GENERATE ELECTRONIC BILL SO THAT WE
CAN SEARCH RECORDS QUICKLY AND GENERATE ELECTRONIC REPORT
WITHIN A SECOND

WE CAN USE THIS PROJECT IN ANY SHOP AND MAINTAIN THEIR


TRANSECTION WITH THE HELP OF COMPUTER AND ELECTRONICLLY IT ALSO
REDUCE HUMAN EFFORT AND PAPER WORK.

I WOULD LIKE TO EXTEND MY SINCERE THANKS TO DIRECTOR OF


“COLLEGE” WHO MADE AVAILABLE ALL POSSIBLE RESOURCES
NECESSARY FOR MY PROJECT. FURTHER I WOULD LIKE TO GIVE
REGARDS TO WHO HAD GIVEN THEIR KIND TIME TOWARDS MY
PROJECT. FINALLY I WOULD GIVE MY WHOLE HEARTED THANKS FOR
PROVIDING ALL NECESSARY REQUIRED DATA FOR THE PROJECT.
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

OBJECTIVE OF THE PROJECT

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.

Communication: A project management system makes communication channels


regarding tasks, projects and programs easier through the uploading and sharing of
files, collaborating on an online space and emailing updates through the system.
Communication channels with your customers/ clients can be made simpler also as
business documents e.g. invoices can be sent directly from the project management
system to its required destination and information on those customers/ clients can be
kept on a virtual database to help with the follow up process that takes place.

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.

Quality of information: The quality of the information is increased as only the


information that’s needed is gathered and shown.

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

SCOPE OF THE PROJECT

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

THEORETICAL BACKGROUND OF THE PROJECT

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

SYSTEM ANALYSIS AND DESIGN

FEASIBILITY STUDY:-

An initial investigation terminates in a proposal that determines whether an


alternative system is feasible. Feasibility study can be categorized into three major parts:
-

(1) TECHNICAL FEASIBILITY:-

 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.

(2) OPERATING FEASIBILITY STUDY:-

The management of the organization has a fully supported us to bring


up the project and the data security in this project provided by setting up the
password procedure so that only the authorized user can access the system.

(3) OUR PROJECT IS ECONOMICAL FEASIBLE AS:-

* It has computerized paper works and also is reduced to large extent


* With the help of this project single person is now available to do the
tasks of 5 to 7 persons.
* Due to processing speed of then Computer, we can extract desired
information’s in a fraction of second.
PGDCA 2nd sem

PERT CHART
PGDCA 2nd sem

SYSTEM PLANNING (PERT CHART)

A PERT chart is a project management tool used to schedule, organize, and


coordinate tasks within a project. PERT stands for Program Evaluation Review
Technique, a methodology developed by the U.S. Navy in the 1950s to manage the
Polaris submarine missile program. A similar methodology, the Critical Path
Method (CPM) was developed for project management in the private sector at about
the same time.
PGDCA 2nd sem

A PERT chart presents a graphic illustration of a project as a network diagram


consisting of numbered nodes (either circles or rectangles) representing events, or
milestones in the project linked by labelled vectors (directional lines) representing
tasks in the project. The direction of the arrows on the lines indicates the sequence of
tasks. In the diagram, for example, the tasks between nodes 1, 2, 4, 8, and 10 must be
completed in sequence. These are called dependent or serial tasks. The tasks between
nodes 1 and 2, and nodes 1 and 3 are not dependent on the completion of one to start
the other and can be undertaken simultaneously. These tasks are
called parallel or concurrent tasks. Tasks that must be completed in sequence but that
don't require resources or completion time are considered to have event dependency.
These are represented by dotted lines with arrows and are called dummy activities. For
example, the dashed arrow linking nodes 6 and 9 indicates that the system files must
be converted before the user test can take place, but that the resources and time
required to prepare for the user test (writing the user manual and user training) are on
another path. Numbers on the opposite sides of the vectors indicate the time allotted
for the task.
The PERT chart is sometimes preferred over the Gantt chart, another popular
project management charting method, because it clearly illustrates task dependencies.
On the other hand, the PERT chart can be much more difficult to interpret, especially
on complex projects. Frequently, project managers use both techniques.
PGDCA 2nd sem

HARDWARE AND SOFTWARE USED

 HARDWARE USED:-

 PROCESSOR - PENTIUM-IV 945 GHZ


 RAM – 1 GB
 HARD DISK – 160 GB
 MONITOR – 17” LG COLOR MONITOR
 DVD WRITER SONY
 KEYBOARD – 1.5 KEY MULTIMEDIA KEYBOARD
 PRINTER – HP LASER JET 6L PRINTER
 MOUSE – OPTICAL MOUSE IBALL

 SOFTWARE USED:-

 OPERATING SYSTEM – MICROSOFT WINDOWS 10 PRO


 DATABASE – MY SQL
 FRONT-END PACKAGE –PYTHON (IDLE Shell 3.11.4)
PGDCA 2nd sem

COST AND BENEFIT ANALYSIS

Cost and Benefit Categories


In developing cost estimates for a system, we need to consider several cost elements.
Among them is hardware, personnel, facility, operating, and supply cost.

1 Hardware cost relate to actual purchase or lease of the computer and


peripherals. Determining the actual cost of hardware is generally more
difficult when the system is shared by various users than for a dedicated
stand- alone system. In some cases, the best way to control for this cost is to
treat it is an operating cost.
2 Personnel cost include EDP staff salaries and benefits as well as pay for
those involved in developing the system.
3 Facility costs are expenses incurred in the preparation of the physical site
where the application or the computer will be in operation. This includes
wiring, flooring, acoustics, lighting, and air conditioning. These cost are
treated as one time cost and incorporated into the overall cost estimate of the
candidate system.
4 Operating cost include all cost associated with the day to day operation of
the system, the amount depends on the number of shifts, the nature of the
application, and the caliber of the operating staff. There are various ways of
covering operating cost one approach is to treat operating cost as overhead.
Another approach is to charge each authorized user for the amount of
processing they request from the system. The amount charged is based on
computer time, staff time, and volume of output produced. In any case, some
accounting is necessary to determine how operating cost should be handled.
5 Supply costs are variable costs that increase with increased use of paper,
ribbons, disks, and the like. They should be estimated and included in the
overall cost of the system.
PGDCA 2nd sem

DETAILED LIFE CYCLE OF THE PROJECT

All stages of a software process status quo, problem definition, technical


development, and solution integration coexist simultaneously at some level of detail.
design and analysis. Information engineering encompasses requirements gathering at
the strategic business level and at the business area level.

Software requirements analysis. The requirements gathering process is intensified


and focused specifically on software. To understand the nature of the program(s) to be
built, the software engineer ("analyst") must understand the information domain
for the software, as well as required function, behavior, performance, and interface.
Requirements for both the system and the software are documented
and reviewed with the customer.

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.

Code generation. The design must be translated into a machine-readable form.The


code generation step performs this task. If design is performed in a detailed
manner,code generation can be accomplished mechanistically.

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.

Implementation. Software will undoubtedly undergo change after it is delivered to


the customer (a possible exception is embedded software). Change will occur because
errors have been encountered, because the software must be adapted to accommodate
changes in its external environment (e.g., a change required because of a new
operating system or peripheral device), or because the customer requires functional or
performance enhancements. Software support/maintenance reapplies each of the
preceding phases to an existing program rather than a new one.
PGDCA 2nd sem

FIG. SDLC PHASE


PGDCA 2nd sem

ER DIAGRAM
PGDCA 2nd sem

E-R DIAGRAM

S-name COMPANY Price

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

DATA FLOW DIAGRAM


DFD is a graphical representation of data process and files used in a support
system.Data Flow Diagrams are useful tools for analyzing existing systems. Data
Flow Diagram is a network that describes flows of data and the processes that changes
or transforms the data throughout a system.
Data flow diagrams can be expanded to show successive levels of details sufficient.
Expansion should be performed during the initial investigation to be certain
that both the analyst and user personnel share a common understanding of the existing
system and its data flow.
The different symbols used in the data flow diagram are:-

1. Circle It is used form transfer the input to output


Indicate process that transfer data flow.

2. Rectangle with When data is in file this symbol is used flow.


Representation
Open End

3. Square Squares indicates the source of destination .

4. Arrows Arrows are sued to show flow of path from where it is


coming & going.
PGDCA 2nd sem

CUSTOMER

stockb Detail

CUSTOMERTBL

Enquiry fro STOCK.


Salet_tbl

SALE to customer

Pay BILL

Print Bill
PGDCA 2nd sem

INPUT AND OUTPUT SCREEN DESIGN

Login Form

Home page Form


PGDCA 2nd sem
Stock Entry Form

CUSTOMER ENTRY FORM


PGDCA 2nd sem
PGDCA 2nd sem
PGDCA 2nd sem
Sales Entry Form

Billing Entry Form


PGDCA 2nd sem
PGDCA 2nd sem
PGDCA 2nd sem

PROCESS INVOLVED
WaterFall Model:The stages of “The Waterfall Model” are:

Requirement Gathering & Analysis:-This is the starting phase of the


SDLC in which all possible system requirements are captured & analyzed.
Software requirements specification includes the complete information
about how actual end users are expecting from the system. This
document covers all the necessary requirements for the development of
project. Finally after completion of requirement gathering & analysis
(validation of requirement against the user needs), a Requirement
Specification document is created which give out as a input to the next
phase of SDLC. In this model once we moved to the next phase then it
won’t possible to add or update the requirements.
System & Software Design: Prior to start actual coding, it is mandatory
to be aware of what all features we are going to implement & how it
would look like? The requirement specifications document created in the
first phase is used as the input to this phase & based on this the system
design specifications would be prepared. In which all hardware & system
requirements would be specified. The system design specifications
document prepared in this phase is used as input for the Implementation
& Testing phase model.
Implementation & Unit Testing: Upon getting the system design
specifications document the actual coding would be started. Before
starting the actual coding requirements are divided into the models/units.
In the actual coding the initially develop the small programs called units.
After implementing all units the integration would be started in the next
phase. The developed unit’s model functionality is tested separately in
this phase to check whether the unit models are meets the specified
requirements & this individual model testing is called as Unit Testing.
Integration & System Testing: In the previous model the system
requirements are divided into models & each model is developed & tested
separately. In this phase all units are integrated & done the system
testing
PGDCA 2nd sem
to check whether the all models/units are integrated properly or not & the
system as whole doing as mention as per the system requirement
document, so we call this phase as the Integration & System Testing.
Upon complete testing of software is done then actual Software is
successfully send to customer.
Operations & Maintenance: This phase is the never ending phase of
the Waterfall Model. The problems are comes in picture after
Implementation & Unit Testing phase. The issues found after the
implementation phase
i.e. not found in the period of the development life cycle. Some of the
issues are not catch after testing cycle done so those are implemented in
the maintenance phase, so this phase is called as Operations &
Maintenance phase.
Advantages of Waterfall Model:

 This is linear simple model to implement & easy to maintain.


 In the SDLC initial phase spent time on reviewing requirements and
design which saves the time later.
 Required resources are minimum in this model as compare to other.
 After every phase of the model a document in created which help &
simpler to understand & design the system.
 Upon completion of coding, is done to check for implemented code
or correctness of system.
 For each stage deadlines can be set which will help to develop the
system on decided time frame.

Disadvantages of Waterfall Model:

 The biggest disadvantages of such system is it won’t allow to go


back. If the problems in the design phase which creates
complication in the implementation phase.
 This model is rigid model. Not flexible & make changes is not
possible in the development of system.
 Unable to start the next phase before completing the previous
phase so time consuming.
 In the deployment phase all requirements are not covered or all
requirements are not cover so adding such requirements may
create unsuitable system.
 To make it customer happy such new requirement need to be
implemented in new version of system which leads to added cost to
system development.
PGDCA 2nd sem

SOURCE CODE

Home page Entry form

from tkinter import *


import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
from datetime import datetime
import sqlite3

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()

Login Entry form

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')

Label(loginFrame, text="Log In", font=("Helvetica", 14), bg=bgcolor).grid(row=1,


column=0,padx=12, pady=12,sticky="w")
Label(loginFrame, text="Username", font=("Helvetica", 10,
"bold"),bg=bgcolor).grid(row=2, column=0,padx=12, sticky="w")
Entry(loginFrame, textvariable=self.username, width=28,bd=2,
relief="groove").grid(row=2, column=1, pady=8, ipadx=4, ipady=8, columnspan=2)
Label(loginFrame, text="Password", font=("Helvetica", 10,
"bold"),bg=bgcolor).grid(row=3,padx=12, column=0,sticky="w")
Entry(loginFrame, textvariable=self.password, width=28, show='*',bd=2,
relief="groove").grid(row=3, column=1, pady=8,ipadx=4, ipady=8, columnspan=2)
Button(loginFrame, cursor="hand2",
text="LogIn",command=self.login,fg="white",padx=4,relief="flat",font=("Helvetica",
10),bg="green").grid(row=4, column=1, padx=4, pady=10,ipadx=12,
ipady=2,columnspan=2,sticky="e")

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")

Stock Entry form


class StockEntry:
global mainFrame, root
bodyFrame = None
name = None
price = None
qty = None
listBox = None
product = []
editingProductId = -1
showStockFrame = None

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()

Customer Entry form


class CustomerEntry:
customers = []
name = None
address = None
phno = None
listBox = None
customer = []
editingCustomerId = -1
showCustomerFrame = None

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()

Sales Entry form


class SalesEntry():
billno = None
customer = None
product = None
customers = None
products = None
price = None
quantity = None
amount = None
bodyFrame = None
listBox = None
listBox2 = None
listBoxCart = None
cartItems = None
#availableQty = 0
PGDCA 2nd sem
selectedProduct = ()
selectedCustomer = ()
cartEntries = []
prodcutList = None

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.customers = []
self.products = []
self.billno = StringVar()
self.customer = StringVar()
self.product = StringVar()
self.price = StringVar()
self.quantity = StringVar()
self.quantity.trace_add("write", self.setAmount)
self.amount = StringVar()
self.cartItems =StringVar(value=[])
self.productList =StringVar(value=[])

self.showSalesEntry()

def setAmount(self, var, index, mode):


qty = self.quantity.get()
availableQty = int(self.selectedProduct[3])
try:
if qty == "":
qty = 0
qty = int(qty)
price = float(self.price.get())
if qty > availableQty:
messagebox.showwarning("Input Error", f"only {availableQty} pieces are
available in stock")
self.quantity.set(availableQty)
self.amount.set(f"\u20B9{price*availableQty}")
return
self.amount.set(f"\u20B9{price*qty}")
except Exception as e:
print("ex:", e)
pass

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')

inputFrame = Frame(salesEntryFrame, bg=bgcolor)


inputFrame.pack(side=TOP, padx=36, pady=0, anchor="nw")
Label(inputFrame, text="Sales Entry:",font=("Helvetica", 11, "underline"),
bg=bgcolor).grid(row=0, column=0, padx=0, pady=5, sticky=W)
Label(inputFrame, text="Product", font=("Helvetica", 10),bg=bgcolor).grid(row=1,
PGDCA 2nd sem
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.product, state="disabled", width=26, bd=2,
relief="groove").grid(row=1, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Quantity", font=("Helvetica",
10),bg=bgcolor).grid(row=2, column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.quantity, width=26, bd=2,
relief="groove").grid(row=2, column=1, pady=6, ipadx=4, ipady=5)
Label(inputFrame, text="Amount", font=("Helvetica", 10),bg=bgcolor).grid(row=3,
column=0, padx=5, sticky="w")
Entry(inputFrame, textvariable=self.amount, state="disabled", fg="black",
width=26, bd=2, relief="groove").grid(row=3, column=1, pady=6, ipadx=4, ipady=5)
Button(inputFrame, cursor="hand2", text="Add",
command=lambda:self.addUpdateSales(),bg="blue",fg="white",font=("Helvetica",
9)).grid(row=4, column=0,columnspan=2, pady=4,ipady=2,ipadx=12, sticky="w")

cartFrame = Frame(salesEntryFrame, bg=bgcolor)


cartFrame.pack(fill=X, anchor="n", pady=8)
cartFrame.grid_columnconfigure(0, weight=1, uniform="group1")
cartFrame.grid_columnconfigure(1, weight=1, uniform="group1")
Label(cartFrame, text="Cart:", font=("Helvetica", 11,
"underline"),bg=bgcolor).grid(row=0, column=0, padx=32, sticky="w")
cartBtnFrame = Frame(cartFrame, bg=bgcolor)
cartBtnFrame.grid(row=0, column=1, padx=(24,0), sticky="w")
Button(cartBtnFrame, cursor="hand2", text="Remove",
command=lambda:self.removeCartItem(),bg="red",fg="white",font=("Helvetica",
8)).pack(side=LEFT,padx=4, pady=6,ipady=2,ipadx=4)
Button(cartBtnFrame, cursor="hand2", text="Generate Bill",
command=lambda:BillScreen(self.billno.get()),bg="blue",fg="white",font=("Helvetica",
8)).pack(side=LEFT, padx=4, pady=6,ipady=2,ipadx=4)
self.listBoxCart = Listbox(cartFrame, listvariable=self.cartItems, height=11,
width=48, font=("Helvetica", 10), selectmode=BROWSE)
self.listBoxCart.grid(row=1, column=0, columnspan=2, pady=2)

listFrame= Frame(listContainerFrame, bg=bgcolor)


listFrame.pack(pady=0)
Label(listFrame, text="Customers:", font=("Helvetica",
11),bg=bgcolor).grid(row=0, column=0,sticky="w")
listvar = Variable(value=customernames)
self.listBox = Listbox(listFrame, listvariable=listvar, height=4, width=36,
font=("Helvetica", 10), selectmode=BROWSE)
self.listBox.grid(row=1, column=0, columnspan=2)
btnFrame = Frame(listFrame, bg=bgcolor)
btnFrame.grid(row=0, column=1, sticky="e")
Button(btnFrame, cursor="hand2", text="Select",
command=lambda:self.selectCustomer(), bg="blue",fg="white",font=("Helvetica",
8)).grid(row=0, column=0, sticky="e",pady=(0,8),ipady=2,ipadx=12,padx=4)

Label(listFrame, text="Products:", font=("Helvetica",


11),bg=bgcolor).grid(row=3, column=0,pady=(24,8), sticky="w")
self.setProductsToList()
self.listBox2 = Listbox(listFrame, listvariable=self.productList, height=16,
width=36, font=("Helvetica", 10), selectmode=BROWSE)
self.listBox2.grid(row=4, column=0, columnspan=2)
btnFrame = Frame(listFrame, bg=bgcolor)
btnFrame.grid(row=3, column=1, sticky="e")
Button(btnFrame, cursor="hand2", text="Select",
command=lambda:self.selectProduct(), bg="blue",fg="white",font=("Helvetica",
8)).grid(row=0, column=0, sticky="e",pady=(24,8),ipady=2,ipadx=12,padx=4)
PGDCA 2nd sem

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]])

query = "update products set qty=? where id=?"


productQty = int(self.selectedProduct[3])
leftQty = productQty - int(qty)
cursor.execute(query, [leftQty, self.selectedProduct[0]])
connection.commit()
self.setProductsToList()

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()

Billing Entry form

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

Now days computerizations of existing manual system is going on a large


scale because of the versatility, speed, accuracy and diligence it offers to its users.
Computers provide practical means to organize things systematically and
economically in the organization the use of computers for managing transactions;
information processing and preparation of reports can prove to be a blessing.
The project is discussion is an attempt to attain all the above said
objectives. Its development was mean to replace the manual system and to achieve the
goal to maximum accuracy and most efficiently. But like every other system might
process faults to its credits and has its own limitation. Neglecting these few negations,
the project can be called a stepping stone to automate processes in organizations.
PGDCA 2nd sem

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.

Book Name Author Name

Informatics Practices Sumita Arora

Visual Programming Black Book Steven Holzner

You might also like