Project File Informatics Practices (2024-2025)
Project File Informatics Practices (2024-2025)
SystemManagement
SHARDA GLOBAL SCHOOL, RANCHI
SESSION-[2024-25]
CLASS XII
Project Work
SUBMITTED TO SUBMITTED By
Class:
STUDENT’S NAME:
CLASS: XII A
CBSE ROLL NO:-
CERTIFICATE
_________________________ _________________________
__________________ ___________
Key Features:
1. Lead and Opportunity Tracking: Efficiently manage leads and opportunities, enabling sales
teams to prioritize efforts and focus on prospects with the highest potential.
3. Sales Forecasting: Utilize data analytics to predict future sales trends, allowing for strategic
planning and resource allocation.
4. Inventory Management: Keep track of product availability, manage stock levels, and prevent
stockouts or overstock situations.
5. Performance Analytics: Access real-time insights into individual and team performance,
enabling data-driven decision-making and continuous improvement.
4. Scalability: As your business grows, a robust Sales Management System can easily scale to
accommodate increased sales volumes and expanding teams.
5. Cost Savings: Streamline processes, reduce errors, and minimize wasted resources, resulting
in cost savings across the sales lifecycle.
System Development Life Cycle
The System Development Life Cycle (SDLC) is a framework that outlines the processes involved in the
development, implementation, and maintenance of information systems or software applications. It
provides a structured approach to guide the planning, creation, testing, deployment, and
maintenance of systems in a systematic and organized manner. The SDLC typically consists of several
phases, each with specific goals and deliverables. While various models exist, the core phases of the
SDLC often include:
1. Planning:
2. Analysis:
3. Design:
● Objectives: Develop a blueprint for the system based on the gathered requirements.
● Activities: Create system architecture, design databases, user interfaces, and system
components; produce detailed technical specifications.
4. Implementation:
● Activities: Write code, develop databases, conduct unit testing, and integrate
components to create a functional system.
5. Testing:
● Objectives: Verify that the system functions as intended and identify and fix any
defects.
● Activities: Conduct various testing phases, including unit testing, integration testing,
system testing, and user acceptance testing.
6. Deployment:
● Activities: Monitor system performance, fix bugs, implement updates, and respond
to user feedback.
The SDLC is not necessarily a linear process; it can follow different models, such as the Waterfall
model, Agile model, or Spiral model, depending on project requirements and organizational
preferences. Each model has its advantages and drawbacks, and the choice often depends on factors
like project size, complexity, and the level of flexibility required.
The SDLC ensures that systems are developed systematically, with a clear understanding of user
needs, efficient use of resources, and the ability to adapt to changes throughout the development
process.
2. Assess Feasibility:
● Conduct feasibility studies to evaluate the practicality and viability of the project.
● Determine the skills and expertise needed for the development team.
● Develop a timeline outlining the various phases of the SDLC, including milestones
and deadlines.
5. Risk Assessment:
● Identify potential risks and challenges that may arise during the development
process.
● Develop a comprehensive project plan that outlines the tasks, responsibilities, and
dependencies of each phase.
● Define the scope of work and create a roadmap for project execution.
7. Obtain Approvals:
● Seek approvals from key stakeholders, including management and project sponsors.
● Ensure that the project plan aligns with organizational goals and expectations.
● Clearly define the scope of the project, including the features and functionalities
that the system will include.
● Define measurable outcomes and objectives that can be used to assess the project's
performance.
The planning phase is essential for providing a roadmap that guides the development team
throughout the project. It helps in aligning the project with organizational objectives, ensuring that
resources are effectively utilized, and minimizing risks. A well-executed planning phase sets the stage
for a successful System Development Life Cycle.
Analysis Phases
The Analysis Phase is a critical stage in the System Development Life Cycle (SDLC) that follows the
Planning Phase. During the analysis phase, the focus shifts from defining project goals and
parameters to understanding and documenting the requirements of the system to be developed.
The primary objectives of the analysis phase include:
1. Gather Requirements:
● Conduct in-depth analysis to gather information about the needs and requirements
of the end-users and stakeholders.
● Document how users currently perform their tasks and identify pain points in the
existing system.
● Align system objectives with the overall goals of the organization and the
expectations of stakeholders.
● Develop use cases and scenarios that describe how users will interact with the
system.
5. Model Data:
● Create data models to represent the structure of the data that the system will
manage.
● Functional requirements describe what the system must do, while non-functional
requirements specify qualities such as performance, security, and usability.
7. Prioritize Requirements:
● Identify critical features and functionalities that must be included in the initial
release.
● Verify that the documented requirements align with the organization's goals and the
expectations of end-users.
9. Feasibility Analysis:
● Assess whether the proposed system is technically and economically feasible based
on the identified requirements.
● Develop detailed system specifications that serve as a basis for the design phase.
The analysis phase is crucial for ensuring that the development team has a comprehensive
understanding of what the system needs to accomplish. A thorough analysis helps prevent
misunderstandings, reduces the likelihood of rework in later phases, and lays the groundwork for a
successful design and implementation. The deliverables of the analysis phase often include
requirement documents, use cases, data models, and a clear understanding of the scope of the
system.
Design Phase
The Design Phase is a crucial stage in the System Development Life Cycle (SDLC) that follows the
Analysis Phase. During this phase, the requirements gathered during analysis are translated into a
detailed blueprint for the construction of the system. The primary objectives of the design phase
include creating a plan that specifies how the system will be built and defining its architecture. Here
are key aspects and activities involved in the design phase:
1. System Architecture:
● Identify subsystems and their interactions, defining the overall system framework.
2. Database Design:
4. System Specifications:
● Refine and elaborate on the system specifications produced during the analysis
phase.
● Identify the technologies, frameworks, and tools that will be used in the
development process.
● Plan and design the network architecture if the system involves distributed
components or relies on network communication.
7. Security Design:
● Incorporate security measures into the system design.
8. Prototyping:
9. Integration Planning:
11. Documentation:
● Include system architecture diagrams, data flow diagrams, and other relevant
documentation.
The design phase is crucial for providing a detailed roadmap for developers and ensuring that the
system is architecturally sound and aligned with user requirements. A well-executed design phase
contributes to the overall success of the project by minimizing the likelihood of errors, reducing
development time, and facilitating a smoother implementation process.
Implementation Phase
The Implementation Phase is a pivotal stage in the System Development Life Cycle (SDLC) where the
designs created in the previous phases are turned into a working system. This phase involves actual
coding, development, integration of system components, and preparing for the transition to the
production environment. Key activities and considerations during the implementation phase include:
1. Coding:
● Write the actual code for the system based on the detailed specifications provided in
the design phase.
2. Database Implementation:
● Create and implement the database structure based on the design specifications.
3. Unit Testing:
4. Integration Testing:
● Perform integration testing to ensure that the integrated components work together
seamlessly.
5. System Testing:
● Test the entire system as a whole to validate its functionality against the defined
requirements.
● Identify and address any issues that arise during system testing.
● Engage end-users in UAT to validate that the system meets their needs and
expectations.
7. Data Migration:
● If applicable, migrate data from any existing systems to the new system.
8. Documentation Update:
● Update documentation to reflect any changes made during the implementation
phase.
9. Training:
● Provide training sessions for end-users to familiarize them with the new system.
● Develop a deployment plan outlining the steps and processes for transitioning the
system to the production environment.
12. Deployment:
● Monitor the deployment process and address any issues that may arise.
● Gather feedback from users and stakeholders to identify areas for improvement.
● Hand over the system to the maintenance and support team for ongoing
monitoring, updates, and support.
The implementation phase is a critical step in bringing the envisioned system to life. It involves
collaborative efforts among developers, testers, and other stakeholders to ensure a smooth
transition from development to production. Careful attention to detail and thorough testing during
this phase contributes to the overall success and stability of the system.
Testing Phase
The Testing Phase in the System Development Life Cycle (SDLC) is a critical stage where the system
undergoes comprehensive testing to ensure its functionality, reliability, and compliance with
requirements. The primary goal of testing is to identify and rectify defects, ensuring that the system
meets the specified criteria before deployment. Here are key activities and considerations during the
testing phase:
1. Unit Testing:
2. Integration Testing:
3. System Testing:
● Activities: Test the system as a whole to ensure that it meets the specified
requirements. This includes functional and non-functional testing.
4. Functional Testing:
● Objective: Verify that the system functions according to the defined requirements.
● Activities: Conduct tests to validate specific features, business processes, and use
cases outlined in the requirements.
5. Non-Functional Testing:
● Activities: Conduct performance testing, security testing, usability testing, and other
relevant non-functional tests.
● Objective: Confirm that the system meets user expectations and business needs.
● Activities: Engage end-users to perform tests and provide feedback. Ensure that the
system aligns with user requirements and is ready for deployment.
7. Regression Testing:
● Objective: Ensure that new changes or fixes do not adversely affect existing
functionalities.
8. Smoke Testing:
● Objective: Verify that the essential functionalities of the system work correctly after
each build.
9. Compatibility Testing:
● Objective: Ensure that the system works correctly across different devices,
browsers, and operating systems.
● Activities: Conduct tests to measure response times, resource usage, and system
stability under different scenarios.
● Objective: Evaluate the user interface for ease of use and overall user satisfaction.
● Activities: Gather feedback from end-users regarding the system's user interface,
navigation, and overall user experience.
● Objective: Validate the flow and functionality of the entire system from start to
finish.
● Activities: Test the complete business processes to ensure seamless integration of
all components.
● Activities: Use a defect tracking system to manage and prioritize the resolution of
identified issues.
● Activities: Provide stakeholders with a summary of test results and seek their
approval to move to the next phase.
The testing phase is crucial for ensuring the reliability and quality of the system. Rigorous testing
helps identify and address issues early in the development process, reducing the likelihood of
defects reaching the production environment. Successful completion of the testing phase indicates
that the system is ready for deployment and use by end-users.
Deployment Phase
The Deployment Phase in the System Development Life Cycle (SDLC) is the stage where the
developed system is released and made available for use by end-users in the production
environment. The primary goal is to transition from the development and testing environments to a
live, operational state. The deployment phase involves several activities and considerations:
1. Deployment Planning:
● Develop a detailed deployment plan outlining the steps and processes for
transitioning the system to the production environment.
● Specify roles and responsibilities for team members involved in the deployment
process.
2. Data Migration:
● If applicable, migrate data from any existing systems to the new system.
● Confirm that hardware, software, and network configurations are in place and meet
the system requirements.
● Define rollback procedures in case issues arise during or after deployment, allowing
a return to the previous state.
5. User Training:
● Conduct training sessions for end-users to familiarize them with the new system.
7. Deployment Execution:
● Execute the deployment plan, following the specified steps and timelines.
● Verify that the deployed system functions correctly in the production environment.
9. Post-Deployment Support:
● Provide immediate post-deployment support to address any issues that may arise.
● Ensure that documentation accurately reflects the configuration of the live system.
● Hand over the responsibility for ongoing monitoring, updates, and support to the
maintenance team.
● Confirm with end-users that the deployed system meets their expectations.
● Officially close the deployment phase, signifying the successful transition of the
system to the production environment.
The deployment phase is a critical step in the SDLC, marking the culmination of the development
process and the beginning of the system's operational life. A well-executed deployment ensures a
smooth transition and minimizes disruptions to business operations. Continuous monitoring and
support during the post-deployment phase contribute to the overall success and stability of the
system in the production environment.
Maintenance Phase
The Maintenance Phase is the final stage in the System Development Life Cycle (SDLC), following the
deployment of the system in the production environment. This phase is characterized by ongoing
activities aimed at supporting, enhancing, and ensuring the continued functionality of the system.
The primary objectives of the maintenance phase include:
● Continuously monitor the system's performance to identify and address any issues
that may impact its efficiency.
● Optimize the system for improved response times, resource utilization, and overall
performance.
2. Bug Fixes:
● Address and fix any bugs or defects identified during the deployment or discovered
during system usage.
3. Security Updates:
● Stay vigilant for potential security vulnerabilities and apply necessary updates and
patches to maintain the system's security.
4. User Support:
5. Data Maintenance:
● Regularly perform data checks and maintenance tasks to ensure data integrity and
accuracy.
6. Adaptation to Changes:
8. Documentation Maintenance:
9. Technology Updates:
● Conduct regression testing to ensure that new changes or updates do not introduce
unintended side effects or issues.
● Develop a plan for retiring the system when it reaches the end of its useful life.
● Solicit feedback from end-users and stakeholders for insights into system
performance and user satisfaction.
● Make informed decisions about allocating resources based on the system's ongoing
value to the organization.
The maintenance phase is a continuous cycle that ensures the system remains reliable, secure, and
aligned with organizational goals. It extends throughout the system's operational life, adapting to
changes in technology, user needs, and the business environment. Effective maintenance practices
contribute to the long-term success and sustainability of the system within the organization.
Testing Phase
The Testing Phase in the System Development Life Cycle (SDLC) is a critical stage where the
developed system undergoes various testing activities to ensure its functionality, reliability, and
compliance with specified requirements. The primary goal of testing is to identify and rectify defects
or issues before the system is deployed to the production environment. The testing phase involves
several key activities:
1. Unit Testing:
2. Integration Testing:
3. System Testing:
● Activities: Test the system as a whole to ensure that it meets the specified
requirements. This includes functional and non-functional testing.
4. Functional Testing:
● Objective: Verify that the system functions according to the defined requirements.
● Activities: Conduct tests to validate specific features, business processes, and use
cases outlined in the requirements.
5. Non-Functional Testing:
● Activities: Conduct performance testing, security testing, usability testing, and other
relevant non-functional tests.
● Objective: Confirm that the system meets user expectations and business needs.
● Activities: Engage end-users to perform tests and provide feedback. Ensure that the
system aligns with user requirements and is ready for deployment.
7. Regression Testing:
● Objective: Ensure that new changes or fixes do not adversely affect existing
functionalities.
8. Smoke Testing:
● Objective: Verify that the essential functionalities of the system work correctly after
each build.
9. Compatibility Testing:
● Objective: Ensure that the system works correctly across different devices,
browsers, and operating systems.
● Activities: Conduct tests to measure response times, resource usage, and system
stability under different scenarios.
● Objective: Evaluate the user interface for ease of use and overall user satisfaction.
● Activities: Gather feedback from end-users regarding the system's user interface,
navigation, and overall user experience.
● Activities: Use a defect tracking system to manage and prioritize the resolution of
identified issues.
● Activities: Provide stakeholders with a summary of test results and seek their
approval to move to the next phase.
The testing phase is a crucial aspect of the SDLC, helping to ensure the quality, reliability, and
performance of the developed system. Thorough testing reduces the likelihood of defects reaching
the production environment and contributes to the overall success of the project.
Testing Method
A comprehensive testing strategy is essential for ensuring the quality, reliability, and effectiveness of
a system throughout the System Development Life Cycle (SDLC). The strategy encompasses a variety
of testing methods, techniques, and best practices to address different aspects of the system. Here is
a comprehensive testing strategy for the SDLC:
1. Requirement Analysis:
2. Test Planning:
● Develop a comprehensive test plan outlining the testing approach, scope, objectives,
resources, schedule, and deliverables.
● Identify testing environments and tools.
3. Testing Types:
● Unit Testing:
● Integration Testing:
● System Testing:
● Acceptance Testing:
4. Testing Levels:
● Static Testing:
● Dynamic Testing:
5. Testing Methods:
● Focus on testing the internal structures, code, and paths of the system.
6. Testing Artifacts:
● Create test scripts for automated testing, particularly for regression testing.
7. Automation Testing:
● Use tools for test automation, such as Selenium for web applications or JUnit for unit
testing.
8. Regression Testing:
● Conduct regression testing after each code change or update to ensure existing
functionalities remain intact.
9. Performance Testing:
● Assess the system's performance under various conditions, including load, stress,
and scalability.
● Evaluate the user interface for ease of use and overall user satisfaction.
● Provide training for testing team members to enhance their skills and knowledge.
● Keep the team updated on industry best practices and emerging trends.
18. Exit Criteria and Sign-Off:
By integrating these elements into the SDLC, organizations can establish a robust testing strategy
that ensures the delivery of a high-quality and reliable system to end-users. The strategy should be
adaptable to project-specific needs and evolving requirements.
1. Unit Testing:
2. Integration Testing:
3. System Testing:
4. Path Testing:
● Test each possible path through the code to identify potential logical errors.
● Ensure that every statement and branch is executed at least once during testing.
● Test the flow of control within the code to ensure that statements are executed in
the expected sequence.
6. Branch Coverage:
● Assess the coverage of decision branches within the code to ensure all possible
paths are tested.
7. Statement Coverage:
● Measure the percentage of code statements that have been executed during
testing.
8. Condition Coverage:
● Evaluate the coverage of different conditions and their outcomes within the code.
● Analyze how data is used and manipulated within the code to identify potential
data-related issues.
● Use static analysis tools to analyze the source code without executing it.
● Identify issues such as code smells, coding standards violations, and potential errors.
● Verify that the system behaves correctly for minimum, maximum, and boundary
values.
● Use knowledge of the code and system to explore and identify potential issues.
White box testing is often performed by developers, and it is an integral part of the software
development process. It helps ensure the reliability and correctness of the code by thoroughly
examining the internal structures and logic of the system. While white box testing is crucial, it is
typically complemented by other testing methods, such as black box testing and grey box testing, to
achieve comprehensive test coverage.
Blackbox Testing
Black box testing is a software testing method where the internal workings, code structure, and
implementation details of the system are not known to the tester. The focus is on testing the
system's functionality, behaviour, and adherence to specifications without knowledge of its internal
logic. Black box testing treats the system as a "black box" where inputs are provided, and outputs
are observed, with no visibility into the internal processes. Here are common methods and
techniques used in black box testing:
1. Equivalence Partitioning:
● Group input conditions into classes or partitions and select representative values
from each partition.
● Test cases are designed to cover each partition, reducing the number of test cases
needed.
● Verify that the system behaves correctly for the minimum, maximum, and values
just beyond the limits.
● Design test cases to cover transitions between different states of the system.
● Design test cases based on use cases, user stories, or functional requirements.
6. Scenario Testing:
● Create realistic scenarios representing end-to-end user interactions with the system.
7. Functional Testing:
● Include tests for input validation, output correctness, and adherence to functional
specifications.
8. Non-Functional Testing:
9. Random Testing:
● Testers explore the system based on their intuition, experience, and creativity.
● Verify that the system works correctly across different devices, browsers, and
operating systems.
● Confirm that the system meets user expectations and business requirements.
● Ensure that new changes or updates do not adversely affect existing functionalities.
● Re-run previously conducted tests after modifications to identify and address any
unintended consequences.
● Verify that the essential functionalities of the system work correctly after each build.
● Assess the system's performance under various conditions, including load, stress,
and scalability.
● Conduct tests to measure response times, resource usage, and system stability
under different scenarios.
● Evaluate the user interface for ease of use and overall user satisfaction.
● Gather feedback from end-users regarding the system's user interface, navigation,
and overall user experience.
Black box testing is valuable for assessing the system from an end-user perspective and ensuring that
it behaves as expected without requiring knowledge of the underlying code or internal structures.
Greybox Testing
Grey box testing is a software testing method that combines elements of both black box testing and
white box testing. In grey box testing, the tester has partial knowledge of the internal workings of
the system. This approach allows testers to assess the system's functionality, behaviour, and internal
structures to a limited extent. Grey box testing is particularly useful when the testing team has some
knowledge of the system's internal logic but does not have complete access to the source code.
Here are some common methods and techniques used in grey box testing:
1. Data-Driven Testing:
● Test different data inputs to assess how the system processes and handles data.
2. Database Testing:
● Examine and manipulate the database directly to verify data integrity, accuracy, and
consistency.
● Assess how the application interacts with the database.
3. API Testing:
4. Functional Testing:
● Design test cases that exercise various functionalities without detailed knowledge of
the internal code.
5. Behavioural Testing:
● Testers observe and analyze how the system responds to inputs and stimuli.
● Identify possible paths and transitions based on partial knowledge of the internal
logic.
7. Code-Based Testing:
● Use partial knowledge of the code to design test cases that focus on specific code
paths or modules.
8. Error Guessing:
● Make educated guesses about potential errors or weak points in the system based
on partial knowledge.
9. Adaptive Testing:
● Adjust testing approaches based on feedback and insights gained during testing.
● Examine parts of the code, especially those relevant to the testing scope.
● Look for potential issues, logical errors, or areas that require additional testing.
● Use code profiling tools to gather information about code execution, resource
utilization, and performance.
● Review trace logs or outputs to understand the flow of execution and identify
potential areas of concern.
Grey box testing allows testers to strike a balance between the external perspective of black box
testing and the internal insight of white box testing. It is particularly beneficial when the testing
team has some knowledge of the internal logic but lacks complete access to the source code or
detailed design. This approach helps uncover defects, assess system behaviour, and improve test
coverage.
Source Code
import customtkinter as ctk
from PIL import Image
import tkinter as tk
import mysql.connector
from tkinter import messagebox, ttk
import tkcalendar as tkc
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import pandas as pd
ctk.set_appearance_mode("light")
ctk.set_default_color_theme("blue")
cou = 0
def startup():
global cou
try:
global host, use, passss
a = pd.read_csv("C:\\ProgramData\\Sales_management_log.csv")
host = a.iloc[0, 1]
use = a.iloc[1, 1]
passss = a.iloc[2, 1]
connection = mysql.connector.connect(host=host, user=use, password=passss)
cursor = connection.cursor()
print(
"_________________________________________MySQL connected "
"successfully_________________________________________")
except:
if cou == 0:
print(
"_________________________________________Enter login "
"credentials_________________________________________")
else:
print(
"_________________________________________Invalid login "
"credentials_________________________________________")
host = input("Enter host: ")
use = input("Enter user: ")
passss = input("Enter password: ")
log = pd.DataFrame(data=[host, use, passss])
log.to_csv("C:\\ProgramData\\Sales_management_log.csv")
cou += 1
startup()
def db(query):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(query)
mydb.commit()
mydb.close()
except mysql.connector.Error as e:
messagebox.showerror(title="Error while Execution", message=e)
def user_details():
global acc_name, user_name, pwd, dob, gender, designation, email, about_info,
user_id
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
curr.execute(f"SELECT * From USER where uname= '{user_id}';")
a = curr.fetchall()
acc_name = a[0][0]
user_name = a[0][1]
pwd = a[0][2]
dob = a[0][3]
gender = a[0][4]
designation = a[0][5]
email = a[0][6]
about_info = a[0][7]
mydb.close()
def intialize():
query_user = ("Create table if not exists User(account_holder varchar(50),uname
varchar(50) unique,pwd varchar("
"50),dob date,Gender varchar(6),Designation varchar(25),email
varchar(75),About text(250));")
query_inventory = ("Create table if not exists inventory(product_id char(5)
primary key,product_name varchar(50) ,"
"price int,amount int);")
query_employees = ("Create table if not exists employee(employee_id char(4)
primary key,employee_name varchar(50),"
"department varchar(30));")
query_order = ("Create table if not exists orders(product_id
char(5),product_name varchar(50),amount int,"
"employee_id char(4),Date date,Foreign key(product_id)
references inventory(Product_id) on update "
"cascade,Foreign key (employee_id) references
employee(employee_id) on update cascade);")
db(query_user)
db(query_inventory)
db(query_employees)
db(query_order)
# insert-command
insert_user1 = "Insert ignore into user(uname,pwd) values('root','root');"
insert_user = "Insert ignore into user(account_holder,uname,pwd,dob) values(%s,
%s,%s,%s);"
list_user = [("'Subhashish'", "'Subhashish'", 1234, "'2006-06-28'"),
("'Shaurya'", "'Shaurya'", 1234, "'2005-04-25'"), ("'Shriyansh'",
"'Shriyansh'", 1234, "'2006-07-21'")]
db(insert_user1)
for x in range(0, 3, 1):
query = (insert_user % list_user[x])
db(query)
class login_window(ctk.CTk):
global user_id, count
count = 0
def __init__(self):
super().__init__()
self._set_appearance_mode("dark")
self.title("Welcome")
s_width = self.winfo_screenwidth()
s_height = self.winfo_screenheight()
width = 600
height = 500
width_position = ((s_width / 2) - width / 2)
height_position = ((s_height / 2) - height / 2)
self.geometry("%dx%d+%d+%d" % (width, height, width_position,
height_position))
self.resizable(width=False, height=False)
img = ctk.CTkImage(light_image=Image.open("black and white hexagon.jpg"),
dark_image=Image.open("black and white hexagon.jpg"),
size=(600, 500))
self.frame = ctk.CTkFrame(master=self, width=600, height=500)
self.frame.place(relx=0, rely=0)
self.bg = ctk.CTkLabel(self.frame, 600, 500, image=img, text="")
self.bg.place(relx=0, rely=0)
if count == 0: # first-try
self.rf = ctk.CTkFrame(self, 300, 500, corner_radius=10,
fg_color="#191717", bg_color="#191717")
self.rf.place(relx=0.5, rely=0)
self.welcome = ctk.CTkLabel(self.rf, text="Welcome",
text_color="#CCC8AA", font=("Broadway", 25, "bold"))
self.welcome.place(relx=0.02, rely=0.13)
self.log = ctk.CTkLabel(self.rf, text="Log In to Your Account",
text_color="#CCC8AA", font=("Broadway", 17))
self.log.place(relx=0.02, rely=0.2)
self.username = ctk.CTkEntry(self.rf, width=280, height=35,
fg_color="white", placeholder_text="Username",
state="normal", corner_radius=10,
border_color="#176B87", border_width=5,
font=("Arial", 17))
self.username.place(relx=0.02, rely=0.33)
self.pwd = ctk.CTkEntry(self.rf, width=280, height=35,
fg_color="white", placeholder_text="Password",
state="normal", corner_radius=10,
border_color="#176B87", border_width=5, show="*",
font=("Arial", 17))
self.pwd.place(relx=0.02, rely=0.43)
self.login = ctk.CTkButton(self.rf, 280, 40, 10, 5, 2, "transparent",
"#164B60", text="Log In",
hover_color="#1B6B93", text_color="#CCC8AA",
font=("Arial", 20),
command=self.details)
self.login.place(relx=0.02, rely=0.55)
self.sign = ctk.CTkButton(self.rf, 280, 40, 10, 5, 2, "transparent",
"#164B60", text="Sign Up",
hover_color="#1B6B93", text_color="#CCC8AA",
font=("Arial", 20),
command=self.new_user)
self.sign.place(relx=0.02, rely=0.65)
elif count == 1: # Autofill
self.rf = ctk.CTkFrame(self, 300, 500, corner_radius=10,
fg_color="#191717", bg_color="#191717")
self.rf.place(relx=0.5, rely=0)
self.welcome = ctk.CTkLabel(self.rf, text="Welcome",
text_color="#CCC8AA", font=("Broadway", 25, "bold"))
self.welcome.place(relx=0.02, rely=0.13)
self.log = ctk.CTkLabel(self.rf, text="Log In to Your Account",
text_color="#CCC8AA", font=("Broadway", 17))
self.log.place(relx=0.02, rely=0.2)
self.username = ctk.CTkEntry(self.rf, width=280, height=35,
fg_color="white", placeholder_text="Username",
state="normal", corner_radius=10,
border_color="#176B87", border_width=5,
font=("Arial", 17))
self.username.place(relx=0.02, rely=0.33)
self.username.insert(0, user_id)
self.pwd = ctk.CTkEntry(self.rf, width=280, height=35,
fg_color="white", placeholder_text="Password",
state="normal", corner_radius=10,
border_color="#176B87", border_width=5, show="*",
font=("Arial", 17))
self.pwd.place(relx=0.02, rely=0.43)
self.login = ctk.CTkButton(self.rf, 280, 40, 10, 5, 2, "transparent",
"#164B60", text="Log In",
hover_color="#1B6B93", text_color="#CCC8AA",
font=("Arial", 20),
command=self.details)
self.login.place(relx=0.02, rely=0.55)
self.sign = ctk.CTkButton(self.rf, 280, 40, 10, 5, 2, "transparent",
"#164B60", text="Sign Up",
hover_color="#1B6B93", text_color="#CCC8AA",
font=("Arial", 20),
command=self.new_user)
self.sign.place(relx=0.02, rely=0.65)
elif count == 2: # new-user
self.rf = ctk.CTkFrame(self, 300, 500, corner_radius=10,
fg_color="#191717", bg_color="#191717")
self.rf.place(relx=0, rely=0)
self.welcome = ctk.CTkLabel(self.rf, text="Welcome",
text_color="#CCC8AA", font=("Broadway", 25, "bold"),
bg_color="#191717")
self.welcome.place(relx=0.02, rely=0.13)
self.log = ctk.CTkLabel(self.rf, text="Enter Your User Details",
text_color="#CCC8AA",
font=("Broadway", 17))
self.log.place(relx=0.02, rely=0.2)
self.nuser_frame = ctk.CTkScrollableFrame(self, 278, 210,
fg_color="#191717", bg_color="#191717",
scrollbar_button_color="#164B60",
scrollbar_button_hover_color="#1B6B93", )
self.nuser_frame.place(relx=0, rely=0.27)
self.NAME = ctk.CTkLabel(self.nuser_frame, width=270, height=15,
fg_color="#191717",
text="Account Holder Name:", font=("Arial",
17), text_color="#CCC8AA",
anchor=ctk.W)
self.NAME.pack()
self.name = ctk.CTkEntry(self.nuser_frame, width=270, height=35,
fg_color="white", placeholder_text="Name",
corner_radius=10, border_color="#176B87",
border_width=5, font=("Arial", 17))
self.name.pack()
self.USERNAME = ctk.CTkLabel(self.nuser_frame, width=270, height=15,
fg_color="#191717", text="Username:",
font=("Arial", 17), text_color="#CCC8AA",
anchor=ctk.W)
self.USERNAME.pack()
self.username = ctk.CTkEntry(self.nuser_frame, width=270, height=35,
fg_color="white",
placeholder_text="Username",
corner_radius=10, border_color="#176B87",
border_width=5, font=("Arial", 17))
self.username.pack()
self.PWD = ctk.CTkLabel(self.nuser_frame, width=270, height=15,
fg_color="#191717", text="Password:",
font=("Arial", 17), text_color="#CCC8AA",
anchor=ctk.W)
self.PWD.pack()
self.pwd = ctk.CTkEntry(self.nuser_frame, width=270, height=35,
fg_color="white",
placeholder_text="Password", show="*",
corner_radius=10, border_color="#176B87",
border_width=5, font=("Arial", 17))
self.pwd.pack()
self.CONFIRMPASSWORD = ctk.CTkLabel(self.nuser_frame, width=270,
height=15, fg_color="#191717",
text="Confirm Password:",
font=("Arial", 17), text_color="#CCC8AA",
anchor=ctk.W)
self.CONFIRMPASSWORD.pack()
self.confirm_pwd = ctk.CTkEntry(self.nuser_frame, width=270, height=35,
fg_color="white",
placeholder_text="Confirm Password",
corner_radius=10,
border_color="#176B87", border_width=5,
font=("Arial", 17))
self.confirm_pwd.pack()
self.DOB = ctk.CTkLabel(self.nuser_frame, width=270, height=15,
fg_color="#191717", text="Date of Birth:",
font=("Arial", 17), text_color="#CCC8AA",
anchor=ctk.W)
self.DOB.pack()
self.dob = tkc.DateEntry(master=self.nuser_frame, font=(None, 12),
selectmode="day")
self.dob.pack()
self.submit = ctk.CTkButton(self.rf, 280, 40, 10, 5, 2, "transparent",
"#164B60", text="SUBMIT",
hover_color="#1B6B93",
text_color="#CCC8AA", font=("Arial", 20),
command=self.submit)
self.submit.place(relx=0.02, rely=0.75)
def close_it(self):
self.quit()
def details(self):
global user_id, passwd
user_id = self.username.get()
passwd = self.pwd.get()
self.destroy()
fetch_login()
def new_user(self):
global count
count = 2
self.destroy()
login_window().mainloop()
def submit(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
global count, user_id
acc_name = self.name.get()
user_id = self.username.get()
pwd = self.pwd.get()
confirm_pwd = self.confirm_pwd.get()
dob = self.dob.get()
if pwd == confirm_pwd:
curr.execute("Select uname from User;")
users = curr.fetchall()
if user_id in users:
self.destroy()
messagebox.showerror(title="Error",
message="Same Username exists
"
" \n\n\n\n\n")
count = 2
login_window().mainloop()
else:
self.destroy()
try:
curr.execute(
f"insert into user(account_holder,uname,pwd,dob)
values('{acc_name}','{user_id}','{pwd}','{dob}');")
mydb.commit()
count = 1
except mysql.connector.Error as e:
messagebox.showerror(title="Error in execution", message=e)
count = 2
login_window().mainloop()
else:
self.destroy()
messagebox.showerror(title="Error",
message="Password Incorrect
"
" \n\n\n\n\n")
count = 2
login_window().mainloop()
mydb.close()
def fetch_login():
global user_id, passwd, count, users_id
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
query = f"select uname,pwd from user where uname = '{user_id}';"
curr.execute(query)
users_id = curr.fetchall()
else:
messagebox.showerror("Error",
"No User found!
\n\n\n\n\n")
mydb.close()
class main_window(ctk.CTk):
def __init__(self):
global acc_name, user_name, pwd, dob, gender, designation, email,
about_info, user_id
# style = ttk.Style()
# style.configure("my.Treeview", background="white", foreground="black",
rowheight=30, fieldbackground="white",
# fone=(None, 100))
# style.map("my.Treeview", background=[("selected", "#001B79")])
super().__init__()
self._set_appearance_mode("dark")
self.title("Sales Management System")
width = 1920
height = 1080
self.geometry("%dx%d+0+0" % (width, height))
self.info = self.tabs.add("Info")
self.inventory = self.tabs.add("Inventory")
self.order = self.tabs.add("Order")
self.employees = self.tabs.add("Employees")
self.dv = self.tabs.add("Data Visualization")
# INFO-Tab
self.frame_info = tk.LabelFrame(self.info, width=1890, height=1000,
text="ACCOUNT DETAILS", font=(None, 15),
bg="white")
self.frame_info.pack(fill=tk.Y, expand=True, anchor=tk.NW)
self.frame = ctk.CTkFrame(self.frame_info, width=1880, height=970,
bg_color="white", fg_color="white")
self.frame.place(relx=0, rely=0)
img = ctk.CTkImage(light_image=Image.open("user.png"),
dark_image=Image.open("user.png"), size=(225, 225))
self.image = ctk.CTkLabel(self.frame, fg_color="#7071E8", width=1880,
height=300, text="", corner_radius=30,
image=img, anchor=ctk.N)
self.image.place(relx=0.0005, rely=0)
self.account_name = ctk.CTkLabel(self.frame, fg_color='#7071E8',
bg_color="#7071E8", width=1880, height=45,
text=f"Hi! {acc_name}", font=("helvetica",
30))
self.account_name.place(relx=0.0005, rely=0.235)
self.details = ctk.CTkFrame(self.frame, fg_color="#C683D7", height=660,
width=1880, corner_radius=30)
self.details.place(relx=0.0005, rely=0.32)
def lg_out(self):
global count
self.destroy()
count = 1
login_window().mainloop()
def update_profile(self):
self.destroy()
update_window().mainloop()
def change_password(self):
self.destroy()
change_password().mainloop()
class update_window(ctk.CTk):
def __init__(self):
super().__init__()
self.title("Update Profile")
s_width = self.winfo_screenwidth()
s_height = self.winfo_screenheight()
width = 500
height = 300
width_position = ((s_width / 2) - width / 2)
height_position = ((s_height / 2) - height / 2)
self.geometry("%dx%d+%d+%d" % (width, height, width_position,
height_position))
self.resizable(width=False, height=False)
self.bg = ctk.CTkFrame(self, height=300, width=500, fg_color="#A6CF98",
bg_color="#A6CF98", corner_radius=10)
self.bg.place(relx=0, rely=0)
self.msg = ctk.CTkLabel(self.bg, text="Kindly Update Your Details",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 30))
self.msg.place(relx=0.15, rely=0)
self.acc_name_label = ctk.CTkLabel(self.bg, text="Account Name:",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 25))
self.acc_name_label.place(relx=0.08, rely=0.13)
self.DOB_label = ctk.CTkLabel(self.bg, text="DOB :",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 25))
self.DOB_label.place(relx=0.08, rely=0.23)
self.Gender_label = ctk.CTkLabel(self.bg, text="Gender :",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 25))
self.Gender_label.place(relx=0.08, rely=0.33)
self.designation_name_label = ctk.CTkLabel(self.bg,
text="Designation :", text_color="black",
fg_color="#A6CF98",
font=("Helvetica", 25))
self.designation_name_label.place(relx=0.08, rely=0.43)
self.email_label = ctk.CTkLabel(self.bg, text="Email :",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 25))
self.email_label.place(relx=0.08, rely=0.53)
self.about_info_label = ctk.CTkLabel(self.bg, text="About :-",
text_color="black", fg_color="#A6CF98",
font=("Helvetica", 25))
self.about_info_label.place(relx=0.08, rely=0.63)
def autofill(self):
global acc_name, dob, gender, designation, email, about_info
DOB = dob
Gender = gender
Designation = designation
list = [acc_name, DOB, Gender, Designation, email, about_info]
num = 0
for x in list:
if x is not None:
if num == 0:
self.acc_name_entry.insert(0, x)
elif num == 1:
self.DOB_entry.insert(0, x)
elif num == 2:
self.Gender_entry.insert(0, x)
elif num == 3:
self.Designation_entry.insert(0, x)
elif num == 4:
self.email_entry.insert(0, x)
elif num == 5:
self.about_info_entry.insert(0, x)
num += 1
def submit(self):
global user_name
a = self.acc_name_entry.get()
b = self.DOB_entry.get()
c = self.Gender_entry.get()
d = self.Designation_entry.get()
e = self.email_entry.get()
f = self.about_info_entry.get()
g = user_name
try:
db(f"UPDATE USER SET
account_holder='{a}',dob='{b}',gender='{c}',designation='{d}',email='{e}',about='{f
}' where uname='{g}'")
self.destroy()
user_details()
main_window().mainloop()
except mysql.connector.Error as e:
self.destroy()
messagebox.showerror(title="ERROR WHILE EXECUTION", message=e)
main_window().mainloop()
class change_password(ctk.CTk):
global users_id
def __init__(self):
super().__init__()
self.title("Change Password")
s_width = self.winfo_screenwidth()
s_height = self.winfo_screenheight()
width = 500
height = 300
width_position = ((s_width / 2) - width / 2)
height_position = ((s_height / 2) - height / 2)
self.geometry("%dx%d+%d+%d" % (width, height, width_position,
height_position))
self.resizable(width=False, height=False)
self.frame = ctk.CTkFrame(self, width=width, height=height,
fg_color="#A6CF98", corner_radius=10)
self.frame.place(relx=0, rely=0)
self.msg = ctk.CTkLabel(self.frame, text="Kindly! Update Your Password",
font=("Helvetica", 30))
self.msg.place(relx=0.1, rely=0.05)
self.pwd = ctk.CTkLabel(self.frame, text="Old Password :",
font=("Helvetica", 20))
self.pwd.place(relx=0.1, rely=0.2)
self.PWD = ctk.CTkEntry(self.frame, width=220, height=30,
placeholder_text="Old Password",
font=("Helvetica", 20))
self.PWD.place(relx=0.47, rely=0.2)
self.new_pwd = ctk.CTkLabel(self.frame, text="New Password :",
font=("Helvetica", 20))
self.new_pwd.place(relx=0.1, rely=0.4)
self.NEW_PWD = ctk.CTkEntry(self.frame, width=220, height=30,
placeholder_text="New Password",
font=("Helvetica", 20), show="*")
self.NEW_PWD.place(relx=0.47, rely=0.4)
self.confirm_pwd = ctk.CTkLabel(self.frame, text="Confirm Password :",
font=("Helvetica", 20))
self.confirm_pwd.place(relx=0.1, rely=0.6)
self.CONFIRM_PWD = ctk.CTkEntry(self.frame, width=220, height=30,
placeholder_text="Confirm Password",
font=("Helvetica", 20))
self.CONFIRM_PWD.place(relx=0.47, rely=0.6)
self.submit = ctk.CTkButton(self.frame, width=80, height=40, text="SUBMIT",
font=("Helvetica", 20),
command=self.submit)
self.submit.place(relx=0.4, rely=0.8)
def submit(self):
a = self.PWD.get()
b = self.NEW_PWD.get()
c = self.CONFIRM_PWD.get()
self.destroy()
if users_id[0][1] == a:
if b == c:
db(f"UPDATE user set pwd='{c}' where uname='{users_id[0][0]}';")
messagebox.showerror(title="Success", message="Password Updated
Successfully\n\n\n")
login_window().mainloop()
else:
messagebox.showerror(title="Incorrect New Password",
message="Entered New Password and Confirm
Password are not correct.\n\n\n")
self.mainloop()
else:
messagebox.showerror(title="Incorrect Old Password", message="Old
Password is INCORRECT.\n\n\n")
self.mainloop()
class inventory(tk.LabelFrame):
def __init__(self, parent):
super().__init__(parent, width=1890, height=1000, text="Inventory",
font=(None, 20), bg="white")
self.tree_frame = ctk.CTkFrame(self, width=1890, height=695)
self.tree_frame.pack(fill=ctk.Y, expand=True)
self.a = ttk.Scrollbar(self.tree_frame)
self.a.pack(fill=tk.Y, expand=True, side=tk.RIGHT)
self.inventory_table = ttk.Treeview(master=self.tree_frame, columns=["1",
"2", "3", "4"],
yscrollcommand=self.a.set,
selectmode="extended")
self.inventory_table.heading("#0", text="")
self.inventory_table.heading("1", text="Product_ID", anchor=ctk.CENTER)
self.inventory_table.heading("2", text="Product_Name", anchor=ctk.CENTER)
self.inventory_table.heading("3", text="Price", anchor=ctk.CENTER)
self.inventory_table.heading("4", text="Amount", anchor=ctk.CENTER)
self.inventory_table.column("#0", width=0, stretch=tk.NO)
self.inventory_table.column("1", width=470, minwidth=400,
anchor=ctk.CENTER, stretch=tk.YES)
self.inventory_table.column("2", width=470, minwidth=400,
anchor=ctk.CENTER, stretch=tk.YES)
self.inventory_table.column("3", width=470, minwidth=400,
anchor=ctk.CENTER, stretch=tk.YES)
self.inventory_table.column("4", width=470, minwidth=400,
anchor=ctk.CENTER, stretch=tk.YES)
self.inventory_table.tag_configure("odd", background="#6DB9EF")
self.inventory_table.tag_configure("even", background="white")
self.add_data()
self.inventory_table.pack(fill=tk.BOTH, expand=1, side=tk.LEFT)
self.inventory_table.bind("<ButtonRelease-1>", self.select_record)
def load(self):
self.Product_ID.configure(state=ctk.DISABLED)
self.Product_Name.configure(state=ctk.NORMAL)
self.Price.configure(state=ctk.NORMAL)
self.Amount.configure(state=ctk.NORMAL)
def clear_fun(self):
self.Product_ID.configure(state=ctk.NORMAL)
self.Product_Name.configure(state=ctk.NORMAL)
self.Price.configure(state=ctk.NORMAL)
self.Amount.configure(state=ctk.NORMAL)
self.Product_ID.delete(0, ctk.END)
self.Product_Name.delete(0, ctk.END)
self.Price.delete(0, ctk.END)
self.Amount.delete(0, ctk.END)
def add_data(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
curr.execute("SELECT * FROM INVENTORY order by abs(product_id)")
table = curr.fetchall()
# print(table)
num = 0
for i in table:
if num % 2 == 0:
self.inventory_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2], i[3]),
tags="even")
# print(i)
else:
self.inventory_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2], i[3]),
tags="odd")
# print(i)
num += 1
def add_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"insert into inventory
values('{self.Product_ID.get()}','{self.Product_Name.get()}',{self.Price.get()},
{self.Amount.get()});")
messagebox.showerror(title="Message", message="Item added
successfully")
mydb.commit()
mydb.close()
for i in self.inventory_table.get_children():
self.inventory_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def remove_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM INVENTORY WHERE
product_id='{self.Product_ID.get()}';")
messagebox.showerror(title="Message", message="Item removed
successfully")
mydb.commit()
mydb.close()
for i in self.inventory_table.get_children():
self.inventory_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def update_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"UPDATE INVENTORY set product_name =
'{self.Product_Name.get()}',price={self.Price.get()},amount={self.Amount.get()}
where product_id='{self.Product_ID.get()}';")
messagebox.showerror(title="Message", message="Items Updated
successfully")
mydb.commit()
mydb.close()
for i in self.inventory_table.get_children():
self.inventory_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def remove_all(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM INVENTORY;")
messagebox.showerror(title="Message", message="All Items removed
successfully")
mydb.commit()
mydb.close()
for i in self.inventory_table.get_children():
self.inventory_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
class employees(tk.LabelFrame):
def __init__(self, parent):
super().__init__(parent, width=1890, height=1000, text="Employee Profile",
font=(None, 20), bg="white")
self.tree_frame = ctk.CTkFrame(self, width=1890, height=695)
self.tree_frame.pack(fill=ctk.Y, expand=True)
self.a = ttk.Scrollbar(self.tree_frame)
self.a.pack(fill=tk.Y, expand=True, side=tk.RIGHT)
self.employee_table = ttk.Treeview(master=self.tree_frame, columns=["1",
"2", "3"],
yscrollcommand=self.a.set,
selectmode="extended")
self.employee_table.heading("#0", text="")
self.employee_table.heading("1", text="Employee_ID", anchor=ctk.CENTER)
self.employee_table.heading("2", text="Employee_Name", anchor=ctk.CENTER)
self.employee_table.heading("3", text="Department", anchor=ctk.CENTER)
self.employee_table.column("#0", width=0, stretch=tk.NO)
self.employee_table.column("1", width=626, minwidth=600, anchor=ctk.CENTER,
stretch=tk.YES)
self.employee_table.column("2", width=626, minwidth=600, anchor=ctk.CENTER,
stretch=tk.YES)
self.employee_table.column("3", width=626, minwidth=600, anchor=ctk.CENTER,
stretch=tk.YES)
self.employee_table.tag_configure("odd", background="#6DB9EF")
self.employee_table.tag_configure("even", background="white")
self.add_data()
self.employee_table.pack(fill=tk.BOTH, expand=1, side=tk.LEFT)
self.employee_table.bind("<ButtonRelease-1>", self.select_record)
self.edit_frame = tk.LabelFrame(self, text="Data Control", width="1880",
height="225",
font=(None, 18), bg="white")
self.edit_frame.place(relx=0.004, rely=0.76)
def load(self):
self.Employee_ID.configure(state=ctk.DISABLED)
self.Employee_Name.configure(state=ctk.NORMAL)
self.Department.configure(state=ctk.NORMAL)
def clear_fun(self):
self.Employee_ID.configure(state=ctk.NORMAL)
self.Employee_Name.configure(state=ctk.NORMAL)
self.Department.configure(state=ctk.NORMAL)
self.Employee_ID.delete(0, ctk.END)
self.Employee_Name.delete(0, ctk.END)
self.Department.delete(0, ctk.END)
def add_data(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
curr.execute("SELECT * FROM employee order by abs(Employee_ID)")
table = curr.fetchall()
# print(table)
num = 0
for i in table:
if num % 2 == 0:
self.employee_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2]),
tags="even")
# print(i)
else:
self.employee_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2]),
tags="odd")
# print(i)
num += 1
def add_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"insert into employee
values('{self.Employee_ID.get()}','{self.Employee_Name.get()}','{self.Department.ge
t()}');")
messagebox.showerror(title="Message", message="Employee Profile added
successfully")
mydb.commit()
mydb.close()
for i in self.employee_table.get_children():
self.employee_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def remove_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM EMPLOYEE WHERE
Employee_ID='{self.Employee_ID.get()}';")
messagebox.showerror(title="Message", message="Employee Profile removed
successfully")
mydb.commit()
mydb.close()
for i in self.employee_table.get_children():
self.employee_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def update_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"UPDATE EMPLOYEE set Employee_Name =
'{self.Employee_Name.get()}',Department='{self.Department.get()}' where
Employee_ID='{self.Employee_ID.get()}';")
messagebox.showerror(title="Message", message="Employee Profile Updated
successfully")
mydb.commit()
mydb.close()
for i in self.employee_table.get_children():
self.employee_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def remove_all(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM Employee;")
messagebox.showerror(title="Message", message="All Employee Profiles
removed successfully")
mydb.commit()
mydb.close()
for i in self.employee_table.get_children():
self.employee_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
class order(tk.LabelFrame):
def __init__(self, parent):
super().__init__(parent, width=1890, height=1000, text="Order", font=(None,
20), bg="white")
self.tree_frame = ctk.CTkFrame(self, width=1890, height=695)
self.tree_frame.pack(fill=ctk.Y, expand=True)
self.a = ttk.Scrollbar(self.tree_frame)
self.a.pack(fill=tk.Y, expand=True, side=tk.RIGHT)
self.order_table = ttk.Treeview(master=self.tree_frame, columns=["1", "2",
"3", "4", "5"],
yscrollcommand=self.a.set,
selectmode="extended")
self.order_table.heading("#0", text="")
self.order_table.heading("1", text="Product_ID", anchor=ctk.CENTER)
self.order_table.heading("2", text="Product_Name", anchor=ctk.CENTER)
self.order_table.heading("3", text="Amount", anchor=ctk.CENTER)
self.order_table.heading("4", text="Employee_ID", anchor=ctk.CENTER)
self.order_table.heading("5", text="Date of Purchase", anchor=ctk.CENTER)
self.order_table.column("#0", width=0, stretch=tk.NO)
self.order_table.column("1", width=375, minwidth=350, anchor=ctk.CENTER,
stretch=tk.YES)
self.order_table.column("2", width=375, minwidth=350, anchor=ctk.CENTER,
stretch=tk.YES)
self.order_table.column("3", width=375, minwidth=350, anchor=ctk.CENTER,
stretch=tk.YES)
self.order_table.column("4", width=375, minwidth=350, anchor=ctk.CENTER,
stretch=tk.YES)
self.order_table.column("5", width=375, minwidth=350, anchor=ctk.CENTER,
stretch=tk.YES)
self.order_table.tag_configure("odd", background="#6DB9EF")
self.order_table.tag_configure("even", background="white")
self.add_data()
self.order_table.pack(fill=tk.BOTH, expand=1, side=tk.LEFT)
self.order_table.bind("<ButtonRelease-1>", self.select_record)
def search(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
id = self.Product_ID.get()
# print(id)
curr.execute(f"SELECT product_name FROM inventory where product_id =
'{id}'")
table = curr.fetchall()
self.Product_Name.configure(state=ctk.NORMAL)
self.Product_Name.delete(0, ctk.END)
self.Product_Name.insert(0, table[0][0])
self.Product_Name.configure(state=ctk.DISABLED)
mydb.close()
def load(self):
self.Amount.configure(state=ctk.NORMAL)
self.Employee_ID.configure(state=ctk.NORMAL)
self.Date.configure(state=ctk.NORMAL)
def clear_fun(self):
self.Product_ID.configure(state=ctk.NORMAL)
self.Product_Name.configure(state=ctk.NORMAL)
self.Amount.configure(state=ctk.NORMAL)
self.Employee_ID.configure(state=ctk.NORMAL)
self.Date.configure(state=ctk.NORMAL)
self.Product_ID.delete(0, ctk.END)
self.Product_Name.delete(0, ctk.END)
self.Amount.delete(0, ctk.END)
self.Employee_ID.delete(0, ctk.END)
self.Date.delete(0, ctk.END)
def add_data(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
curr.execute("SELECT * FROM orders order by date")
table = curr.fetchall()
# print(table)
num = 0
for i in table:
if num % 2 == 0:
self.order_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2], i[3], i[4]),
tags="even")
# print(i)
else:
self.order_table.insert(parent='', index="end", iid=f"{num}",
values=(i[0], i[1], i[2], i[3], i[4]),
tags="odd")
# print(i)
num += 1
def add_record(self):
global amount_value
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
print(int(self.Amount.get()))
if amount_value[0][0] >= int(self.Amount.get()):
tuple1 = (self.Product_ID.get(), self.Product_Name.get(),
int(self.Amount.get()), self.Employee_ID.get(),
self.Date.get())
curr.execute(f"UPDATE INVENTORY SET AMOUNT=AMOUNT-{tuple1[2]} where
PRODUCT_ID='{tuple1[0]}'")
try:
# print(tuple1)
curr.execute(
f"insert into orders values('{tuple1[0]}','{tuple1[1]}',
{tuple1[2]},'{tuple1[3]}','{tuple1[4]}');")
messagebox.showerror(title="Message",
message="Item Purchased successfully.\nThank
You For Your Purchase")
mydb.commit()
mydb.close()
for i in self.order_table.get_children():
self.order_table.delete(i)
self.add_data()
self.clear_fun()
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution",
message=e)
self.clear_fun()
else:
messagebox.showerror(title="Insufficient Amount", message="Insufficient
Amount")
def remove_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM ORDERS WHERE PRODUCT_ID='{self.Product_ID.get()}';")
messagebox.showerror(title="Message", message="Purchase History removed
successfully")
mydb.commit()
mydb.close()
for i in self.order_table.get_children():
self.order_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def update_record(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"UPDATE ORDER SET
AMOUNT={self.Amount.get()},EMPLOYEE_ID='{self.Employee_ID.get()}',DATE='{self.Date.
get()}'")
messagebox.showerror(title="Message", message="Purchase History Updated
successfully")
mydb.commit()
mydb.close()
for i in self.order_table.get_children():
self.order_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
def remove_all(self):
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
try:
curr.execute(
f"DELETE FROM ORDERS;")
messagebox.showerror(title="Message", message="All Purchase History
removed successfully")
mydb.commit()
mydb.close()
for i in self.order_table.get_children():
self.order_table.delete(i)
self.add_data()
except mysql.connector.Error as e:
messagebox.showerror(title="Error Occured while Execution", message=e)
self.clear_fun()
class cal(ctk.CTkToplevel):
def __init__(self, parent, x, y):
super().__init__(parent)
def get_value(parent):
global DOP
parent.Date.delete(0, ctk.END)
DOP = (self.dob.get_date())
parent.Date.insert(0, DOP)
self.destroy()
class data_visualization(tk.LabelFrame):
def __init__(self, parent):
super().__init__(parent, text="DATA VISUALIZATION", width="1900",
height="1000",
font=("Arial", 15))
self.frame1 = graph(self)
self.frame1.grid(row=0, column=0, sticky=ctk.NSEW)
self.frame2 = graph(self)
self.frame2.grid(row=0, column=1, sticky=ctk.NSEW)
self.frame3 = graph(self)
self.frame3.grid(row=1, column=0, sticky=ctk.NSEW)
self.frame4 = graph(self)
self.frame4.grid(row=1, column=1, sticky=ctk.NSEW)
class graph(ctk.CTkFrame):
def __init__(self, parent):
super().__init__(parent, width=948, height=498, fg_color="#ECCDB4",
corner_radius=0)
self.data_dic()
self.option_menu = ctk.CTkOptionMenu(self, values=["Inventory by Product",
"Purchase History", "Total Sales",
"Item Sales"],
command=self.graph_callable,
fg_color="#F0EDD4",
button_color="#FEA1A1", dropdown_hover_color="#ECCDB4",
text_color="black",
button_hover_color="#D25380")
self.option_menu.place(relx=0.02, rely=0.02)
def data_dic(self):
global inv_dict
mydb = mysql.connector.connect(host=host, username=use, passwd=passss,
database="sales_management")
curr = mydb.cursor()
query1 = "select product_name,amount from inventory order by
abs(product_id);"
curr.execute(query1)
query1_tmp = curr.fetchall()
inv_dict = dict((x, y) for x, y in query1_tmp)
# Inventory Graph
self.inv, ax1 = plt.subplots(figsize=(9, 4.2))
ax1.barh(list(inv_dict.keys()), inv_dict.values())
ax1.set_title("Inventory by Product")
ax1.set_xlabel("Product Name")
ax1.set_ylabel("Stock Present")
# Purchase History Graph
self.phis, ax2 = plt.subplots(figsize=(9, 4.2))
plt.xticks(rotation=5, ha="right")
ax2.plot_date(Purchase_history_dict.values(), Purchase_history_dict.keys())
ax2.set_title("Purchase History")
ax2.set_xlabel("Date of Purchase")
ax2.set_ylabel("Item Purchased")
# Item sold graph
self.item_sold, ax3 = plt.subplots(figsize=(9, 4.2))
plt.xticks(rotation=15, ha="right")
ax3.bar(item_sold_dict.keys(), item_sold_dict.values())
ax3.set_title("Item Sold")
ax3.set_xlabel("Items")
ax3.set_ylabel("Amount")
# Total Sales
self.total_sales, ax4 = plt.subplots(figsize=(9, 4.2))
ax4.pie(list(item_totalsales.values()),
labels=list(item_totalsales.keys()), startangle=90)
ax4.set_title("Total Sales by Each Item")
ax4.legend(title=f"Total Sales Rs.{sum(list(item_totalsales.values()))}",
loc="upper right",
bbox_to_anchor=(1, 1), bbox_transform=plt.gcf().transFigure)
if __name__ == '__main__':
startup()
intialize()
login_window().mainloop()
Startup Procedure
Installation (Software)
1. Pycharm (Only for the first time), it is downloadable from ‘www.jetbrains.com’
2. MySQL (Only for the first time), it is downloadable from ‘www.mysql.org’
Installation(Packages)
1. pandas
2. mysql.connector
3. tkinter
4. customtkinter
5. tkcalender
6. pillow
7. matplotlib
System Requirement
Biblography
● Youtube: codemy.com
● Stackoverflow
● GeekforGeek