Jovian
⭐️
Sign In
In [7]:
from tkinter import *
from tkinter import ttk
import sqlite3 as sq
import sys
import tkinter.messagebox
from tkinter.filedialog import askopenfilename
from tkinter import ttk
from PIL import Image, ImageTk
from tkcalendar import *
import csv
import tkinter as tk
import ctypes
import time
from time import strftime
from tkinter import simpledialog
LARGE_FONT= ("Arial", 16)
SMALL_FONT= ("Arial", 12)

class Master(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)
    
        container.pack(side=TOP,fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        
        self.frames = {}

        for F in (StartPage, PageOne, PageTwo, PageThree, PageFour, PageFive, LogIn,stlogin,StuFee,StuPage):

            frame = F(container, self)

            self.frames[F] = frame

            frame.grid(row=0, column=0,sticky=N+S+E+W)
        self.winfo_toplevel().title("By-Mr.Shaktiswarup Pahantasingh")
        self.show_frame(LogIn)
        self.state('zoomed')
    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()


class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        tk.Frame.configure(self,bg='lawngreen')

        def time(): 
            string = strftime('%H:%M:%S %p :: %d.%m.%y') 
            lbl.config(text = string) 
            lbl.after(1000, time)  
        lbl = Label(self, font = ('calibri',20, 'bold'), 
                    background = 'lawngreen', 
                    foreground = 'grey2',relief=RIDGE)  
        lbl.place(relx=0.0,rely=0.0) 
        time() 
        b1=tk.Button(self,text="Add Record",command=lambda: controller.show_frame(PageOne) )
        b1.place(relx=0.0,rely=0.2,relwidth=0.2)
        b1.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b2=tk.Button(self,text="View Record",command=lambda: controller.show_frame(PageTwo) )
        b2.place(relx=0.0,rely=0.3,relwidth=0.2)
        b2.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b3=tk.Button(self,text="Delete Record",command=lambda: controller.show_frame(PageThree) )
        b3.place(relx=0.0,rely=0.4,relwidth=0.2)
        b3.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b4=tk.Button(self,text="Update Record",command=lambda: controller.show_frame(PageFour) )
        b4.place(relx=0.0,rely=0.5,relwidth=0.2)
        b4.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b5=tk.Button(self,text="Search Record",command=lambda: controller.show_frame(PageFive) )
        b5.place(relx=0.0,rely=0.6,relwidth=0.2)
        b5.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b6=tk.Button(self, text="Add Fee Details", command=lambda: controller.show_frame(StuFee))
        b6.place(relx=0.0,rely=0.7,relwidth=0.2)
        b6.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b6=tk.Button(self, text="Log Out", command=lambda: controller.show_frame(LogIn))
        b6.place(relx=0.0,rely=0.8,relwidth=0.2)
        b6.config(cursor='mouse',bg='navy', fg='white', bd=8)
        
        
        def imgview(self):
            self.img  = Image.open('home3.png')
            self.img = self.img.resize((1090,707)) 
            photo=ImageTk.PhotoImage(self.img)
            self.lab=Label(self,image=photo,relief=SUNKEN)    
            self.img.image=photo
            self.lab.place(relx=0.2,rely=0.0)
        return imgview(self)
class PageOne(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
        
        label0=tk.Label(self,text="Add Student Records Here",fg='grey25',bg="lawngreen",height=1,width=50,)
        label0.place(relx=0.2,rely=0.0)
        label0.config(font=("Vineta BT",12,"bold","italic","underline"))

        e1 = tk.StringVar(self)
        e2 = tk.StringVar(self)
        e3 = tk.StringVar(self)
        e4 = tk.StringVar(self)
        de1= tk.StringVar(self)
        r1 = tk.StringVar(self)
        d  = tk.StringVar(self)
        e  = tk.StringVar(self)
        
        self.label1=tk.Label(self,text="Student Name*",width=20)
        self.label1.place(relx=0.1,rely=0.08)
        self.nentry=tk.Entry(self,textvariable=e1,relief=SOLID)
        self.nentry.place(relx=0.5,rely=0.08,relwidth=0.3)
        
        self.lbl2=tk.Label(self,text="DOB*",width=20)
        self.lbl2.place(relx=0.1,rely=0.14)
        self.ent=DateEntry(self,backgroundcolor="blue",foreground="red",borderwidth=15,textvariable=de1,relief=SOLID)
        self.ent.place(relx=0.5,rely=0.14,relwidth=0.3)
        
        self.label2=tk.Label(self,text="Father's Name*",width=20)
        self.label2.place(relx=0.1,rely=0.21)
        self.fentry=tk.Entry(self,textvariable=e2,relief=SOLID)
        self.fentry.place(relx=0.5,rely=0.21,relwidth=0.3)
        
        self.label3=tk.Label(self,text="Contact No.*",width=20)
        self.label3.place(relx=0.1,rely=0.3)
        self.aentry=tk.Entry(self,textvariable=e3,relief=SOLID)
        self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)
        
        self.label4=tk.Label(self,text="Student ID*",width=20)
        self.label4.place(relx=0.1,rely=0.4)
        self.identry=tk.Entry(self,textvariable=e4,relief=SOLID)
        self.identry.place(relx=0.5,rely=0.4,relwidth=0.3)
        
        self.label4=tk.Label(self,text="Gender*",width=20)
        self.label4.place(relx=0.1,rely=0.5)
        
        self.radiobutton1=tk.Radiobutton(self,text="male",value='male',var=r1).place(relx=0.5,rely=0.5)
        self.radiobutton2=tk.Radiobutton(self,text="Female",value='female',var=r1).place(relx=0.7,rely=0.5)
        
        self.label4=tk.Label(self,text="Course*",width=20)
        self.label4.place(relx=0.1,rely=0.6)
        
        list1 = ['MBA','MCA','BBA','BCA','BTECH','B-ARCH','BIO-TECH'];
        self.droplist=OptionMenu(self,d, *list1)
        self.droplist.config(width=15)
        d.set('Select Course') 
        self.droplist.place(relx=0.5,rely=0.6,width=200)
        
        self.label5=tk.Label(self,text="Sleect passing year",width=20)
        self.label5.place(relx=0.1,rely=0.7)
        list2 = ['2010','2011','2012','2013','2014','2015','2016','2017','2018','2019','2020'];
        self.droplist=OptionMenu(self,e, *list2)
        self.droplist.config(width=15)
        e.set('Select passing year') 
        self.droplist.place(relx=0.5,rely=0.7,width=200)
        
        def create(self):
            
            deg=e3.get()
            print(deg)
            try:
                x=int(deg) 
            except ValueError:
                tkinter.messagebox.showerror("Invalid Input","This is not a Num")

            cn=int(len(str(e3.get())))
            print(cn)
            con = sq.connect('stddyn.db')
            c = con.cursor()
            if cn!=10:
                tkinter.messagebox.showwarning("Warning", "Phone Num should be 10 Digit")
            elif e1.get() == "":
                tkinter.messagebox.showwarning("Warning", "Please Enter Name")
            elif e2.get() == "":
                tkinter.messagebox.showwarning("Warning", "Please Enter Fathers Name")
            elif e4.get() == "":
                tkinter.messagebox.showwarning("Warning", "Please Enter Regd. Num")
            elif de1.get() =="":
                tkinter.messagebox.showwarning("Warning", "Please Enter DOB")
            elif d.get()=="Select Course":
                tkinter.messagebox.showwarning("Warning", "Please Enter a course")
            elif e.get()=="Select passing year":
                tkinter.messagebox.showwarning("Warning", "Please select a passing year")
            else:
                try:
                    c.execute('CREATE TABLE IF NOT EXISTS stud2(name TEXT,fname TEXT,phno INTEGER,roll INTEGER UNIQUE,gender TEXT,course TEXT,dob DATESTAMP,pyr INTEGER,PRIMARY KEY(roll,name))') 
                    c.execute('INSERT INTO stud2(name,fname,phno,roll,gender,course,dob,pyr) VALUES(?, ?, ?, ?, ?, ?,?,?)',[e1.get(),e2.get(),e3.get(),e4.get(),r1.get(),d.get(),de1.get(),e.get()])
                    result=tkinter.messagebox.askyesno("submit","Do you want to submit ?")
                    if result==True:
                        tkinter.messagebox.showinfo("record  submitted","Your data submitted successfully")
                    else:
                        return print('You press No')
                except :
                    tkinter.messagebox.showwarning("Exception","Already Present")
                     
                con.commit()
        def clearData(self):
            self.nentry.delete(0,END)
            self.fentry.delete(0,END)
            self.aentry.delete(0,END)
            self.identry.delete(0,END)
            self.ent.delete(0,END)
            d.set('Select Course')
        
        def OpenFile(self):
            global file
            file = askopenfilename()
            print(file.name)
        def clr(self):
            controller.show_frame(StartPage)
            self.nentry.delete(0,END)
            self.fentry.delete(0,END)
            self.aentry.delete(0,END)
            self.identry.delete(0,END)
            self.ent.delete(0,END)
            d.set('Select Course')
        btnSubmit=Button(self,text="Submit",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:create(self))
        btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
        btnStartPage=Button(self,text="Back",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clr(self) )
        btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnfee=Button(self,text="Go to Delete record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageThree))
        btnfee.place(relx=0.2,rely=0.85,relwidth=0.3)
        btnfee.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnview=Button(self,text="View All records",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageTwo))
        btnview.place(relx=0.5,rely=0.85,relwidth=0.3)
        btnview.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
        btnclearData.place(relx=0.2,rely=0.9,relwidth=0.3)
        btnquit=Button(self, text="Log Out", command=lambda: controller.show_frame(LogIn))
        btnquit.place(relx=0.5,rely=0.9,relwidth=0.3)
        btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        con = sq.connect('stddyn.db')
        c = con.cursor()
        con.commit()

class StuFee(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
        label0=tk.Label(self,text="Add Student Fee Here",fg='grey25',bg="lawngreen",height=1,width=50,)
        label0.place(relx=0.2,rely=0.0)
        label0.config(font=("Vineta BT",12,"bold","italic","underline"))
        
        f1 = tk.IntVar(self)
        f2 = tk.IntVar(self)
        f3 = tk.IntVar(self)
        f4 = tk.IntVar(self) 
        idd= tk.StringVar(self)
        
        self.label1=tk.Label(self,text="Student Id/Roll*",width=20)
        self.label1.place(relx=0.1,rely=0.08)
        self.iid=tk.Entry(self,textvariable=idd,relief=SOLID)
        self.iid.place(relx=0.5,rely=0.08,relwidth=0.3)
        
        self.lbl2=tk.Label(self,text="1st Year Fee",width=20)
        self.lbl2.place(relx=0.1,rely=0.14)
        self.fy=Entry(self,textvariable=f1,relief=SOLID)
        self.fy.place(relx=0.5,rely=0.14,relwidth=0.3)
        
        self.label2=tk.Label(self,text="2nd year fee*",width=20)
        self.label2.place(relx=0.1,rely=0.21)
        self.sy=tk.Entry(self,textvariable=f2,relief=SOLID)
        self.sy.place(relx=0.5,rely=0.21,relwidth=0.3)
        
        self.label3=tk.Label(self,text="3rd year fee*",width=20)
        self.label3.place(relx=0.1,rely=0.27)
        self.ty=tk.Entry(self,textvariable=f3,relief=SOLID)
        self.ty.place(relx=0.5,rely=0.27,relwidth=0.3)
        
        self.label4=tk.Label(self,text="4th year fee*",width=20)
        self.label4.place(relx=0.1,rely=0.35)
        self.foy=tk.Entry(self,textvariable=f4,relief=SOLID)
        self.foy.place(relx=0.5,rely=0.35,relwidth=0.3)
          
        def fee(self):
            con = sq.connect('stddyn.db')
            c = con.cursor()
            
            totalfee=f1.get()+f2.get()+f3.get()+f4.get()
            print(totalfee)
            de=idd.get()
            
            try:
                x=int(de)    
            except ValueError:
                tkinter.messagebox.showerror("Invalid Input","This is not a Num")
            record_id= int(self.iid.get())
            dataCopy = c.execute("select count(*) from stud2;")
            values = dataCopy.fetchone()
            #print (values[0])
            if record_id >values[0]:
                 tkinter.messagebox.showerror("Error", "No roll Found")
            elif str(self.iid.get()) == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter a Roll num")
#             elif dc == 0:
#                 tkinter.messagebox.showinfo("Warning", "Please Enter firstyear fee")   
            else:
                try:
                    c.execute("""CREATE TABLE IF NOT EXISTS sfee
                                (iid INTEGER UNIQUE,
                                fyear INTEGER NOT NULL,
                                syear INTEGER NOT NULL,
                                tyear INTEGER,
                                foyear INTEGER,
                                total INTEGER,
                                CONSTRAINT fk_stud2 FOREIGN KEY(iid) REFERENCES stud2(roll)
                                ON DELETE CASCADE
                                ON UPDATE CASCADE
                                ON UPDATE SET NULL
                                ON DELETE SET NULL)""") 
                    c.execute('INSERT INTO sfee(iid,fyear,syear,tyear,foyear,total) VALUES(?, ?, ?, ?, ?,?)',[idd.get(),f1.get(),f2.get(),f3.get(),f4.get(),totalfee])
                    tkinter.messagebox.showinfo("total fee",+totalfee)
                    result=tkinter.messagebox.askyesno("submit","Do you want to submit ?")
                    if result==True:
                        tkinter.messagebox.showinfo("record  submitted","Your data submitted successfully")
                    else:
                        return print('You press No')
                except:
                    tkinter.messagebox.showwarning("Wrong Input","Data may be already present,You can update the details in update page section")
                con.commit()
                con.close()
        btnSubmit=Button(self,text="Submit",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:fee(self))
        btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
        btnStartPage=Button(self,text="Back",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(StartPage) )
        btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        


class PageTwo(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
        label0=tk.Label(self,text="Student Records View Point",fg='grey25',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.1,rely=0.0)
        label0.config(font=("Vineta BT",12,"bold","italic","underline"))
        
        def treeview1(self):
            
            con = sq.connect('stddyn.db')
            c = con.cursor()
            c.execute("select * from stud2 left join sfee on sfee.iid=stud2.roll")
            self.tree=ttk.Treeview(self,selectmode='browse')
            vsb1 = ttk.Scrollbar(self, orient="vertical", command=self.tree.yview)
            vsb1.place(relx=0.708,rely=0.1, height=295)
#             self.tree=ttk.Treeview(self,selectmode='browse')
            vsb2 = ttk.Scrollbar(self, orient="horizontal", command=self.tree.xview)
            vsb2.place(relx=0.2,rely=0.502, width=697)
            self.tree.configure(yscrollcommand=vsb1.set)
            self.tree.configure(xscrollcommand=vsb2.set)
            self.tree["columns"]=("e1","e2","e3","e4","r1","d","de1","e","idd","f1","f2","f3","f4","total")
            self.tree.column("#0", width=50, stretch=tk.NO)
            self.tree.column("e1", width=130, stretch=tk.NO)
            self.tree.column("e2", width=155,stretch=tk.NO)
            self.tree.column("e3", width=80, stretch=tk.NO)
            self.tree.column("e4", width=60, stretch=tk.NO)
            self.tree.column("r1", width=60, stretch=tk.NO)
            self.tree.column("d", width=70, stretch=tk.NO)
            self.tree.column("e", width=85, stretch=tk.NO)
            self.tree.column("de1", width=85, stretch=tk.NO)
            self.tree.column("idd", width=50, stretch=tk.NO)
            self.tree.column("f1", width=85, stretch=tk.NO)
            self.tree.column("f2", width=85, stretch=tk.NO)
            self.tree.column("f3", width=85, stretch=tk.NO)
            self.tree.column("f4", width=85, stretch=tk.NO)
            self.tree.column("total", width=85, stretch=tk.NO)
            
            self.tree.heading("#0",text="ID",anchor=tk.W)
            self.tree.heading("e1", text="NAME",anchor=tk.W)
            self.tree.heading("e2", text="FATHER NAME",anchor=tk.W)
            self.tree.heading("e3", text="PH_No",anchor=tk.W)
            self.tree.heading("e4", text="ROLL No.",anchor=tk.W)
            self.tree.heading("r1", text="GENDER",anchor=tk.W)
            self.tree.heading("d", text="COURSE",anchor=tk.W)
            self.tree.heading("de1", text="DOB",anchor=tk.W)
            self.tree.heading("e", text="passing year",anchor=tk.W)
            self.tree.heading("idd", text="ID",anchor=tk.W)
            self.tree.heading("f1", text="1st fee",anchor=tk.W)
            self.tree.heading("f2", text="2nd fee",anchor=tk.W)
            self.tree.heading("f3", text="3rd fee",anchor=tk.W)
            self.tree.heading("f4", text="4th fee",anchor=tk.W)
            self.tree.heading("total", text="total fee",anchor=tk.W)
            
            style = ttk.Style(self)
            style.theme_use("clam")
            style.configure("Treeview", fieldbackground="gray")
            self.tree.place(relx=0.2,rely=0.1,width=695,height=300)
            index = id = 1
            for row in c:
                self.tree.insert("", index, text=id, values=row)
                index = id = index + 1
            con.commit()
            
        def treeview2(self):
            
            con = sq.connect('stddyn.db')
            c = con.cursor()
            print(self.d.get())
            var1=self.d.get()
            c.execute("SELECT * FROM stud2  WHERE course = '"+var1+"'")
            
            self.tree=ttk.Treeview(self,selectmode='browse')
            vsb = ttk.Scrollbar(self, orient="vertical", command=self.tree.yview)
            vsb.place(relx=0.708,rely=0.1, height=295)
            self.tree.configure(yscrollcommand=vsb.set)
            self.tree["columns"]=("e1","e2","e3","e4","r1","d","de1")
            self.tree.column("#0", width=50, stretch=tk.NO)
            self.tree.column("e1", width=130, stretch=tk.NO)
            self.tree.column("e2", width=155,stretch=tk.NO)
            self.tree.column("e3", width=80, stretch=tk.NO)
            self.tree.column("e4", width=60, stretch=tk.NO)
            self.tree.column("r1", width=60, stretch=tk.NO)
            self.tree.column("d", width=70, stretch=tk.NO)
            self.tree.column("de1", width=85, stretch=tk.NO)
            self.tree.heading("#0",text="ID",anchor=tk.W)
            self.tree.heading("e1", text="NAME",anchor=tk.W)
            self.tree.heading("e2", text="FATHER NAME",anchor=tk.W)
            self.tree.heading("e3", text="PH_No",anchor=tk.W)
            self.tree.heading("e4", text="ROLL No.",anchor=tk.W)
            self.tree.heading("r1", text="GENDER",anchor=tk.W)
            self.tree.heading("d", text="COURSE",anchor=tk.W)
            self.tree.heading("de1", text="DOB",anchor=tk.W)
            style = ttk.Style(self)
            style.theme_use("clam")
            style.configure("Treeview", fieldbackground="gray")
            self.tree.place(relx=0.2,rely=0.1,width=695,height=300)
            index = id = 1
            for row in c:
                self.tree.insert("", index, text=id, values=row)
                index = id = index + 1
            con.commit()
        def func(self):
            record_course=self.d.get()
            print(record_course)
        self.d=tk.StringVar(self)
        list1 = ['MBA','MCA','BBA','BCA','BTECH','B-ARCH','BIO-TECH'];
        self.dlist=OptionMenu(self,self.d, *list1,command=func(self))
        self.dlist.config(width=15,bg='yellow') 
        self.d.set('Select Course')   
        self.dlist.place(relx=0.5,rely=0.7,relwidth=0.3)
        
        btnvc=tk.Button(self,text="View Student details course wise",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:treeview2(self))
        btnvc.place(relx=0.18,rely=0.7,relwidth=0.3)
        btnvc.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnViewRec=tk.Button(self,text="View All Records",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:treeview1(self) )
        btnViewRec.place(relx=0.18,rely=0.8,relwidth=0.3)
        btnViewRec.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStart=tk.Button(self,text="Go to Home Page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: controller.show_frame(StartPage) )
        btnStart.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnStart.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btndel=tk.Button(self,text="Go to Delete Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageThree) )
        btndel.place(relx=0.5,rely=0.85,relwidth=0.3)
        btndel.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnupd=tk.Button(self,text="Go to Update Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageFour) )
        btnupd.place(relx=0.18,rely=0.85,relwidth=0.3)
        btnupd.config(cursor='mouse',bg='navy', fg='white', bd=5)
class PageThree(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
        label=tk.Label(self,text=" ",bd=12,width=50,height=35,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        label0=tk.Label(self,text="Student Records Delete Point",fg='grey25',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.1,rely=0.0)
        label0.config(font=("Vineta BT",15,"bold","italic","underline"))
        
        
        labdelete1=Label(self,text='Give a Roll Num* :',font=('none 13 bold'))
        labdelete1.place(relx=0.3,rely=0.5)
        self.rdelete=Entry(self,width=20,font=('none 13 bold'))
        self.rdelete.place(relx=0.3,rely=0.6)
       
        def delete1(self):    
            print("Record Deleted")
            con = sq.connect('stddyn.db')
            c = con.cursor()
            z=int(self.rdelete.get())
            try:
                ch= int(self.rdelete.get())
            except ValueError:
                tkinter.messagebox.showwarning("Warning", "Please enter a roll num")
            dataCopy = c.execute("select count(*) from stud2;")
            values = dataCopy.fetchone()
            print (values[0])
            if z >values[0]:
                tkinter.messagebox.showerror("Error", "No Roll No. Found")
#             elif z == "":
#                 tkinter.messagebox.showinfo("Warning", "Please Enter a Roll num")   
            else:
                
                c.execute("DELETE FROM stud2 WHERE roll = " + self.rdelete.get())
                result1=tkinter.messagebox.askyesno("Delete","Do you want to delete this roll num ?")
                if result1==True:
                    tkinter.messagebox.showinfo("Record Removed","Student record removed successfully")
                else:
                    return print('you press no')
                con.commit()
                
        btndel1=tk.Button(self,text="Dlete Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:delete1(self) )
        btndel1.place(relx=0.3,rely=0.7,relwidth=0.1)
        btndel1.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStart=tk.Button(self,text="Go to Home Page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: controller.show_frame(StartPage) )
        btnStart.place(relx=0.3,rely=0.8,relwidth=0.2)
        btnStart.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnView=tk.Button(self,text="View Records ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: controller.show_frame(PageTwo) )
        btnView.place(relx=0.5,rely=0.8,relwidth=0.2)
        btnView.config(cursor='mouse',bg='navy', fg='white', bd=5)

class PageFour(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
        
        label0=tk.Label(self,text="Update Student Records Here",fg='grey25',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.1,rely=0.0)
        label0.config(font=("Vineta BT",15,"bold","italic","underline"))
        self.label1=tk.Label(self,text="Enter Roll Num* ",width=20)
        self.label1.place(relx=0.3,rely=0.5)
        self.rsentry=tk.Entry(self)
        self.rsentry.place(relx=0.5,rely=0.5,relwidth=0.3)
        btnselect=Button(self,text="Select a record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:SelectRoll1(self))
        btnselect.place(relx=0.5,rely=0.7,relwidth=0.3)
        btnselect.config(cursor='mouse',bg='navy', fg='white', bd=5)
        
        record_rol=self.rsentry.get()
        
        def RecUpdate(self):
            c=len(str(self.aentry.get()))
            k=int(self.pye.get())
            
            print(c)
            if c!=10:
                 tkinter.messagebox.showwarning("Warning", "Phone num should be of 10 Digit!!!")
            elif k<2010 or k>2020:
                tkinter.messagebox.showwarning("Warning", "passing year should be between 2010-2020")
            else:
                con = sq.connect('stddyn.db')
                c = con.cursor()
                record_rol1=int(self.rsentry.get())
#                 record_rol2=int(self.rsentry.get())
                dataCopy = c.execute("select count(*) from stud2;")
                values = dataCopy.fetchone()
                
                
                if record_rol1 >values[0]:
                    tkinter.messagebox.showerror("Error", "No Roll No. Found")
                
                elif self.rsentry.get() == "":
                    tkinter.messagebox.showwarning("Warning", "Please Enter a Roll num")
                else:
                    c.execute("""UPDATE stud2 SET
                             name=:nm,
                             fname=:fnm,
                             phno=:ph,
                             dob=:db,
                             gender=:gd,
                             course=:cr,
                             pyr=:py
                             WHERE roll=:roll""",
                             {'nm':self.nentry.get(),
                              'fnm':self.fentry.get(),
                              'ph':self.aentry.get(),
                              'db':self.ent.get(),
                              'gd':self.gent.get(),
                              'cr':self.cent.get(),
                              'py':self.pye.get(),
                              'roll':str(record_rol1)
                             })
                    c.execute("""UPDATE sfee SET
                             fyear=:fy,
                             syear=:sy,
                             tyear=:ty,
                             foyear=:foy
                             WHERE iid=:iid""",
                             {'fy':self.fye.get(),
                              'sy':self.sye.get(),
                              'ty':self.tye.get(),
                              'foy':self.foye.get(),
                              'iid':str(self.rsentry.get())     
                             }
                              )
                    c.execute("""UPDATE sfee SET
                            total=:tt
                            WHERE iid=:iid""",
                              {'tt':int(self.fye.get())+int(self.sye.get())+int(self.tye.get())+int(self.foye.get()),
                               'iid':str(self.rsentry.get())
                              }
                             )
                    result1=tkinter.messagebox.askyesno("Update","Do you want to update this roll num ?")
                    if result1==True:
                        tkinter.messagebox.showinfo("Record Updated","Student record update successfully")
                    else:
                        return print("you press no")

                    con.commit()
                    con.close()
        def SelectRoll1(self):
            print("Record selected")
            con = sq.connect('stddyn.db')
            c = con.cursor()
            try:
                record_id= int(self.rsentry.get())
            except ValueError:
                tkinter.messagebox.showwarning("Warning", "Please enter a roll num")
            dataCopy = c.execute("select count(*) from stud2")
            values = dataCopy.fetchone()
            if record_id >values[0]:
                tkinter.messagebox.showerror("Error", "No roll Found")
            
            else:
        
        
                global nentry
                global fentry
                global aentry
                global ent
                global gent
                global cent
                global fye
                global sye
                global tye
                global foye
                global pye
                try:
        
                    c.execute("select * from stud2 left join sfee on sfee.iid=stud2.roll WHERE stud2.roll= " + str(record_id))
                    records=c.fetchall()
                except:
                    tkinter.messagebox.showinfo("Warning", "No Table found")
                    
                self.label0=tk.Label(self,text="Student Name*",width=20)
                self.label0.place(relx=0.3,rely=0.2)
                self.nentry=tk.Entry(self)
                self.nentry.place(relx=0.5,rely=0.2,relwidth=0.3)


                self.label1=tk.Label(self,text="Father's Name*",width=20)
                self.label1.place(relx=0.3,rely=0.25)
                self.fentry=tk.Entry(self)
                self.fentry.place(relx=0.5,rely=0.25,relwidth=0.3)

                self.label2=tk.Label(self,text="Phone NO.*",width=20)
                self.label2.place(relx=0.3,rely=0.3)
                self.aentry=tk.Entry(self)
                self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)

                self.label3=tk.Label(self,text="Course*",width=20)
                self.label3.place(relx=0.3,rely=0.35)
                self.cent=tk.Entry(self)
                self.cent.place(relx=0.5,rely=0.35,relwidth=0.3)
                
                self.label4=tk.Label(self,text="DOB*",width=20)
                self.label4.place(relx=0.3,rely=0.4)
                self.ent=tk.Entry(self)
                self.ent.place(relx=0.5,rely=0.4,relwidth=0.3)

                self.label5=tk.Label(self,text="Gender*",width=20)
                self.label5.place(relx=0.3,rely=0.45)
                self.gent=tk.Entry(self)
                self.gent.place(relx=0.5,rely=0.45,relwidth=0.3)
                
                self.lbl3=tk.Label(self,text="passing year*",width=20)
                self.lbl3.place(relx=0.3,rely=0.6)
                self.pye=tk.Entry(self)
                self.pye.place(relx=0.5,rely=0.6,relwidth=0.3)
                
                self.label6=tk.Label(self,text="Fee(1st/2nd/3rd/4th year)*",width=20)
                self.label6.place(relx=0.3,rely=0.55)
                self.fye=tk.Entry(self)
                self.fye.place(relx=0.5,rely=0.55,relwidth=0.05)
                self.sye=tk.Entry(self)
                self.sye.place(relx=0.57,rely=0.55,relwidth=0.05)
                self.tye=tk.Entry(self)
                self.tye.place(relx=0.64,rely=0.55,relwidth=0.05)
                self.foye=tk.Entry(self)
                self.foye.place(relx=0.71,rely=0.55,relwidth=0.05)
                try:
                    for record in records:
                        self.nentry.insert(0,record[0])
                        self.fentry.insert(0,record[1])
                        self.aentry.insert(0,record[2])
                        self.ent.insert(0,record[6])
                        self.gent.insert(0,record[4])
                        self.cent.insert(0,record[5])
                        self.fye.insert(0,record[9])
                        self.sye.insert(0,record[10])
                        self.tye.insert(0,record[11])
                        self.foye.insert(0,record[12])
                        self.pye.insert(0,record[7])
                except:
                    pass

                con.commit()

            def clearData(self):
                self.nentry.delete(0,END)
                self.fentry.delete(0,END)
                self.aentry.delete(0,END)
                self.ent.delete(0,END)
                self.rsentry.delete(0,END)
                self.gent.delete(0,END)
                self.cent.delete(0,END)
                self.fye.delete(0,END)
                self.sye.delete(0,END)
                self.tye.delete(0,END)
                self.foye.delete(0,END)
            btnupdate=Button(self,text="Update Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:RecUpdate(self))
            btnupdate.place(relx=0.0,rely=0.2,relwidth=0.2)
            btnupdate.config(cursor='mouse',bg='navy', fg='white', bd=5)
            btnSubmit=Button(self,text="view all record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageTwo))
            btnSubmit.place(relx=0.0,rely=0.3,relwidth=0.2)
            btnStartPage=Button(self,text="Back ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: controller.show_frame(StartPage) )
            btnStartPage.place(relx=0.0,rely=0.4,relwidth=0.2)
            btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
            btnclearData.place(relx=0.0,rely=0.5,relwidth=0.2)
            btnquit=Button(self, text="Log Out", command=lambda: controller.show_frame(LogIn))
            btnquit.place(relx=0.0,rely=0.6,relwidth=0.2)
            btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
            btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
            btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
            btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)
            con = sq.connect('stddyn.db')
            c = con.cursor()
            
class PageFive(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        tk.Frame.configure(self,bg='lawngreen')
    
        
        label0=tk.Label(self,text="Search Student Records Here",fg='grey25',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.1,rely=0.0)
        label0.config(font=("Vineta BT",15,"bold","italic","underline"))
        self.label1=tk.Label(self,text="Enter Roll Num ",width=20)
        self.label1.place(relx=0.3,rely=0.5)
        self.rsentry=tk.Entry(self)
        self.rsentry.place(relx=0.5,rely=0.5,relwidth=0.3)
        btnshow=Button(self,text="Show record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:SelectRoll1(self))
        btnshow.place(relx=0.2,rely=0.7,relwidth=0.3)
        btnshow.config(cursor='mouse',bg='navy', fg='white', bd=5)
    
        def SelectRoll1(self):
            print("Record selected")
            con = sq.connect('stddyn.db')
            c = con.cursor()
            try:
                xy= int(self.rsentry.get())
            except ValueError:
                tkinter.messagebox.showwarning("Warning", "Please enter a roll num")
            dataCopy = c.execute("select count(*) from stud2")
            values = dataCopy.fetchone()
            if xy >values[0]:
                tkinter.messagebox.showerror("Error", "No roll Found")
            
            else:
        
                global nentry
                global fentry
                global aentry
                global ent
                global gent
                global cent
                global fye
                global sye
                global tye
                global foye
                global pye
                
                try:
        
                    c.execute("select * from stud2 left join sfee on sfee.iid=stud2.roll WHERE stud2.roll= " + str(xy))
                    records=c.fetchall()
                except:
                    tkinter.messagebox.showinfo("Warning", "No Table found")
                    
                self.label0=tk.Label(self,text="Student Name*",width=20)
                self.label0.place(relx=0.3,rely=0.2)
                self.nentry=tk.Entry(self)
                self.nentry.place(relx=0.5,rely=0.2,relwidth=0.3)
                
                
                self.label1=tk.Label(self,text="Father's Name*",width=20)
                self.label1.place(relx=0.3,rely=0.25)
                self.fentry=tk.Entry(self)
                self.fentry.place(relx=0.5,rely=0.25,relwidth=0.3)

                self.label2=tk.Label(self,text="Phone NO.*",width=20)
                self.label2.place(relx=0.3,rely=0.3)
                self.aentry=tk.Entry(self)
                self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)

                self.label3=tk.Label(self,text="Course*",width=20)
                self.label3.place(relx=0.3,rely=0.35)
                self.cent=tk.Entry(self)
                self.cent.place(relx=0.5,rely=0.35,relwidth=0.3)
                
                self.lbl3=tk.Label(self,text="passing year*",width=20)
                self.lbl3.place(relx=0.3,rely=0.55)
                self.pye=tk.Entry(self)
                self.pye.place(relx=0.5,rely=0.55,relwidth=0.3)
                
                self.label4=tk.Label(self,text="DOB*",width=20)
                self.label4.place(relx=0.3,rely=0.4)
                self.ent=tk.Entry(self)
                self.ent.place(relx=0.5,rely=0.4,relwidth=0.3)

                self.label5=tk.Label(self,text="Gender*",width=20)
                self.label5.place(relx=0.3,rely=0.45)
                self.gent=tk.Entry(self)
                self.gent.place(relx=0.5,rely=0.45,relwidth=0.3)
                
                self.label6=tk.Label(self,text="Fee Deposited Annually*",width=20)
                self.label6.place(relx=0.3,rely=0.65)
                self.label7=tk.Label(self,text="1st year",width=10)
                self.label7.place(relx=0.5,rely=0.6,relwidth=0.05)
                self.fye=tk.Entry(self)
                self.fye.place(relx=0.5,rely=0.65,relwidth=0.05)
                self.label8=tk.Label(self,text="2nd year",width=10)
                self.label8.place(relx=0.57,rely=0.6,relwidth=0.05)
                self.sye=tk.Entry(self)
                self.sye.place(relx=0.57,rely=0.65,relwidth=0.05)
                self.label9=tk.Label(self,text="3rd year",width=10)
                self.label9.place(relx=0.64,rely=0.6,relwidth=0.05)
                self.tye=tk.Entry(self)
                self.tye.place(relx=0.64,rely=0.65,relwidth=0.05)
                self.label9=tk.Label(self,text="4th year",width=10)
                self.label9.place(relx=0.71,rely=0.6,relwidth=0.05)
                self.foye=tk.Entry(self)
                self.foye.place(relx=0.71,rely=0.65,relwidth=0.05)
                self.label10=tk.Label(self,text="Total Paid",width=10)
                self.label10.place(relx=0.78,rely=0.6,relwidth=0.05)
                self.total=tk.Entry(self)
                self.total.place(relx=0.78,rely=0.65,relwidth=0.05)
                try:
                    for record in records:
                        self.nentry.insert(0,record[0])
                        self.fentry.insert(0,record[1])
                        self.aentry.insert(0,record[2])
                        self.ent.insert(0,record[6])
                        self.gent.insert(0,record[4])
                        self.cent.insert(0,record[5])
                        self.fye.insert(0,record[9])
                        self.sye.insert(0,record[10])
                        self.tye.insert(0,record[11])
                        self.foye.insert(0,record[12])
                        self.total.insert(0,record[13])
                        self.pye.insert(0,record[7])
                except:
                    pass
                con.commit()                
                btnSubmit=Button(self,text="view all record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(PageTwo))
                btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
                btnStartPage=Button(self,text="Go to Home Page",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: controller.show_frame(StartPage) )
                btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
                btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
                btnclearData.place(relx=0.2,rely=0.9,relwidth=0.3)
                btnquit=Button(self, text="Log Out", command=lambda: controller.show_frame(LogIn))
                btnquit.place(relx=0.5,rely=0.9,relwidth=0.3)
                btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
                btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
                btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
                btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)


class LogIn(tk.Frame):

    def LogInCheck(self):
        global actEntry
        global pinEntry

        act = "j"
        pin = "py"

        actNum = actEntry.get()
        pinNum = pinEntry.get()

        print("FUNCTION RUN")
        
        if actNum=="":
            tkinter.messagebox.showwarning("Blank","Please provide a username")
        elif pinNum=="":
            tkinter.messagebox.showwarning("Blank","Please provide a password")
        elif actNum == act and pinNum == pin:
            print("CORRECT")
            actEntry.delete(0,END)
            pinEntry.delete(0,END)
            self.controller.show_frame(StartPage)
        elif actNum != act or pinNum != pin: 
            print("INCORRECT")
            tkinter.messagebox.showerror("Error","Incorrect Login Input")
            
            self.controller.show_frame(LogIn)

    def __init__(self, parent, controller):

        global actEntry
        global pinEntry
        self.controller = controller

        tk.Frame.__init__(self, parent)

        tk.Frame.configure(self,bg='lawngreen')
        label=tk.Label(self,text=" ",bd=12,width=70,height=35,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        def time(): 
            string = strftime('%I:%M:%S %p') 
            lbl.config(text = string) 
            lbl.after(1000, time)  
        lbl = Label(self, font = ('calibri', 60, 'bold'),background = 'lawngreen',foreground = 'grey8',relief=RIDGE)  
        lbl.place(relx=0.01,rely=0.0) 
        time() 
        label0=tk.Label(self,text="Admin Login Here",fg='grey8',bg="lawngreen",pady=4,width=50)
        label0.place(relx=-0.25,rely=0.2)
        label0.config(font=("Vineta BT",15,"bold","italic","underline"))
        label1=tk.Label(self,text="Student Login Here",fg='grey8',bg="lawngreen",pady=4,width=50)
        label1.place(relx=-0.25,rely=0.62)
        label1.config(font=("Vineta BT",15,"bold","italic","underline"))
        labelinfo=tk.Label(self,text="NOTE:Ask Admin For ID & Password",fg='red',bg="lawngreen",pady=4,width=50,)
        labelinfo.place(relx=0.05,rely=0.27)
        labelinfo.config(font=("Times New Roman",9,"bold","italic"))
        btnStartPage=Button(self,text="Student Login ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(stlogin) )
        btnStartPage.place(relx=0.0,rely=0.7,relwidth=0.3)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        actLabel = Label(self, text = 'Username:',relief=RIDGE)
        actLabel.place(relx=0.05,rely=0.3)
        actEntry = Entry(self,relief=SOLID)
        actEntry.place(relx=0.1,rely=0.3)
        pinLabel = Label(self, text = 'Password:',relief=RIDGE)
        pinLabel.place(relx=0.05,rely=0.35)
        pinEntry = Entry(self, show ="*",relief=SOLID)
        pinEntry.place(relx=0.1,rely=0.35)      
        def imgview1(self):
            self.img  = Image.open('userlogin.png')
            self.img2 =  Image.open('63940.png')
            self.img3=  Image.open('ppt3.png')
            self.img = self.img.resize((50,20)) 
            self.img2= self.img2.resize((50,20))
            self.img3 = self.img3.resize((910,700))
            photo=ImageTk.PhotoImage(self.img)
            photo1=ImageTk.PhotoImage(self.img2)
            photo3=ImageTk.PhotoImage(self.img3)
            self.lab=Button(self,image=photo,command=self.LogInCheck) 
            self.lab1=Button(self,image=photo1,command = controller.destroy) 
            self.lab2=Label(self,image=photo3,relief=SUNKEN)
            self.img.image=photo
            self.img2.image=photo1
            self.img3.image=photo3
            self.lab.place(relx=0.05,rely=0.4)
            self.lab1.place(relx=0.12,rely=0.4)
            self.lab2.place(relx=0.33,rely=0.0)
            self.lab1.config(cursor='mouse',bg='red', fg='white', bd=15)
            self.lab.config(cursor='mouse',bg='black', fg='white', bd=15)
        return imgview1(self)
    
class stlogin(tk.Frame):
    
  

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        tk.Frame.configure(self,bg='lawngreen')
        btnStartPage=Button(self,text="Back",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:controller.show_frame(LogIn))
        btnStartPage.place(relx=0.35,rely=0.55,relwidth=0.3)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        con = sq.connect('stddyn.db')
        c = con.cursor()
        
        c.execute('CREATE TABLE IF NOT EXISTS user(regd INTEGER NOT NULL,username TEXT NOT NULL UNIQUE ,password TEX NOT NULL, CONSTRAINT fk1_stud2 FOREIGN KEY(regd) REFERENCES stud2(roll));')
        con.commit()
        con.close()
        
        global username
        self.username = StringVar()
        self.password = StringVar()
        self.n_username = StringVar()
        self.n_password = StringVar()
        self.n_regd=StringVar()
        #Create Widgets
        self.widgets()
    def login(self):
    
        con = sq.connect('stddyn.db')
        c = con.cursor()
       
        find_user = ('SELECT * FROM user WHERE username = ? and password = ?')
        c.execute(find_user,[(self.username.get()),(self.password.get())])
        result = c.fetchall()
        if self.username.get()=="":
            tkinter.messagebox.showwarning("Invalid Input","Please enter a username")
        elif self.password.get()=="":
            tkinter.messagebox.showwarning("Invalid Input","Please enter a Password")
        elif result:
            
            self.head['text'] = self.username.get() + 'You Logged Out,Please Login Again \n'
            self.head['pady'] = 50
            
            self.controller.show_frame(StuPage)
            self.username.set('')
            self.password.set('')
        else:
            tkinter.messagebox.showerror('Oops!','Username/Password Not Found.')
            
    def new_user(self):
    
        con = sq.connect('stddyn.db')
        c = con.cursor()
        find_user = ('SELECT * FROM user WHERE username = ?')
        c.execute(find_user,[(self.username.get())])        
        if c.fetchall():
            tkinter.messagebox.showerror('Error!','Username Taken Try a Diffrent One.')
        else:
            tkinter.messagebox.showinfo('Success!','Account Created!')
            self.log()
        
        insert = 'INSERT INTO user(regd,username,password) VALUES(?,?,?)'
        c.execute(insert,[(self.n_regd.get()),(self.n_username.get()),(self.n_password.get())])
        con.commit()

    def log(self):
        self.username.set('')
        self.password.set('')
        self.crf.pack_forget()
        self.head['text'] = 'LOGIN'
        self.logf.pack()
    def cr(self):
        self.n_regd.set('')
        self.n_username.set('')
        self.n_password.set('')
        self.logf.pack_forget()
        self.head['text'] = 'Create Account'
        self.crf.pack()
    def widgets(self):

        self.head = Label(self,text = 'LOGIN',bg="lawngreen",font = ('',35),pady = 10)
        self.head.pack()
        self.logf = Frame(self,padx =10,pady = 10)
        un=Label(self.logf,text = 'Username: ',font = ('',20),pady=5,padx=5).grid(sticky = W)
        Entry(self.logf,textvariable = self.username,bd = 5,font = ('',15)).grid(row=0,column=1)
        Label(self.logf,text = 'Password: ',font = ('',20),pady=5,padx=5).grid(sticky = W)
        up=Entry(self.logf,textvariable = self.password,bd = 5,font = ('',15),show = '*').grid(row=1,column=1)
        Button(self.logf,text = ' Login ',bd = 3 ,font = ('',15),padx=5,pady=5,command=self.login).grid()
        Button(self.logf,text = ' Create Account ',bd = 3 ,font = ('',15),padx=5,pady=5,command=self.cr).grid(row=2,column=1)
        self.logf.pack()
        
        self.crf = Frame(self,padx =10,pady = 10)
        Label(self.crf,text = 'Regd no.: ',font = ('',20),pady=5,padx=5).grid(sticky = W)
        Entry(self.crf,textvariable = self.n_regd,bd = 5,font = ('',15)).grid(row=0,column=1)
        Label(self.crf,text = 'Username: ',font = ('',20),pady=5,padx=5).grid(sticky = W)
        Entry(self.crf,textvariable = self.n_username,bd = 5,font = ('',15)).grid(row=1,column=1)
        Label(self.crf,text = 'Password: ',font = ('',20),pady=5,padx=5).grid(sticky = W)
        Entry(self.crf,textvariable = self.n_password,bd = 5,font = ('',15),show = '*').grid(row=2,column=1)
        Button(self.crf,text = 'Create Account',bd = 3 ,font = ('',15),padx=5,pady=5,command=self.new_user).grid()
        Button(self.crf,text = 'Go to Login',bd = 3 ,font = ('',15),padx=5,pady=5,command=self.log).grid(row=3,column=1)
        
class StuPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        tk.Frame.configure(self,bg='lawngreen')

        def time(): 
            string = strftime('%H:%M:%S %p :: %d.%m.%y') 
            lbl.config(text = string) 
            lbl.after(1000, time)  
        lbl = Label(self, font = ('calibri',20, 'bold'),background = 'lawngreen',foreground = 'grey2',relief=RIDGE)  
        lbl.place(relx=0.0,rely=0.0) 
        time() 
    
        b1=tk.Button(self,text="View your Details",command=lambda:viewrecord(self))
        b1.place(relx=0.0,rely=0.3,relwidth=0.2)
        b1.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b2=tk.Button(self,text="Logout",command=lambda:controller.show_frame(stlogin))
        b2.place(relx=0.0,rely=0.4,relwidth=0.2)
        b2.config(cursor='mouse',bg='navy', fg='white', bd=8)
        
        def viewrecord(self):
            
            con = sq.connect('stddyn.db')
            c = con.cursor()
#             z=c.execute("select regd from user where username='"+self.username.get()+"'")
#             print(z)
            title="roll"
            prompt="Enter Your roll here"
            answer = tkinter.simpledialog.askinteger(title,prompt)
            dataCopy = c.execute("select count(*) from stud2;")
            values = dataCopy.fetchone()
            if answer >values[0]:
                 tkinter.messagebox.showerror("Error", "No roll Found")
            elif answer == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter a Roll num")
            else:
            
                try:
        
                    c.execute("select * from stud2 left join sfee on sfee.iid=stud2.roll WHERE stud2.roll= " + str(answer))
                    records=c.fetchall()
                except:
                    tkinter.messagebox.showinfo("Warning", "No Table found")
                self.label=tk.Label(self,text="Your passing year",width=20)
                self.label.place(relx=0.3,rely=0.15)
                self.pye=tk.Entry(self)
                self.pye.place(relx=0.5,rely=0.15,relwidth=0.3)
  
                self.label0=tk.Label(self,text="Name",width=20)
                self.label0.place(relx=0.3,rely=0.2)
                self.nentry=tk.Entry(self)
                self.nentry.place(relx=0.5,rely=0.2,relwidth=0.3)

                self.label1=tk.Label(self,text="Father's Name",width=20)
                self.label1.place(relx=0.3,rely=0.25)
                self.fentry=tk.Entry(self)
                self.fentry.place(relx=0.5,rely=0.25,relwidth=0.3)

                self.label2=tk.Label(self,text="Phone NO.",width=20)
                self.label2.place(relx=0.3,rely=0.3)
                self.aentry=tk.Entry(self)
                self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)

                self.label3=tk.Label(self,text="Course",width=20)
                self.label3.place(relx=0.3,rely=0.35)
                self.cent=tk.Entry(self)
                self.cent.place(relx=0.5,rely=0.35,relwidth=0.3)

                self.label4=tk.Label(self,text="DOB",width=20)
                self.label4.place(relx=0.3,rely=0.4)
                self.ent=tk.Entry(self)
                self.ent.place(relx=0.5,rely=0.4,relwidth=0.3)

                self.label5=tk.Label(self,text="Gender",width=20)
                self.label5.place(relx=0.3,rely=0.45)
                self.gent=tk.Entry(self)
                self.gent.place(relx=0.5,rely=0.45,relwidth=0.3)

                self.label6=tk.Label(self,text="Fee Deposited Annually",width=20)
                self.label6.place(relx=0.3,rely=0.55)
                self.label7=tk.Label(self,text="1st year",width=10)
                self.label7.place(relx=0.5,rely=0.5,relwidth=0.05)
                self.fye=tk.Entry(self)
                self.fye.place(relx=0.5,rely=0.55,relwidth=0.05)
                self.label8=tk.Label(self,text="2nd year",width=10)
                self.label8.place(relx=0.57,rely=0.5,relwidth=0.05)
                self.sye=tk.Entry(self)
                self.sye.place(relx=0.57,rely=0.55,relwidth=0.05)
                self.label9=tk.Label(self,text="3rd year",width=10)
                self.label9.place(relx=0.64,rely=0.5,relwidth=0.05)
                self.tye=tk.Entry(self)
                self.tye.place(relx=0.64,rely=0.55,relwidth=0.05)
                self.label9=tk.Label(self,text="4th year",width=10)
                self.label9.place(relx=0.71,rely=0.5,relwidth=0.05)
                self.foye=tk.Entry(self)
                self.foye.place(relx=0.71,rely=0.55,relwidth=0.05)
                self.label10=tk.Label(self,text="Total Paid",width=10)
                self.label10.place(relx=0.78,rely=0.5,relwidth=0.05)
                self.total=tk.Entry(self)
                self.total.place(relx=0.78,rely=0.55,relwidth=0.05)
                try:
                    for record in records:
                        self.nentry.insert(0,record[0])
                        self.fentry.insert(0,record[1])
                        self.aentry.insert(0,record[2])
                        self.ent.insert(0,record[6])
                        self.gent.insert(0,record[4])
                        self.cent.insert(0,record[5])
                        self.fye.insert(0,record[9])
                        self.sye.insert(0,record[10])
                        self.tye.insert(0,record[11])
                        self.foye.insert(0,record[12])
                        self.total.insert(0,record[13])
                        self.pye.insert(0,record[7])
                except:
                    
                    con.commit()
                
                if self.fye.get()=="":
                        tkinter.messagebox.showinfo("Fee not paid","You have not paid your 1st year fee")
                elif self.fye.get()=="0":
                        tkinter.messagebox.showinfo("Fee not paid","You have not paid your 1st year fee please pay")
                elif self.sye.get()=="":
                         tkinter.messagebox.showinfo("Fee not paid","You have not paid your 2nd year fee")
                elif self.sye.get()=="0":
                         tkinter.messagebox.showinfo("Fee not paid","You have not paid your 2nd year fee please pay")
                elif self.tye.get()=="":
                         tkinter.messagebox.showinfo("Fee not paid","You have not paid your 3rd year fee")
                elif self.tye.get()=="0":
                         tkinter.messagebox.showinfo("Fee not paid","You have not paid your 3rd year fee please pay")  
                
if __name__ == "__main__":
     
    app = Master()
    app.mainloop()
    
#===========Questions==============
#show an error if entries are empty update,search,stupage
#exception in line num 1050
#update total

In [8]:
#Find the frequency of a digit in a number
def frequencyDigits(n, d): 
      
    
    c = 0 
    while (n > 0):  
        if (n % 10 == d): 
            c += 1 
        n = int(n / 10) 
  
    return c 
f = int(input("Enter a number to check"))
e = int(input("Enter a digit to check"))  
print(frequencyDigits(f, e))
  #input 0 is showing problem
Enter a number to check4456657 Enter a digit to check4 2
In [ ]:
import jovian
jovian.commit()
[jovian] Attempting to save notebook..
In [13]:
number=int(input("enter a num"))
if 10000 <= number <= 30000:
    print ("you have to pay 5% taxes")
else:
    print("you dont have to pay")
enter a num84684684848484684654685 you dont have to pay
In [11]:
pip install jovian
Collecting jovian Downloading https://files.pythonhosted.org/packages/6a/7f/830ca8cda042d7313f2bf40d700a41e7b869944668865f6c560db8b2ec26/jovian-0.2.16-py2.py3-none-any.whl (63kB) Requirement already satisfied: click in c:\users\shakt\anaconda3\lib\site-packages (from jovian) (7.0) Requirement already satisfied: requests in c:\users\shakt\anaconda3\lib\site-packages (from jovian) (2.22.0) Collecting uuid (from jovian) Downloading https://files.pythonhosted.org/packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz Requirement already satisfied: pyyaml in c:\users\shakt\anaconda3\lib\site-packages (from jovian) (5.1.1) Requirement already satisfied: idna<2.9,>=2.5 in c:\users\shakt\anaconda3\lib\site-packages (from requests->jovian) (2.8) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\shakt\anaconda3\lib\site-packages (from requests->jovian) (1.24.2) Requirement already satisfied: certifi>=2017.4.17 in c:\users\shakt\anaconda3\lib\site-packages (from requests->jovian) (2019.6.16) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\shakt\anaconda3\lib\site-packages (from requests->jovian) (3.0.4) Building wheels for collected packages: uuid Building wheel for uuid (setup.py): started Building wheel for uuid (setup.py): finished with status 'done' Stored in directory: C:\Users\shakt\AppData\Local\pip\Cache\wheels\2a\80\9b\015026567c29fdffe31d91edbe7ba1b17728db79194fca1f21 Successfully built uuid Installing collected packages: uuid, jovian Successfully installed jovian-0.2.16 uuid-1.30 Note: you may need to restart the kernel to use updated packages.
In [5]:
import cx_Oracle
In [ ]: