Professional Documents
Culture Documents
CBSE Project Class XII: Video Library Management System
CBSE Project Class XII: Video Library Management System
MANAGEMENT SYSTEM
Class: XII
Section: B
ACKNOWLEDGEMENT
Adding a CD
In this module, software provides the interface to enter the details of a new CD. This
includes cd number, name, language and availability.
CD Issue
This module allows to issue a CD to a customer by entering the CD number and the
1
customer id. After issuing the availability field of cd table is updated with ‘no’ and this
also updates customer table fields cd number and token. Token 1 denotes customer is
having a cd with him and token 0 denotes customer don’t have a cd with him at present.
CD Return
This module allows to return a cd back to the library. This also updates cd and customer
table.
Modify details of a CD
This module allows to update the details of a cd. It’s possible only if the cd is available
in the library.
Deleting a CD
This asks the administrator to enter the cd number to delete and removes the cd from the
database. It’s possible only if the cd is available.
Registering a customer
This module allows to register a customer by adding details like customer id, name,
telephone and address. The fields cd number and token will be inserted as 0.
Deleting a customer
This asks the administrator to enter the customer id to delete and removes the customer
from the database. It’s possible only if the customer is having any cd with him.
Modifying a customer
This module allows to update the details of a customer.
Exit
This module allows the administrator to come out from the software whenever he is
moving out of his seat. So that unauthorized people cannot handle the things.
2
II. REQUIREMENT ANALYSIS
HARDWARE REQUIREMENTS
RAM : 4GB
Cache : 512 KB
Monitor
Keyboard
SOFTWARE REQUIREMENTS
3
III. SYSTEM SPECIFICATIONS
DATA DESIGN
MySQL Database: lib
Table: cd
Table: cdcust
Python History
The Python programming language was conceived in the late 1980s and was
named after the “BBC TV show Monty Python’s Flying Circus”. Guido van
Rossum started implementing Python at CWI in the Netherlands in December of
1989.
4
Python Constructs
i. Functions
A function in Python is a collection of statements grouped under a name. You
can use it whenever you want to execute all those statements at a time. You can
call it wherever you want and as many times as you want in a program. A
function may return a value.
ii. Classes
Python is an object-oriented language. It supports classes and objects. A class is
an abstract data type. In other words, it is a blueprint for an object of a certain
kind. It holds no values. An object is a real-world entity and an instance of a
class.
iii. Modules
A Python module is a collection of related classes and functions. We have
modules for mathematical calculations, string manipulations, web programming,
and many more. User can define his/her own modules, apart from built-in
modules.
iv. Packages
Python package is a collection of related modules. You can either import a
package or create your own.
v. List
A list is a collection of values. Declared in the CSV (Comma-Separated Values)
format and delimit using square brackets:
arity = [1,2,3]
A list may also contain elements of different types, and the indexing begins at 0.
You can also slice lists; slicing is a way of retrieving some values from it.
vi. Tuple
A tuple is like a list, but it is immutable (you cannot change its values).
pizza = (‘base’, ‘sauce’, ‘cheese’, ‘mushroom’)
vii. Dictionary
A dictionary is a collection of key-value pairs. Declare it using curly braces, and
commas to separate key-value pairs. Also, separate values from keys using a
colon (:).
5
student = {‘Name’: ‘Abc’, ‘Age’: 21}
viii. Comments and Docstrings
Declare comments using an octothorpe (#). However, Python does support
multiline comments using docstring. Also, docstrings are documentation strings
that help explain the code.
#This is a comment
“““
This is a docstring
”””
Python has a lot of other constructs. These include control structures, functions,
exceptions, etc.
Features of Python
The Python programming language is one of the richest languages.
i. Easy
Python is very easy to learn and understand; using this Python tutorial, any
beginner can understand the basics of Python.
ii. Interpreted
It is interpreted (executed) line by line. This makes it easy to test and debug.
iii. Object-Oriented
The Python programming language supports classes and objects. We discussed
these above.
v. Portable
Since it is open-source, you can run Python on Windows, Mac, Linux or any
other platform. Your programs will work without needing to the changed for
every machine.
6
Interface Python with SQL
The Python programming language has powerful features for database
programming. Python supports various databases like MySQL, Oracle,
PostgreSQL, etc. Python also supports Data Definition Language (DDL), Data
Manipulation Language (DML) and Data Query Statements. For database
programming, Python DB-API is a widely used module that provides a database
application programming interface. It’s a standard for database interfaces.
Python Database API supports wide range of database servers like MySQL,
Oracle, PostgreSQL, etc.
Python-MySQL Connectivity
While designing real-life applications, certain situations arise pertaining to
storing some important and necessary information by the user. Usually, the data
inputted by the user along with the generated output is displayed but not stored
because all program execution takes place inside the RAM which is a temporary
memory and as soon as we close the form, its contents (form input and generated
output) get erased. They cannot be retrieved since they are not saved on a hard
disk (or any secondary storage device). Thus, when the application is executed
the second time, it requires a new set of inputs from the user. This limitation can
be overcome by sending output generated and saving the input fetched from the
user in a database created at the back-end of the application. The input is fetched
from the user using Python Interface. This is termed as the Front-End Interface
(Python) of the application. An application usually stores a lot of data in the
form of a database which is not directly accessible to the user. This database is
used by the application to give suitable response to the user. This database is
called Back-End Database (MySQL).
MySQL-CONNECTOR
So, we are integrating MySQL with Python interface for executing any database
applications. To establish connectivity between Python and MySQL, we have to
install MySQL-connector using pip command on the command prompt;
MySQL-connector is an interface for connecting to MySQL database server
from Python. It implements the Python Database API.
Python-MySQL Database Access
MySQL-connector is the Python interface to work with MySQL databases. It
must be imported in Python to work with any MySQL databases. All the SQL
commands are implemented through Python Interface.
7
V. MODULES
Modules in our project along with their associated functions are as follows:
Module Name Purpose Functions
mysql.connnector To establish connection connect( )
between Python and cursor( )
MySQL commit( )
execute( )
fetchone( )
fetchall( )
close( )
tkinter to create the GUI Tk( )
title( )
geometry( )
configure( )
Label( )
place( )
Entry( )
mainloop( )
Button( )
get( )
pack()
Frame( )
Scrollbar( )
destroy( )
Tkinter’s To create intractable showerror( )
tkmessagebox message boxes showinfo( )
User defined Deals with the SQL add ( )
functions based operations display1 ( ), display2 ( )
display3 ( ), search ( )
issue ( ), cdreturn ( )
delete ( ), modifycd ( )
register ( ), display4 ( )
remove ( ), modifyc ( )
stop ( ), menu( )
closingframes( )
valnum( )
valname( )
8
VI. TABLE DESIGN AND STRUCTURE
Table: cd
Sno. Field Name Type/Constraints Purpose
1 cdno int PRIMARY KEY It stores cd number
2 cname char(20) It stores cd name
3 language char(25) It stores cd language
4 avail char(6) It stores the availability os a cd
Table: cdcust
Sno. Field Name Type/Constraints Purpose
1 cusid int PRIMARY KEY It stores customer id
2 cname char(25) It stores customer name
3 tele int It stores telephone number of customer
4 address char(10) It stores address of customer
5 cdno char(30) Stores cd number issued to customer
6 token char(5) Denotes whether customer is having a
cd or not
VII. PROCEDURE/FUNCTION DESCRIPTION
S.No Function Purpose
1 add ( ) For adding a new cd
2 display1 ( ) To display all CD details
3 display2 ( ) To display all available cds
4 display3 ( ) To display all cds of a language
5 search ( ) To search for a CD with name
6 issue ( ) To issue a CD to customer
7 cdreturn ( ) To return CD
8 delete ( ) To delete a CD
9 modifycd ( ) To modify details of a CD
10 register ( ) To register a customer
11 logout ( ) To exit from project
12 menu( ) To display home screen
13 closingframes( ) For closing all frames that’s kept open
14 valname( ) For validating character data with alphabets and space
15 valnum( ) For validating numerical data
16 display4 ( ) To display all customer details
17 remove ( ) To remove a customer
18 modifyc ( ) To modify details of a customer
19 stop ( ) To exit from project
9
VIII. SOURCE CODE
#main program with menu
import os
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
import mysql.connector
def valnum(S):
for i in S:
if i.isdigit() == True:
pass
else:
return -1
return 0
def valname(S):
for i in S:
if i.isalpha() == True or i == ' ':
pass
else:
return -1
return 0
#Function to add a CD
def add():
global D
closingframes()
10
D.place(x=320, y=160)
cdn = Label(D, text = "CD Number", bg='white', fg ="blue" , font = 'Times 18' )
cdn.place(x=10, y=40)
Tcdn = Entry(D, width=30)
Tcdn.place(x=200, y = 50)
cdname = Label(D, text = "CD Name", bg='white', fg ="blue" , font = 'Times 18' )
cdname.place(x=10, y=70)
Tcdname = Entry(D, width=30)
Tcdname.place(x=200, y = 80)
def addp():
if Tcdn.get()=='' or Tcdname.get()=='' or Tlan.get()=='':
messagebox.showerror("Error","Enter data completely")
else:
w1 = valnum(Tcdn.get())
w2 = valname(Tcdname.get())
w3 = valname(Tlan.get())
if w1 == -1:
messagebox.showerror("Error","Wrong CD number")
elif w2 == -1:
messagebox.showerror("Error","Wrong CD name")
elif w3 == -1:
messagebox.showerror("Error","Wrong Language")
else:
cur.execute('select * from CD')
f=0
res = cur.fetchall()
for i in res:
if int(i[0]) == int(Tcdn.get()):
f=1
break
if f == 1:
messagebox.showerror("Error","This CD number already exists")
else:
11
stmt = "insert into CD (cdno,cdname,language,avail) values(%s,%s,%s,%s)"
val = (int(Tcdn.get()), Tcdname.get(),Tlan.get(), 'yes')
cur.execute(stmt,val)
cur.execute("commit")
messagebox.showinfo("","CD added successfully")
con.close()
D.destroy()
But2 = Button(D, text = "Submit", command=addp, bg='black',fg ="white" , font = 'forte 14',
relief=FLAT )
But2.place(x=180, y=150)
mainwin.mainloop()
t1 = ttk.Treeview(D)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","avail")
t1.column("cdno", width=60, minwidth=60,anchor=CENTER)
t1.column("cdname", width=170, minwidth=170,anchor=CENTER)
t1.column("language", width=120, minwidth=120,anchor=CENTER)
t1.column("avail", width=80, minwidth=80,anchor=CENTER)
12
t1.heading("cdname", text="CD Name", anchor=CENTER)
t1.heading("language", text="Language", anchor=CENTER)
t1.heading("avail", text="Available", anchor=CENTER)
i=0
for row in cur:
t1.insert('',i, values=(row[0],row[1],row[2],row[3]))
i = i+1
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def treeclose():
con.close()
D.destroy()
tb1 = Button(D, text = "Close", command=treeclose, bg='black',fg ="white" , font = 'forte 18',
relief=FLAT )
tb1.pack()
t1 = ttk.Treeview(D)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
13
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","avail")
t1.column("cdno", width=80, minwidth=80,anchor=CENTER)
t1.column("cdname", width=125, minwidth=125,anchor=CENTER)
t1.column("language", width=120, minwidth=120,anchor=CENTER)
t1.column("avail", width=100, minwidth=100,anchor=CENTER)
i=0
for row in cur:
t1.insert('',i, values=(row[0],row[1],row[2],row[3]))
i = i+1
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def treeclose2():
con.close()
D.destroy()
14
L2.pack()
Lan = Label(D, text = "Enter Language to Search", bg='white', fg ="red" , font = 'Times 10' )
Lan.pack()
TLan = Entry(D, width=40)
TLan.pack()
def searchp():
if TLan.get() == '':
messagebox.showerror("Error","Enter language to search")
else:
e1 = valname(TLan.get())
if e1 == -1:
messagebox.showerror("Error","Wrong language")
else:
s="select * from CD where language=%s"
v=(TLan.get(),)
cur.execute(s,v)
for i in t1.get_children():
t1.delete(i)
i=0
for row in cur:
t1.insert('',i, values=(row[0],row[1],row[2],row[3]))
i = i+1
t1 = ttk.Treeview(D)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","available")
t1.column("cdno", width=80, minwidth=80,anchor=CENTER)
t1.column("cdname", width=100, minwidth=100,anchor=CENTER)
t1.column("language", width=100, minwidth=100,anchor=CENTER)
t1.column("available", width=80, minwidth=80,anchor=CENTER)
vsb=ttk.Scrollbar(D,orient='vertical')
15
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def treeclose3():
con.close()
D.destroy()
Lcdname = Label(D, text = "Enter CD Name to Search", bg='white', fg ="red" , font = 'Times
10' )
Lcdname.pack()
Tcdname = Entry(D, width=40)
Tcdname.pack()
def searchp():
if Tcdname.get() == '':
messagebox.showerror("Error","Enter CD Name")
else:
e1 = valname(Tcdname.get())
if e1 == -1:
messagebox.showerror("Error","Wrong CD Name")
else:
s="select * from CD where cdname=%s"
v=(Tcdname.get(),)
16
cur.execute(s,v)
for i in t1.get_children():
t1.delete(i)
i=0
for row in cur:
t1.insert('',i, text='', values=(row[0],row[1],row[2],row[3]))
i = i+1
t1 = ttk.Treeview(D)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","available")
t1.column("cdno", width=60, minwidth=60,anchor=CENTER)
t1.column("cdname", width=150, minwidth=150,anchor=CENTER)
t1.column("language", width=100, minwidth=100,anchor=CENTER)
t1.column("available", width=120, minwidth=120,anchor=CENTER)
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def treeclose():
con.close()
D.destroy()
17
D = Frame(mainwin,'', width=750, height=400,bg='white')
D.place(x=320, y=160)
cur.execute("use jean")
cur.execute("create table if not exists cdcust(cusid int primary key, cname char(20), tele
char(10), address char(25), cdno int, token int)")
cur.execute("commit")
Lcdid = Label(D, text = "Enter CD NO. to be isuued", bg='white', fg ="red" , font = 'Times
10' )
Lcdid.pack()
Tcdid = Entry(D, width=40)
Tcdid.pack()
Lcid = Label(D, text = "Enter Customer ID for isuue", bg='white', fg ="red" , font = 'Times
10' )
Lcid.pack()
Tcid = Entry(D, width=40)
Tcid.pack()
def issp():
if Tcid.get() == '' or Tcdid.get() == '':
messagebox.showerror("Error","Enter CD NO. / customer id")
else:
e1 = valnum(Tcdid.get())
e2 = valnum(Tcid.get())
if e1 == -1:
messagebox.showerror("Error","Wrong CD ID")
elif e2 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
s1="select * from CD where cdno=%s"
v1=(Tcdid.get(),)
cur.execute(s1,v1)
for i in t1.get_children():
t1.delete(i)
18
i=0
for row in cur:
t1.insert('',i, values=(row[0],row[1],row[2],row[3]))
i = i+1
t1 = ttk.Treeview(D, height=7)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","avail")
t1.column("cdno", width=80, minwidth=80,anchor=CENTER)
t1.column("cdname", width=130, minwidth=130,anchor=CENTER)
t1.column("language", width=100, minwidth=100,anchor=CENTER)
t1.column("avail", width=150, minwidth=150,anchor=CENTER)
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def issp2():
w2 = valnum(Tcdid.get())
w3 = valnum(Tcid.get())
if w2 == -1:
messagebox.showerror("Error","Wrong CD ID")
elif w3 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
s2="select * from cdcust"
cur.execute(s2)
r2 = cur.fetchall()
19
#Checking whether cd is found and is available to issue
found = 0
av = 0
for i in r:
if int(i[0]) == int(Tcdid.get()):
found = 1
if i[3]=='yes':
av = 1
break
if found == 0:
messagebox.showerror("Error","CD not found")
elif av == 0:
messagebox.showerror("Error","CD is not available to issue")
else:
#Checking whether customer is found and has already taken CD or not
#token = 1 says this customer has already taken a CD
#A customer can take only one CD at a time
fou = 0
a=0
for i in r2:
if int(i[0]) == int(Tcid.get()):
fou = 1
if int(i[5]) == 0:
stmt1 = "update cdcust set cdno=%s, token=%s where cusid=%s"
val1 = (Tcdid.get(), 1, Tcid.get())
cur.execute(stmt1, val1)
cur.execute('commit')
def treeclose4():
con.close()
D.destroy()
20
tb1.pack()
tb2 = Button(D, text = " Issue ", command=issp2, bg='red', fg='white', font='Times 18',
relief=FLAT)
tb2.pack()
#Function to return CD
def cdreturn():
global D
closingframes()
Lcdid = Label(D, text = "Enter CD NO. to be returned", bg='white', fg ="red" , font = 'Times
10' )
Lcdid.pack()
Tcdid = Entry(D, width=40)
Tcdid.pack()
Lcid = Label(D, text = "Enter Customer ID for return", bg='white', fg ="red" , font = 'Times
10' )
Lcid.pack()
Tcid = Entry(D, width=40)
Tcid.pack()
def retp():
if Tcdid.get() == '' or Tcid.get() == '':
messagebox.showerror("Error","Enter CD ID / Customer ID")
else:
e1 = valnum(Tcdid.get())
e2 = valnum(Tcid.get())
if e1 == -1:
messagebox.showerror("Error","Wrong CD ID")
21
elif e2 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
s1="select * from CD where cdno=%s"
v1=(Tcdid.get(),)
cur.execute(s1,v1)
for i in t1.get_children():
t1.delete(i)
i=0
for row in cur:
t1.insert('',i, values=(row[0],row[1],row[2],row[3]))
i = i+1
t1 = ttk.Treeview(D, height=7)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cdno","cdname","language","avail")
t1.column("cdno", width=80, minwidth=80,anchor=CENTER)
t1.column("cdname", width=130, minwidth=130,anchor=CENTER)
t1.column("language", width=100, minwidth=100,anchor=CENTER)
t1.column("avail", width=150, minwidth=150,anchor=CENTER)
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def retp2():
if Tcdid.get() == '' or Tcid.get() == '':
messagebox.showerror("Error","Enter CD ID / Customer ID")
else:
e1 = valnum(Tcdid.get())
e2 = valnum(Tcid.get())
if e1 == -1:
22
messagebox.showerror("Error","Wrong CD ID")
elif e2 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
s2="select * from cdcust"
cur.execute(s2)
r2 = cur.fetchall()
23
if fou == 0:
messagebox.showerror("Error","Customer ID not found")
con.close()
D.destroy()
def treeclose4():
con.close()
D.destroy()
#Function to delete a CD
def delete():
global D
closingframes()
Lcdno = Label(D, text = "Enter CD No. to be Deleted", bg='white', fg ="red" , font = 'Times
18' )
Lcdno.place(x=20, y=60)
Tcdno = Entry(D, width=20)
Tcdno.place(x=320, y = 68)
def delp():
if Tcdno.get() == '':
messagebox.showerror("Error","Enter CD No. to delete")
else:
w6 = valnum(Tcdno.get())
if w6 == -1:
messagebox.showerror("Error","Wrong CD No.")
else:
24
s1 = "select * from CD"
cur.execute(s1)
rows = cur.fetchall()
if found == 0:
messagebox.showerror("Error","CD not found")
elif a == 0:
messagebox.showerror("Error","CD not available to delete")
else:
s = "delete from CD where cdno=%s"
v=(Tcdno.get(),)
cur.execute(s,v)
cur.execute("commit")
messagebox.showinfo("","CD successfully deleted")
con.close()
D.destroy()
Bb2 = Button(D, text = "Delete CD", command=delp, bg='black',fg ="white" , font = 'Times 18',
relief=FLAT )
Bb2.place(x=200, y=130)
Lcdno = Label(D, text = "Enter CD No. to be modified", bg='white', fg ="red" , font = 'Times
16' )
Lcdno.place(x=10, y=60)
Tcdno = Entry(D, width=15)
Tcdno.place(x=260, y = 68)
25
cur=con.cursor(buffered=True)
cur.execute("use lib ")
cur.execute("create table if not exists books(bookid int primary key, bname char(20), author
char(15), publisher char(15), lang char(15), avail char(6))")
cur.execute("commit")
def modb1():
if con.is_connected():
if Tcdno.get() == '':
messagebox.showerror("Error","Enter CD No.")
else:
w6 = valnum(Tcdno.get())
if w6 == -1:
messagebox.showerror("Error","Wrong CD No.")
else:
cur.execute("use jean")
s1 = "select * from CD"
cur.execute(s1)
rows = cur.fetchall()
def modb2():
if Tcdn.get() == '' or Tlan.get() == '':
messagebox.showerror("Error","ENTER FULL DATA")
else:
w2 = valname(Tcdn.get())
26
w3 = valname(Tlan.get())
if w2 == -1:
messagebox.showerror("Error","Wrong CD Name")
elif w3 == -1:
messagebox.showerror("Error","Wrong Language")
else:
stmt = "update CD set cdname=%s, language=%s where cdno=%s"
val = (Tcdn.get(),Tlan.get(), int(Tcdno.get()))
cur.execute(stmt,val)
cur.execute("commit")
messagebox.showinfo("","CD details updated successfully")
con.close()
D.destroy()
But2 = Button(D, text = "Submit", command=modb1, bg='black',fg ="white" , font = 'Times 14',
relief=FLAT )
But2.place(x=370, y=60)
cid = Label(D, text = "Customer ID", bg='white', fg ="red" , font = 'Times 18' )
cid.place(x=10, y=40)
Tcid = Entry(D, width=30)
Tcid.place(x=220, y = 50)
27
cn.place(x=10, y=70)
Tcn = Entry(D, width=30)
Tcn.place(x=220, y = 80)
def regp():
if Tcid.get() == '' or Tcn.get() == '' or Ttel.get() == '' or Tadd.get() == '':
messagebox.showerror("Error","Enter all data")
else:
w1 = valnum(Tcid.get())
w2 = valname(Tcn.get())
w3 = valnum(Ttel.get())
if w1 == -1:
messagebox.showerror("Error","Wrong Customer id")
elif w2 == -1:
messagebox.showerror("Error","Wrong Customer Name")
elif w3 == -1:
messagebox.showerror("Error","Wrong Telephone number")
else:
#Checking whether customer id already exists or not
cur.execute('select * from cdcust')
res = cur.fetchall()
f=0
for i in res:
if int(i[0]) == int(Tcid.get()):
f=1
break
if f == 1:
messagebox.showerror("Error","This Customer id already exists")
else:
stmt = "insert into cdcust (cusid,cname,tele,address, cdno, token) values(%s,%s,%s,
%s,%s,%s)"
val = (int(Tcid.get()), Tcn.get(),Ttel.get(), Tadd.get(), 0, 0)
cur.execute(stmt,val)
cur.execute("commit")
messagebox.showinfo("","Customer registered successfully")
con.close()
D.destroy()
28
But2 = Button(D, text = "Submit", command=regp, bg='black',fg ="white" , font = 'Times 14',
relief=FLAT )
But2.place(x=180, y=220)
t1 = ttk.Treeview(D)
t1['show']='headings'
s=ttk.Style(D)
s.theme_use("clam")
s.configure('.',font=('Times Roman', 8))
s.configure('Treeview.Heading', foreground='blue', font=('Times Roman', 8, 'bold'))
t1['columns'] = ("cusid","cname","tele","address","cdno","token")
t1.column("cusid", width=50, minwidth=50,anchor=CENTER)
t1.column("cname", width=100, minwidth=100,anchor=CENTER)
t1.column("tele", width=70, minwidth=70,anchor=CENTER)
t1.column("address", width=100, minwidth=100,anchor=CENTER)
t1.column("cdno", width=60, minwidth=60,anchor=CENTER)
t1.column("token", width=70, minwidth=70,anchor=CENTER)
i=0
s=''
29
for row in cur:
if int(row[5])==0:
s='No'
else:
s='Yes'
t1.insert('',i, text='', values=(row[0],row[1],row[2],row[3],row[4],s))
i = i+1
vsb=ttk.Scrollbar(D,orient='vertical')
vsb.configure(command=t1.yview)
t1.configure(yscrollcommand=vsb.set)
vsb.pack(fill=Y, side=RIGHT)
t1.pack()
def treeclose():
con.close()
D.destroy()
def delp():
if Tcid.get() == '':
messagebox.showerror("Error","Enter Customer ID")
else:
30
w6 = valnum(Tcid.get())
if w6 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
s1 = "select * from cdcust"
cur.execute(s1)
rows = cur.fetchall()
con.close()
D.destroy()
31
Lcid = Label(D, text = "Enter Customer ID to be modified", bg='white', fg ="red" , font = 'Times
18' )
Lcid.place(x=10, y=60)
Tcid = Entry(D, width=10)
Tcid.place(x=360, y = 68)
def modp1():
con=mysql.connector.connect(host='localhost', database=' lib ', user='root',
password='123456')
cur=con.cursor(buffered=True)
cur.execute("use lib ")
cur.execute("create table if not exists cdcust(cusid int primary key, cname char(20), tele
char(10), address char(25), cdno int, token int)")
cur.execute("commit")
if con.is_connected():
if Tcid.get() == '':
messagebox.showerror("Error","Enter Customer ID")
else:
w6 = valnum(Tcid.get())
if w6 == -1:
messagebox.showerror("Error","Wrong Customer ID")
else:
cur.execute("use jean")
s1 = "select * from cdcust"
cur.execute(s1)
rows = cur.fetchall()
32
Ttel = Entry(D, width=30)
Ttel.place(x=260, y = 180)
def modp2():
if Tcn.get() == '' or Ttel.get() == '' or Tadd.get() == '':
messagebox.showerror("Error","Enter full data")
else:
w2 = valname(Tcn.get())
w3 = valnum(Ttel.get())
if w2 == -1:
messagebox.showerror("Error","Wrong Customer Name")
elif w3 == -1:
messagebox.showerror("Error","Wrong Telephone number")
else:
stmt = "update cdcust set cname=%s, tele=%s, address=%s where cusid=
%s"
val = (Tcn.get(),Ttel.get(), Tadd.get(),int(Tcid.get()))
cur.execute(stmt,val)
cur.execute("commit")
messagebox.showinfo("","Customer details updated successfully")
con.close()
D.destroy()
But2 = Button(D, text = "Submit", command=modp1, bg='black',fg ="white" , font = 'Times 14',
relief=FLAT )
But2.place(x=200, y=100)
33
L1 = Label(mainwin, text = "VIDEO LIBRARY MANAGEMENT SYSTEM", bg='white', fg
="purple" , font = 'Times 30')
L1.place(x=5, y=5)
F = Frame(mainwin, width=25)
F.place(x=10,y=60)
34
B11.pack()
mainwin.mainloop()
menu()
35
IX. OUTPUT SCREENS
Home screen
Adding a CD
36
37
38
39
Displaying all cds
40
Registering a customer
41
Displaying all customers
42
Issuing a CD
Screen after pressing submit button
43
Displaying all cds
44
Displaying all customers
Modifying a cd
45
Displaying all cds
46
Deleting a cd
47
Displaying all cds
Modifying a customer
48
Displaying all customers
49
Returning a cd
50
Displaying all cds
51
X. FUTURE ENHANCEMETS
Aesthetic changes
Can include login screen
Can also include more features
XI. BIBLIOGRAPHY
www.stackoverflow.com
Computer Science with Python by Sumita Arora
www.effbot.com
www.w3schools.com/python
www.learnpython.com
www.programiz.com/python-programming
52