Uploaded by faizansayyed657

student managment form project for clg

advertisement
import mysql.connector
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='create table student_manage(name varchar(20),mobno Varchar(20),dept varchar(20),marks varchar(20))'
mycur=conn.cursor()
mycur.execute(qur)
mycur.close()
conn.close()
import mysql.connector
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
win=Tk()
win.title('STUDENT MANAGEMENT SYSTEM')
win.minsize(width=800,height=600)
win.configure(bg='skyblue')
def add():
name=n1.get()
mobno=m1.get()
dept=d1.get()
marks=mr1.get()
if (name=='' or mobno=='' or dept=='' or marks==''):
messagebox.showinfo('info','Its a compulsory')
else:
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='INSERT INTO stu_pro(name,mobno,dept,marks) VALUES("%s","%s","%s","%s")'%(name,mobno,dept,marks)
mycur=conn.cursor()
mycur.execute(qur)
conn.commit()
mycur.close()
conn.close()
messagebox.showinfo('info','info is added')
n1.set('')
m1.set('')
d1.set('')
mr1.set('')
def result():
root=Tk()
root.geometry('1500x900')
root.configure(bg='skyblue')
def disp():
var5=e9.get()
if (var5==''):
messagebox.showinfo('info','Its a compulsory')
else:
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='select marks from stu_pro WHERE name="%s"'%(var5)
mycur=conn.cursor()
mycur.execute(qur)
result=mycur.fetchone()
result=result[0]
l10.config(text=var5.title()+' Marks='+result+" %")
l9=Label(root,text='Enter Student Name',width=20,
relief='ridge',bd=5,fg='black',
bg='white',font=('times new roman',12,'bold'))
l9.place(x=50,y=40)
var4=StringVar()
e9=Entry(root,bg='white',fg='black',width=40,
bd=5,textvariable=var4,font=('times new roman',12))
e9.place(x=250,y=40)
resbtn=Button(root,text='SHOW RESULT',width=20,command=disp).place(x=300,y=80)
l10=Label(root,text='Result is here',height=2,width=15,
relief='ridge',bd=5,fg='black',
bg='white',font=('times new roman',16,'bold'))
l10.place(x=50,y=120)
root.mainloop()
def show():
treev.delete(*treev.get_children())
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='select * from stu_pro'
mycur=conn.cursor()
mycur.execute(qur)
result=mycur.fetchall()
for i in result:
treev.insert("",'end',values=(i[0],i[1],i[2],i[3]))
mycur.close()
conn.close()
def delete():
var1=tt.get()
if (var1==''):
messagebox.showinfo('info','Its a compulsory')
else:
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='DELETE FROM stu_pro WHERE name="%s"'%(var1)
mycur=conn.cursor()
mycur.execute(qur)
conn.commit()
mycur.close()
conn.close()
messagebox.showinfo('info','info is deleted')
tt.set('')
def select():
var2=updata.get()
if (var2==''):
messagebox.showinfo('info','Its a compulsory')
else:
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='select * from stu_pro where name="%s"'%(var2)
mycur=conn.cursor()
mycur.execute(qur)
result=mycur.fetchall()
for i in result:
e1.insert(0,i[0])
e2.insert(0,i[1])
e3.insert(0,i[2])
e4.insert(0,i[3])
mycur.close()
conn.close()
updata.set('')
def update():
name=n1.get()
mobno=m1.get()
dept=d1.get()
marks=mr1.get()
if (name=='' or mobno=='' or dept=='' or marks==''):
messagebox.showinfo('info','Its a compulsory')
else:
conn=mysql.connector.connect(user='root',password='Faizan@1882',host='localhost',database='project10')
qur='UPDATE stu_pro SET mobno="%s",dept="%s",marks="%s" WHERE name="%s"'%(mobno,dept,marks,name)
mycur=conn.cursor()
mycur.execute(qur)
conn.commit()
mycur.close()
conn.close()
messagebox.showinfo('info','info is updated')
n1.set('')
m1.set('')
d1.set('')
mr1.set('')
def clear():
treev.delete(*treev.get_children())
#main label
lbl=Label(win,text='STUDENT MANAGEMENT SYSTEM',bd=5,relief='ridge',
bg='white',fg='black',font=('times new roman',16,'bold'))
lbl.place(x=268,y=40)
# name label and entry
l1=Label(win,text='NAME',bd=5,width=20,relief='ridge',
bg='white',fg='black',font=('times new roman',12,'bold'))
l1.place(x=190,y=100)
n1=StringVar()
e1=Entry(win,bd=5,width=40,textvariable=n1,relief='ridge',
bg='white',fg='black',font=('times new roman',12,'bold'))
e1.place(x=385,y=100)
## mob no label and entry
l2=Label(win,text='MOBILE NUMBER',bd=5,width=20,relief='ridge',
bg='white',fg='black',font=('times new roman',12,'bold'))
l2.place(x=190,y=140)
m1=StringVar()
e2=Entry(win,bd=5,width=40,relief='ridge',textvariable=m1,bg='white',
fg='black',font=('times new roman',12,'bold'))
e2.place(x=385,y=140)
# dept entry and label
l3=Label(win,text='DEPARTMENT',bd=5,width=20,relief='ridge',
bg='white',fg='black',font=('times new roman',12,'bold'))
l3.place(x=190,y=180)
d1=StringVar()
e3=Entry(win,bd=5,width=40,relief='ridge',textvariable=d1,bg='white',
fg='black',font=('times new roman',12,'bold'))
e3.place(x=385,y=180)
#marks label and entry
l4=Label(win,text='MARKS',bd=5,width=20,relief='ridge',
bg='white',fg='black',font=('times new roman',12,'bold'))
l4.place(x=190,y=220)
mr1=StringVar()
e4=Entry(win,bd=5,width=40,relief='ridge',textvariable=mr1,bg='white',
fg='black',font=('times new roman',12,'bold'))
e4.place(x=385,y=220)
# add exit show result buttons
showbtn=Button(win,text='SHOW',width=20,command=show).place(x=200,y=320)
addbtn=Button(win,text='ADD',width=20,command=add).place(x=500,y=320)
exitbtn=Button(win,text='EXIT',width=20,command=win.destroy).place(x=200,y=360)
relbtn=Button(win,text='RESULT',width=20,command=result).place(x=500,y=360)
# delete label entry button
l5=Label(win,text='Delete by Name >>',width=20,relief='ridge',bd=5,fg='black',
bg='white',font=('times new roman',10,'bold'))
l5.place(x=190,y=400)
tt=StringVar()
e5=Entry(win,bg='white',fg='black',width=40,bd=5,textvariable=tt,font=('times new roman',12))
e5.place(x=385,y=400)
delbtn=Button(win,text='Delete',width=20,command=delete).place(x=300,y=440)
# update ...label entry select and update button
l6=Label(win,text='Update by Name >>',width=20,
relief='ridge',bd=5,fg='black',bg='white',
font=('times new roman',10,'bold'))
l6.place(x=190,y=500)
updata=StringVar()
e6=Entry(win,bg='white',fg='black',width=40,bd=5,
textvariable=updata,font=('times new roman',12))
e6.place(x=385,y=500)
upbtn=Button(win,text='Update',width=20,command=update).place(x=450,y=540)
selbtn=Button(win,text='Select',width=20,command=select).place(x=300,y=540)
# tree view
treev=ttk.Treeview(win,selectmode ='browse',height=20)
treev.place(x=900,y=100,width=450)
treev["columns"] = ("1", "2", "3","4")
treev['show'] = 'headings'
treev.column("1", width = 90, anchor ='c')
treev.column("2", width = 90, anchor ='se')
treev.column("3", width = 90, anchor ='se')
treev.column("4", width = 90, anchor ='se')
treev.heading("1", text ="Name")
treev.heading("2", text ="Mobile No")
treev.heading("3", text ="Dept")
treev.heading("4", text ="Marks")
# clear button
cleartbtn=Button(win,text=' Clear',width=20,command=clear).place(x=1080,y=560)
win.mainloop()
Download