College and Home Automation System Project Using IOT (Python & Machine Learning)

PROJECT – REPORT

College and Home Automation System Project Using IOT (Python & Machine Learning)

COLLEGE AUTOMATION SYSTEM

This report introduces the management system which is designed to automate the entire operations of a college and in reducing time in activities using centralized data handling and paperless work with reduced manpower. This Desktop Application has functionality that is basic requirement for college staff. It will help the college staff to access the application and keep record of college data like Student, their marks details and attendance etc. This general application is planned for aiding the students about details on the Courses, Subjects, Marks, Attendance.

INTRODUCTION

1.1 INTRODUCTION TO PROJECT

Presently, each and every day, a novel application or software is being introduced in the economy that serves to enhance and uplift the lifestyle of the people in innumerable ways. College Automation System (CAS) is an application which aims to make the work load of college staff less.
CAS is a Desktop Application. Users have better experience with desktop application as compared to Web applications. CAS provides basic functionality to the users (in this case teachers) to maintain the records of the students. After login the user is redirected to the home page.
The homepage or gateway displays a tree-view of the students according to their session, course. The gateway also consist of a menubar which can be used to navigate to different pages in the application like New Registration, View Students, Add marks, update marks, view marks, Mark attendance etc.
New registrations can be made through the New Registration Form, user have to enter all the required details of the student and the student’s details will be added to the database. The students can be enrolled to different semesters by using the Semester Registration Page. All the details of already saved students can be accessed by the View Students Page.
Teachers can add or update or view the marks of the students using the Add/Update/View Page. The teacher has to enter the session, course and semester and the students who fall into these conditions will be displayed in a tree-view. Teacher can select any student and click on the add marks button to add the marks of the student. If the marks of that particular student has been already added, the teacher will be redirected to the update marks page where they can update the marks of the student. There also a view button which displays the entered marks of the students, total marks obtained and percentage of the student.
CAS also provides the functionality of marking attendance of the students and maintain the record of the same. The teachers can marks the attendance from the mark attendance page which can be accessed through the submenu of the Attendance. Students present in selected session, course and semester will be displayed. If the student is present checkbox will be checked else it will be left unchecked. The record of the attendance can also be viewed through the view attendance page.
CAS also provide a master records which can be used to add a new session or new course or a new subject to the database. Already present sessions, courses and subjects can also be viewed and deleted. Masters records also provides Semester Subject Page which can be used to add different subjects to different semesters.
The project is easy to use and has a friendly user interface so anyone with basic knowledge of computers can use the website and get benefited. Hence, the motto “Education must be accessible to anyone anytime and everywhere” is fulfilled.

1.2 PROJECT CATEGORY

The project presented in this paper belongs to the “Desktop Applications”. The simplest for a desktop application can be:
it runs on a PC operating system (Windows, Mac, Linux, etc.)
it has a graphical user interface
it does not run inside a web browser.
An Internet connection is not required to run to this application.
The application is developed in Python using Tkinter framework. This kind of application contains different forms and widgets. A python desktop application can be deployed as exe file. An EXE file contains an executable program for Windows. EXE is short for “executable,” and it is the standard file extension used by Windows programs.

1.3 PROBLEM FORMULATION

Teachers have to maintain records of every student on paper which leads to huge paper work. Sometimes, it is hard to find record of some student through huge pile of papers. The idea mainly focuses on making the reducing the workload of teachers by using centralized database from where every teacher has access to the records and they can add, update or remove information.

1.4 EXISTING SYSTEMS

Currently, teachers maintain records on papers. Different information is stored in different registers etc. For marks, there is different register or papers, for attendance there is different. This makes the job more time consuming to maintain records at different places. Further, it is difficult to find records of students. Sometimes, if some information of student say contact number is changed, is has to be updated everywhere where contact number of the student is written. Again, this is very tedious task, finding where contact number is stored and updating it.

1.5 PROPOSED SYSTEM

The current scenario presented a few major issues which are resolved in the proposed system. These include:
⦁ This system reduces the paperwork. Records can be maintained in different pages of the application. It is less time consuming. It reduces the after work of maintaining record liking compiling marks of students. In this system, with a click of button it is possible.
⦁ Besides, reducing paperwork it also reduces the efforts to find the records of students. Records of present students or existing student can be found by entering their registration id.
⦁ If some detail of student is to be updated, it can be easily done and we done have to update it manually everywhere, the system will do it itself.
⦁ The proposed system works on centralised database which means every teacher can access the data of students.
⦁ The system interface is very user friendly, anyone can use this who has basic knowledge of English and computer and take the maximum benefit.

SYSTEM DESIGN

DESIGN APPROACH

Object Oriented Approach has been followed throughout the development of the project. Object oriented design works around the entities and their characteristics instead of functions involved in the software system. This design strategies focuses on entities and its characteristics. The whole concept of software solution revolves around the engaged entities.

The important concepts of Object Oriented Design:

 Objects – All entities involved in the solution design are known as objects. For example, person, banks, company and customers are treated as objects. Every entity has some attributes associated to it and has some methods to perform on the attributes.
 Classes – A class is a generalized description of an object. An object is an instance of a class. Class defines all the attributes, which an object can have and methods, which defines the functionality of the object.
In the solution design, attributes are stored as variables and functionalities are defined by means of methods or procedures.
 Encapsulation – In OOD, the attributes (data variables) and methods (operation on the data) are bundled together is called encapsulation. Encapsulation not only bundles important information of an object together, but also restricts access of the data and methods from the outside world. This is called information hiding.
 Inheritance – OOD allows similar classes to stack up in hierarchical manner where the lower or sub-classes can import, implement and re-use allowed variables and methods from their immediate super classes. This property of OOD is known as inheritance. This makes it easier to define specific class and to create generalized classes from specific ones.
 Polymorphism – OOD languages provide a mechanism where methods performing similar tasks but vary in arguments, can be assigned same name. This is called polymorphism, which allows a single interface performing tasks for different types. Depending upon how the function is invoked, respective portion of the code gets executed.

DATABASE DESIGN

Student Table

Course Table

Session Table

Subject Table

Semester Subject Table

Enrollments Table

Marks Table

Attendance Table

Software Requirements:

⦁ Python : Python is an in high-level, interpreted, interactive and object-oriented programming language programming language. Python is designed to be highly readable. Python offers much more structure and support for large programs. Created by Guido van Rossum and first released in 1991. Board standard library .Python has a huge library that contains reusable code. The huge library helps the developer to develop application in less time. Python’s bulk of the library is portable and cross-platform. It is compatible on UNIX, Windows, and Macintosh.
Python language can be used to create different types of applications: Console, Web, Desktop, Enterprise etc.

⦁ Tkinter: Tkinter is Python’s de-facto standard GUI(Graphical User Interface) package. It is a thin object-oriented layer on top of Tcl/Tk. Tkinter is not the only Gui Programming toolkit for Python. It is however the most commonly used one.
⦁ Pyodbc: pyodbc is an open source Python module that makes accessing ODBC databases simple. It implements the ⦁ DB API 2.0 specification but is packed with even more Pythonic convenience.

⦁ IDE
Spyder is a powerful scientific environment written in Python, for Python. It offers a unique combination of the advanced editing, analysis, debugging, and profiling functionality of a comprehensive development tool with the data exploration, interactive execution, deep inspection, and beautiful visualization capabilities of a scientific package.
Beyond its many built-in features, its abilities can be extended even further via its plugin system and API. Furthermore, Spyder can also be used as a PyQt5 extension library, allowing developers to build upon its functionality and embed its components, such as the interactive console, in their own PyQt software.

⦁ Database
Microsoft SQL Server
Snapshots

Login Page

Homepage

New Registration

Semester Registration or Enrollment

View Students

Mark Attendance

Masters – Add Course

Masters – Add Subject

Conclusion

We have proposed a application which can help the teachers to reduce their work load. If teachers are busy in dealing with records, they might not able to give time to the students. This application will automate the things which teachers had to do manually. They do not have to sit all day and deal with lot of papers, there work will be done in just few clicks.
Our long term goal is to add more functionality to the current application and automate more functions, so paper work will be reduced to zero and will help the teachers.

College Automation System Python Code

1.gateway.py

import tkinter as tk
from tkinter.ttk import Treeview
from datalayer import DBSessions
#from RegistrationForm import RegistrationForm
#from ViewStudents import ViewStudents
#from Enrollments import Enrollments
#from DisplayStudentsForm import DisplayStudentForm
#from Attendance import Attendance
from AddSession import AddSession
from ViewSessions import ViewSessions
from AddSubject import AddSubject
from ViewSubjects import ViewSubjects
from AddCourse import AddCourse
from ViewCourses import ViewCourses
#from SemesterSubjects import SemesterSubjectsForm
from datalayer import DBCourse, DBStudents
#from ViewAttendance import ViewAttendance
from datetime import date

class Gateway:
def __init__(self,username):
self.root = tk.Toplevel()

self.root.geometry(“625×450”)
self.root.title(“CAS”)
self.root.resizable(‘false’,’false’)

self.Menu = tk.Menu(self.root)

dt = date.today()
self.welcomeuser = tk.Label(self.root, text = “Welcome, ” + username)
self.welcomeuser.place(x = 10 , y = 425)
self.datetimelabel = tk.Label(self.root, text = dt)
self.datetimelabel.place(x = 550, y = 425)

studentmenu = tk.Menu(self.Menu, tearoff = 0)
studentmenu.add_command(label = “New Registration”, command = self.NewRegistrationClick)
studentmenu.add_command(label = “View Students”, command = self.ViewStudentsClick)
studentmenu.add_separator()
studentmenu.add_command(label= “Semester Registration”, command = self.SemesterRegistrationClick)

self.Menu.add_cascade(label = “Students”, menu = studentmenu)

marksmenu = tk.Menu(self.Menu, tearoff = 0)
marksmenu.add_command(label= “Add/View/Update”, command = self.MarksClick)
self.Menu.add_cascade(label = “Marks”, menu = marksmenu)

attendancemenu = tk.Menu(self.Menu, tearoff = 0)
attendancemenu.add_command(label = “Mark Attendance”, command = self.AttendanceClick)
attendancemenu.add_command(label = “View Attendance”, command = self.ViewAttendanceClick)
self.Menu.add_cascade(label = “Attendance”, menu = attendancemenu)

master = tk.Menu(self.Menu, tearoff = 0)

session = tk.Menu(master, tearoff = 0)
session.add_command(label = “Add Session”, command = self.AddSessionClick)
session.add_command(label = “View Session”, command = self.ViewSessionClick)
master.add_cascade(label = “Session”, menu = session)

course = tk.Menu(master, tearoff = 0)
course.add_command(label = “Add Course”, command = self.AddCourseClick)
course.add_command(label = “View Course”, command = self.ViewCourseClick)
master.add_cascade(label = “Course”, menu = course)

subject = tk.Menu(master, tearoff = 0)
subject.add_command(label = “Add Subject”, command = self.AddSubjectClick)
subject.add_command(label = “View Subject”, command = self.ViewSubjectClick)
master.add_cascade(label = “Subject”, menu = subject)
master.add_separator()
master.add_command(label = “Semester Subject”, command = self.SemesterSubjectClick)
self.Menu.add_cascade(label = “Masters Record”, menu = master)

self.root.config(menu = self.Menu)

self.Tree = Treeview(self.root)
self.Tree[‘columns’] = [‘col1’, ‘col2’]
self.Tree.place(x = 10, y = 20, height=400)

dbsession = DBSessions()
allcourses = DBCourse().GetCourse()
objDALStudent = DBStudents()

sessioncounter = 1
coursecounter=1
studentcounter = 1

for session in dbsession.GetSession():
sessionnode = self.Tree.insert(“”, sessioncounter, text=session.Session, values=(“”,””))

coursecounter=1
for course in allcourses:
coursenode = self.Tree.insert(sessionnode, coursecounter, text=course.CourseName, values=(“”,””))
coursecounter+=1

studentcounter = 1
for student in objDALStudent.ViewStudents(course.CourseId, session.SessionId):
self.Tree.insert(coursenode, studentcounter, text=str(studentcounter), values=(student.RollNo, student.Name))
studentcounter+=1

sessioncounter+=1

def NewRegistrationClick(self):
obj = RegistrationForm()
obj.showDialog()

def ViewStudentsClick(self):
obj = ViewStudents()
obj.showDialog()

def SemesterRegistrationClick(self):
obj = Enrollments()
obj.showDialog()

def MarksClick(self):
obj = DisplayStudentForm()
obj.showDialog()

def AttendanceClick(self):
obj = Attendance()
obj.showDiaog()

def ViewAttendanceClick(self):
obj = ViewAttendance()
obj.showDialog()

def AddSessionClick(self):
obj = AddSession()
obj.showDialog()

def ViewSessionClick(self):
obj = ViewSessions()
obj.showDialog()

def AddSubjectClick(self):
obj = AddSubject()
obj.showDialog()

def ViewSubjectClick(self):
obj = ViewSubjects()
obj.showDialog()

def AddCourseClick(self):
obj = AddCourse()
obj.showDialog()

def ViewCourseClick(self):
obj = ViewCourses()
obj.showDialog()

def SemesterSubjectClick(self):
obj = SemesterSubjectsForm()
obj.showDialog()

def showDialog(self):
self.root.mainloop()

2.login.py

import tkinter as tk
from tkinter import messagebox
from gateway import Gateway

class Login():
def __init__(self):
self.root = tk.Tk()
self.user = tk.StringVar()
self.password = tk.StringVar()
self.count = 0

self.show = tk.PhotoImage(file = r”C:\Users\daljeet\Desktop\Project – CAS\TrainingProject – CAS\Images\show2.png”)
self.hide = tk.PhotoImage(file = r”C:\Users\daljeet\Desktop\Project – CAS\TrainingProject – CAS\Images\hide1.png”)

self.welcome = tk.Label(self.root, text = “CAS”, font=(28))
self.welcome.place(x = 120, y = 10)

self.accLabel = tk.Label(self.root, text = “Enter Usename”)
self.accLabel.place(x = 10, y = 50)
self.accEntry = tk.Entry(self.root, textvariable = self.user)
self.accEntry.place(x = 110 , y = 50)
self.errorLabel1 = tk.Label(self.root, text = “” ,fg = ‘red’)
self.errorLabel1.place(x = 110, y =70)

self.passLabel = tk.Label(self.root, text = “Enter password”)
self.passLabel.place(x = 10, y = 90)
self.passEntry = tk.Entry(self.root, textvariable = self.password , show = “*”)
self.passEntry.place(x = 110 , y = 90)
self.errorLabel2 = tk.Label(self.root, text = “” ,fg = ‘red’)
self.errorLabel2.place(x = 110, y =110)
self.shButton = tk.Button(self.root, image = self.show , command =self.showhidePassword)
self.shButton.place(x = 250 , y = 85)

self.logButton = tk.Button(self.root, text = “LogIn” , command = self.loginClicked, width = 10)
self.logButton.place(x = 40, y = 140)
self.eButton = tk.Button(self.root, text = “Exit” , command = self.exitClicked, width = 10)
self.eButton.place(x = 180, y = 140)

self.root.geometry(“295×180”)
self.root.title(“LogIn”)
self.root.resizable(‘false’,’false’)

def loginClicked(self):
check = self.validate()
if check == True:
if self.user.get() == ‘cas’ and int(self.password.get()) == 1234 :
obj = Gateway(self.user.get())
obj.showDialog()

else:
messagebox.showerror(“LogIn”, “Wrong username or password.Please Try Again”)

def exitClicked(self):
a = messagebox.askyesno(“LogIn”, “Do you want to exit?”)
if a == True:
self.root.destroy()

def validate(self):
val = True

self.errorLabel1.config(text = “”)
self.errorLabel2.config(text = “”)

if self.password.get().isdigit() == False:
val = False
self.errorLabel2.config(text = “*Alphabets not allowed”)

if len(self.user.get()) == 0:
val = False
self.errorLabel1.config(text = “*Field Required”)

if len(self.password.get()) == 0:
val = False
self.errorLabel2.config(text = “*Field Required”)

return val

def showhidePassword(self):
if self.count % 2 ==0:
self.passEntry.config(show = “”)
self.shButton.config(image = self.hide)

else:
self.passEntry.config(show = “*”)
self.shButton.config(image = self.show)
self.count += 1

def showDialog(self):
self.root.mainloop()

obj = Login()
obj.showDialog()

3.login.spec

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis([‘login.py’],
pathex=[‘D:\\Python\\TrainingProject’],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name=’login’,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )

4.Enrollments.py

import tkinter as tk
from tkinter.ttk import Combobox
from tkinter import messagebox
from datalayer import DBEnrollment
from datetime import date

class Enrollments:
def __init__(self):
self.root = tk.Toplevel()
self.root.geometry(“590×340”)
self.root.title(“Enrollment”)

self.rollno = tk.StringVar()
self.registrationid = tk.StringVar()
self.redistrationdate = tk.StringVar()
self.name = tk.StringVar()
self.dob = tk.StringVar()
self.gender = tk.StringVar()
self.contact = tk.StringVar()
self.father = tk.StringVar()
self.mother = tk.StringVar()
self.city = tk.StringVar()
self.email = tk.StringVar()
self.course = tk.StringVar()
self.session = tk.StringVar()

self.lbl1 = tk.Label(self.root, text = “Roll No.”)
self.lbl1.place(x = 140, y =10)
self.ent1 = tk.Entry(self.root, textvariable = self.rollno)
self.ent1.place(x = 200, y = 10)

self.FindButton = tk.Button(self.root, text = “Find”, width = 12, command = self.FindClicked)
self.FindButton.place(x = 360, y = 10)

self.MiddleFrame = tk.Frame(self.root, width = 570, height = 210)
self.MiddleFrame.place(x = 10, y = 60)
self.MiddleFrame.config(highlightbackground = “Black”, highlightcolor = “Black”, highlightthickness = 1, bd= 0)

self.lbl2 = tk.Label(self.root, text = “RegistrationId”)
self.lbl2.place(x = 30 , y = 80)
self.ent2 = tk.Entry(self.root, state = “readonly”, textvariable = self.registrationid)
self.ent2.place(x = 130, y = 80)

self.lbl3 = tk.Label(self.root, text = “Registration Date”)
self.lbl3.place(x = 330, y = 80)
self.ent3 = tk.Entry(self.root, state = “readonly”, textvariable = self.redistrationdate)
self.ent3.place(x = 430, y = 80)

self.lbl4 = tk.Label(self.root, text = “Name”)
self.lbl4.place(x = 30, y = 110)
self.ent4 = tk.Entry(self.root, state = “readonly”, textvariable = self.name)
self.ent4.place(x = 130, y = 110)

self.lbl5 = tk.Label(self.root, text = “D.O.B”)
self.lbl5.place(x = 330, y = 110)
self.ent5 = tk.Entry(self.root, state = “readonly”, textvariable = self.dob)
self.ent5.place(x = 430, y = 110)

self.lbl6 = tk.Label(self.root, text = “Gender”)
self.lbl6.place(x = 30, y = 140)
self.ent6 = tk.Entry(self.root, state = “readonly”, textvariable = self.gender)
self.ent6.place(x = 130, y = 140)

self.lbl7 = tk.Label(self.root, text = “Contact Number”)
self.lbl7.place(x = 330, y = 140)
self.ent7 = tk.Entry(self.root, state = “readonly”, textvariable = self.contact)
self.ent7.place(x = 430, y = 140)

self.lbl8 = tk.Label(self.root, text = “Father Name”)
self.lbl8.place(x = 30, y = 170)
self.ent8 = tk.Entry(self.root, state = “readonly”, textvariable = self.father)
self.ent8.place(x = 130, y = 170)

self.lbl9 = tk.Label(self.root, text = “Mother Name”)
self.lbl9.place(x = 330, y = 170)
self.ent9 = tk.Entry(self.root, state = “readonly”, textvariable = self.mother)
self.ent9.place(x = 430, y = 170)

self.lbl10 = tk.Label(self.root, text = “City”)
self.lbl10.place(x = 30, y = 200)
self.ent10 = tk.Entry(self.root, state = “readonly”, textvariable = self.city)
self.ent10.place(x = 130, y = 200)

self.lbl11 = tk.Label(self.root, text = “E-mail”)
self.lbl11.place(x = 330, y = 200)
self.ent11 = tk.Entry(self.root, state = “readonly”, textvariable = self.email)
self.ent11.place(x = 430, y = 200)

self.lbl12 = tk.Label(self.root, text = “Course”)
self.lbl12.place(x = 30, y = 230)
self.ent12 = tk.Entry(self.root, state = “readonly”, textvariable = self.course)
self.ent12.place(x = 130, y = 230)

self.lbl13 = tk.Label(self.root, text = “Session”)
self.lbl13.place(x = 330, y = 230)
self.ent13 = tk.Entry(self.root, state = “readonly”, textvariable = self.session)
self.ent13.place(x = 430, y = 230)

self.lbl14 = tk.Label(self.root, text = “Semester”)
self.lbl14.place(x = 140, y = 300)
self.cmb1 = Combobox(self.root)
self.cmb1.place(x = 200, y = 300)
self.cmb1[‘values’] = [‘1’, ‘2’, ‘3’,’4′,’5′,’6′,’7′,’8′]

self.RegisterButton = tk.Button(self.root, text = “Register”, width = 12, command = self.RegisterClicked)
self.RegisterButton.place(x = 360, y = 300)

def FindClicked(self):
roll = int(self.rollno.get())
db = DBEnrollment()
AllData = db.FindRoll(roll)

for data in AllData:
self.registrationid.set(data.RegistrationId)
self.redistrationdate.set(data.RegistrationDate)
self.name.set(data.Name)
self.dob.set(data.Dob)
self.gender.set(data.Gender)
self.contact.set(data.ContactNo)
self.father.set(data.FatherName)
self.mother.set(data.MotherName)
self.city.set(data.City)
self.email.set(data.EmailId)
self.course.set(data.CourseId)
self.session.set(data.SessionID)

def RegisterClicked(self):
sem = self.cmb1.get()
rid = int(self.registrationid.get())
today = str(date.today())
db = DBEnrollment()
db.Register(today,sem,rid)

messagebox.showinfo(“Enrollment”, “Student was enrolled successfully.”)

def showDialog(self):
self.root.mainloop()

5.MarksForm.py

import tkinter as tk
from datalayer import DBMarks
from tkinter import messagebox

class MarksForm:
def __init__(self,regid,sessid,cid,sem,name):
self.root = tk.Toplevel()
self.root.geometry(“475×400”)
self.root.title(“Add Marks”)
self.Date = tk.StringVar()

self.regID = regid
self.y = 130
self.reg = tk.StringVar()
self.nam = tk.StringVar()

self.lbl1 = tk.Label(self.root, text = “RegistrationId”)
self.lbl1.place(x = 10 , y = 40)
self.ent1 = tk.Entry(self.root, textvariable = self.reg, state = “readonly”, width = 10)
self.ent1.place(x = 110, y = 40)
self.reg.set(self.regID)

self.lbl3 = tk.Label(self.root, text = “Name”)
self.lbl3.place(x = 240 , y = 40)
self.ent2 = tk.Entry(self.root, textvariable = self.nam, state = “readonly”, width = 20)
self.ent2.place(x = 370, y = 40)
self.nam.set(name)

self.lbl5 = tk.Label(self.root, text = “Subject”)
self.lbl5.place(x = 110 , y =100)
self.lbl6 = tk.Label(self.root, text = “Marks”)
self.lbl6.place(x = 200 , y = 100)

db = DBMarks()
self.AllSubjects = db.GetSubjects(sessid,cid,sem)
self.MarksList = []

for a in self.AllSubjects:
listvar = tk.StringVar()
self.MarksList.append((listvar,a.SemesterSubjectId))
lbl = tk.Label(self.root, text = a.Subject)
lbl.place(x = 110, y = self.y)
ent = tk.Entry(self.root, textvariable = listvar)
ent.place(x = 200, y = self.y)
self.y += 40

self.AddButton = tk.Button(self.root, text = “Add”, command = self.AddMarks, width = 12)
self.AddButton.place(x = 150, y = self.y + 20)

def AddMarks(self):
db = DBMarks()
for marks in self.MarksList:
ssid = marks[1]
rid = self.regID
marks = marks[0].get()
date = self.Date.get()
messagebox.showinfo(“Add Marks”, “Marks was added successfully.”)

db.AddMarks(ssid,rid,marks,date)

def showDialog(self):
self.root.mainloop()

6.RegistrationForm.py

import tkinter as tk
from tkinter import messagebox
from tkinter.ttk import Combobox
from components import Student,Course, Session
from datalayer import DBStudents, DBCourse, DBSessions

class RegistrationForm:
def __init__(self):
self.root = tk.Toplevel()
self.root.geometry(“650×390”)
self.root.title(“Registration”)

self.CourseId = 0
self.SessionID = 0
self.RegistrationDate = tk.StringVar()
self.RollNo = tk.StringVar()
self.Name = tk.StringVar()
self.Dob = tk.StringVar()
self.Gender = tk.StringVar()
self.FatherName = tk.StringVar()
self.MotherName = tk.StringVar()
self.Address = tk.StringVar()
self.City = tk.StringVar()
self.Nationality = tk.StringVar()
self.ContactNo = tk.StringVar()
self.EmailId = tk.StringVar()

self.lbl1 = tk.Label(self.root, text = “Course”)
self.lbl1.place(x = 10 , y = 10)

self.cmb1 = Combobox(self.root, state = “readonly”, width = 20)
self.cmb1.place(x = 110, y = 10)

dbcourse = DBCourse()
self.AllCourses = dbcourse.GetCourse()

courseslist = []
for c in self.AllCourses:
courseslist.append(c.CourseName)

self.cmb1[‘values’] = courseslist

self.lbl2 = tk.Label(self.root, text = “Session”)
self.lbl2.place(x = 350 , y = 10)

self.cmb2 = Combobox(self.root, state = “readonly”, width = 20)
self.cmb2.place(x = 460, y = 10)

dbsession = DBSessions()
self.AllSessions = dbsession.GetSession()

sessionlist = []

for s in self.AllSessions:
sessionlist.append(s.Session)

self.cmb2[‘values’] = sessionlist

self.lbl13 = tk.Label(self.root, text = “Registration Date”)
self.lbl13.place(x = 10 , y = 70)
self.ent13 = tk.Entry(self.root , textvariable = self.RegistrationDate, width = 25)
self.ent13.place(x = 110, y = 70)

self.lbl14 = tk.Label(self.root, text = “Name”)
self.lbl14.place(x = 350 , y = 70)
self.ent14 = tk.Entry(self.root, textvariable = self.Name, width = 25)
self.ent14.place(x = 460, y = 70)

self.lbl3 = tk.Label(self.root, text = “Roll Number”)
self.lbl3.place(x = 10 , y = 110)
self.ent3 = tk.Entry(self.root, textvariable = self.RollNo, width = 25)
self.ent3.place(x = 110, y = 110)

self.lbl4 = tk.Label(self.root, text = “D.O.B”)
self.lbl4.place(x = 350 , y = 110)
self.ent4 = tk.Entry(self.root, textvariable = self.Dob, width = 25)
self.ent4.place(x = 460, y = 110)

self.lbl5 = tk.Label(self.root, text = “Gender”)
self.lbl5.place(x = 10, y = 150)
self.rbn1 = tk.Radiobutton(self.root, text = “Male”, variable = self.Gender, value = “Male”)
self.rbn1.place(x = 110, y = 150)
self.rbn2 = tk.Radiobutton(self.root, text = “Female”, variable = self.Gender, value = “Female”)
self.rbn2.place(x = 210, y = 150)
self.rbn3 = tk.Radiobutton(self.root, text = “Others”, variable = self.Gender, value = “Others”)
self.rbn3.place(x = 310, y = 150)

self.lbl6 = tk.Label(self.root, text = “Father Name”)
self.lbl6.place(x = 10 , y = 190)
self.ent6 = tk.Entry(self.root, textvariable = self.FatherName, width = 25)
self.ent6.place(x = 110, y = 190)

self.lbl7 = tk.Label(self.root, text = “Mother Name”)
self.lbl7.place(x = 350 , y = 190)
self.ent7 = tk.Entry(self.root, textvariable = self.MotherName, width = 25)
self.ent7.place(x = 460, y = 190)

self.lbl8 = tk.Label(self.root, text = “Address”)
self.lbl8.place(x = 10 , y = 230)
self.ent8 = tk.Entry(self.root, textvariable = self.Address, width = 25)
self.ent8.place(x = 110, y = 230)

self.lbl9 = tk.Label(self.root, text = “City”)
self.lbl9.place(x = 350 , y = 230)
self.ent9 = tk.Entry(self.root, textvariable = self.City, width = 25)
self.ent9.place(x = 460, y = 230)

self.lbl10 = tk.Label(self.root, text = “Nationality”)
self.lbl10.place(x = 10 , y = 270)
self.ent10 = tk.Entry(self.root, textvariable = self.Nationality, width = 25)
self.ent10.place(x = 110, y = 270)

self.lbl11 = tk.Label(self.root, text = “Contact Number”)
self.lbl11.place(x = 350 , y = 270)
self.ent11 = tk.Entry(self.root, textvariable = self.ContactNo, width = 25)
self.ent11.place(x = 460, y = 270)

self.lbl12 = tk.Label(self.root, text = “Email Id”)
self.lbl12.place(x = 10 , y = 310)
self.ent12 = tk.Entry(self.root, textvariable = self.EmailId, width = 25)
self.ent12.place(x = 110, y = 310)

self.btn = tk.Button(self.root, text = “Submit”, width = 20, command = self.SubmitClicked)
self.btn.place(x = 250 , y = 350)

def SubmitClicked(self):

comp = Student()
comp.CourseId = self.AllCourses[self.cmb1.current()].CourseId
comp.SessionID = self.AllSessions[self.cmb2.current()].SessionId
comp.RegistrationDate = self.RegistrationDate.get()
comp.RollNo = self.RollNo.get()
comp.Name = self.Name.get()
comp.Dob = self.Dob.get()
comp.Gender = self.Gender.get()
comp.FatherName = self.FatherName.get()
comp.MotherName = self.MotherName.get()
comp.Address = self.Address.get()
comp.City = self.City.get()
comp.Nationality = self.Nationality.get()
comp.ContactNo = self.ContactNo.get()
comp.EmailId = self.EmailId.get()
db = DBStudents()
db.AddStudent(comp)
messagebox.showinfo(“Registration”, “Registration successful.”)

def showDialog(self):
self.root.mainloop()

7.SemesterSubjects.py

import tkinter as tk
from tkinter.ttk import Combobox, Treeview
from datalayer import DBSessions, DBCourse, DBSubjects, DBSemesterSubjects
from components import SemesterSubjects

class SemesterSubjectsForm:
def __init__(self):
self.root = tk.Toplevel()
self.root.geometry(“625×330”)

self.lbl1 = tk.Label(self.root, text = “Session”)
self.lbl1.place(x = 10 , y =10)
self.cmb1 = Combobox(self.root, state = “readonly”)
self.cmb1.place(x = 70, y = 10)
dbsessions = DBSessions()
self.AllSessions = dbsessions.GetSession()
SessionList = []
for sess in self.AllSessions:
SessionList.append(sess.Session)
self.cmb1[‘values’] = SessionList

self.lbl2 = tk.Label(self.root, text = “Semester”)
self.lbl2.place(x = 270 , y =10)
self.cmb2 = Combobox(self.root, state = “readonly”)
self.cmb2.place(x = 330, y = 10)
self.cmb2[‘values’] = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’]

self.lbl3 = tk.Label(self.root, text = “Course”)
self.lbl3.place(x = 10 , y =40)
self.cmb3 = Combobox(self.root, state = “readonly”)
self.cmb3.place(x = 70, y = 40)
dbcourses = DBCourse()
self.AllCourses = dbcourses.GetCourse()
CourseList = []
for cour in self.AllCourses:
CourseList.append(cour.CourseName)
self.cmb3[‘values’] = CourseList

self.lbl4 = tk.Label(self.root, text = “Subject”)
self.lbl4.place(x = 270 , y =40)
self.cmb4 = Combobox(self.root, state = “readonly”)
self.cmb4.place(x = 330, y = 40)
dbsubjects = DBSubjects()
self.AllSubjects = dbsubjects.GetSubjects()
SubjectList = []
for sub in self.AllSubjects:
SubjectList.append(sub.Subject)
self.cmb4[‘values’] = SubjectList

self.AddButton = tk.Button(self.root, text = “Show” , width = 12, command = self.ShowClicked)
self.AddButton.place(x = 520, y = 10)

self.AddButton = tk.Button(self.root, text = “Add” , width = 12, command = self.AddClicked)
self.AddButton.place(x = 520, y = 40)

self.Tree = Treeview(self.root)
self.Tree.place(x = 10, y = 90)
self.Tree[‘columns’] = [‘c1′,’c2’]
self.Tree.heading(“#0”, text = “SemesterSubjectId”)
self.Tree.heading(“c1”,text = “Semester”)
self.Tree.heading(“c2”,text = “Subject”)

def ShowClicked(self):
self.Tree.delete(*self.Tree.get_children())
sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb3.current()].CourseId
subid = self.AllSubjects[self.cmb4.current()].SubjectId
ss = SemesterSubjects()
ss.SessionId = sessid
ss.CourseId = cid
ss.SubjectId = subid
ss.Semester = self.cmb2.get()

db = DBSemesterSubjects()
AllSemesterSubjects = db.Getdata(ss)

i = 0
for allss in AllSemesterSubjects:
self.Tree.insert(“”,i,text = allss.SemesterSubjectId, values = (allss.Semester, allss.SubjectId))
i += 1

def AddClicked(self):
sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb3.current()].CourseId
subid = self.AllSubjects[self.cmb4.current()].SubjectId
ss = SemesterSubjects()
ss.SessionId = sessid
ss.CourseId = cid
ss.SubjectId = subid
ss.Semester = self.cmb2.get()

db = DBSemesterSubjects()
db.StoreValues(ss)

self.Tree.delete(*self.Tree.get_children())
AllSemesterSubjects = db.Getdata(ss)

i = 0
for allss in AllSemesterSubjects:
self.Tree.insert(“”, i, text = allss.SemesterSubjectId, values = (allss.Semester, allss.SubjectId))
i += 1

def showDialog(self):
self.root.mainloop()

8.UpdateMarksForms.py

import tkinter as tk
from datalayer import DBMarks
from tkinter import messagebox

class UpdateMarksForm:
def __init__(self,regid,sessid,cid,sem,name, Marks):
self.root = tk.Toplevel()
self.root.geometry(“455×400”)
self.root.title(“Add Marks”)

self.regID = regid
self.y = 130
self.reg = tk.StringVar()
self.nam = tk.StringVar()

self.lbl1 = tk.Label(self.root, text = “RegistrationId”)
self.lbl1.place(x = 10 , y = 40)
self.ent1 = tk.Entry(self.root, textvariable = self.reg, state = “readonly”, width = 10)
self.ent1.place(x = 110, y = 40)
self.reg.set(self.regID)

self.lbl3 = tk.Label(self.root, text = “Name”)
self.lbl3.place(x = 270 , y = 40)
self.ent2 = tk.Entry(self.root, textvariable = self.nam, state = “readonly”, width = 10)
self.ent2.place(x = 370, y = 40)
self.nam.set(name)

self.lbl5 = tk.Label(self.root, text = “Subject”)
self.lbl5.place(x = 110 , y =100)
self.lbl6 = tk.Label(self.root, text = “Marks”)
self.lbl6.place(x = 200 , y = 100)

dbsubjects = DBMarks()
self.AllSubjects = dbsubjects.GetSubjects(sessid,cid,sem)
self.MarksList = []

for a,m in zip(self.AllSubjects,Marks):
listvar = tk.StringVar()
self.MarksList.append((listvar,a.SemesterSubjectId))
lbl = tk.Label(self.root, text = a.Subject)
lbl.place(x = 110, y = self.y)
ent = tk.Entry(self.root, textvariable = listvar)
ent.place(x = 200, y = self.y)
self.y += 40
listvar.set(m)

self.AddButton = tk.Button(self.root, text = “Update”, command = self.UpdateMarks, width = 12)
self.AddButton.place(x = 150, y = self.y + 20)

def UpdateMarks(self):
db = DBMarks()
for marks in self.MarksList:
marks = marks[0].get()
ssid = marks[1]
regid = self.regID
messagebox.showinfo(” UpdateMarks”, “Marks was Updated successfully.”)

db.UpdateMarks(marks, regid, ssid)

def showDialog(self):
self.root.mainloop()

9.DisplayStudentsForm.py

import tkinter as tk
from tkinter.ttk import Combobox, Treeview
from datalayer import DBSessions, DBCourse, DBStudents, DBMarks
from MarksForm import MarksForm
from UpdateMarksForms import UpdateMarksForm
from ViewMarksForm import ViewMarksForm

class DisplayStudentForm:
def __init__(self):
self.root = tk.Toplevel()
self.root.geometry(“855×350”)
self.root.title(“Marks”)

self.lbl1 = tk.Label(self.root, text = “Session”)
self.lbl1.place(x = 10 , y = 10)
self.cmb1 = Combobox(self.root, state = “readonly”)
self.cmb1.place(x = 70, y = 10)
dbsessions = DBSessions()
self.AllSessions = dbsessions.GetSession()
SessionList = []
for sess in self.AllSessions:
SessionList.append(sess.Session)
self.cmb1[‘values’] = SessionList

self.lbl2 = tk.Label(self.root, text = “Course”)
self.lbl2.place(x = 250 , y =10)
self.cmb2 = Combobox(self.root, state = “readonly”)
self.cmb2.place(x = 310, y = 10)
dbcourses = DBCourse()
self.AllCourses = dbcourses.GetCourse()
CourseList = []
for cour in self.AllCourses:
CourseList.append(cour.CourseName)
self.cmb2[‘values’] = CourseList

self.lbl3 = tk.Label(self.root, text = “Semester”)
self.lbl3.place(x = 490 , y =10)
self.cmb3 = Combobox(self.root, state = “readonly”)
self.cmb3.place(x = 560, y = 10)
self.cmb3[‘values’] = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’]

self.ShowButton = tk.Button(self.root, text = “Show”, command = self.ShowClicked, width = 12)
self.ShowButton.place(x = 750, y = 10)

self.Tree = Treeview(self.root)
self.Tree.place(x = 10, y = 70)
self.Tree[‘columns’] = [‘c1′,’c2′,’c3′,’c4′,’c5’]
self.Tree.heading(“#0”, text = “RegId”)
self.Tree.heading(“c1”,text = “Name”)
self.Tree.heading(“c2”,text = “Roll No.”)
self.Tree.heading(“c3”,text = “DOB”)
self.Tree.heading(“c4”,text = “Gender”)
self.Tree.heading(“c5”,text = “Contact No.”)

self.Tree.column(“#0”, width = 50)
self.Tree.column(“c2”, width = 130)
self.Tree.column(“c3”, width = 130)
self.Tree.column(“c4”, width = 120)

self.MarksButton = tk.Button(self.root, text = “Marks”, command = self.MarksClicked, width = 12)
self.MarksButton.place(x = 300, y = 310)

self.ViewMarksButton = tk.Button(self.root, text = “View Marks”, command = self.ViewMarksClicked, width = 12)
self.ViewMarksButton.place(x = 460, y = 310)

def ShowClicked(self):
sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb2.current()].CourseId
sem = self.cmb3.get()

db = DBStudents()
AllDetails = db.FindStudent(sessid,cid,sem)

i = 0
for ad in AllDetails:
self.Tree.insert(“”,i,text = ad.RegistrationId, values = (ad.Name, ad.RollNo, ad.Dob, ad.Gender, ad.ContactNo))
i += 1

def MarksClicked(self):
key = self.Tree.focus()
regid =self.Tree.item(key,”text”)
name =self.Tree.item(key,”values”)

sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb2.current()].CourseId
sem = self.cmb3.get()

db = DBMarks()
MarksList = db.CheckMarks(regid,sem)

if MarksList != []:
obj = UpdateMarksForm(regid,sessid,cid,sem,name, MarksList)
obj.showDialog()

else:
obj = MarksForm(regid,sessid,cid,sem,name)
obj.showDialog()

def ViewMarksClicked(self):
key = self.Tree.focus()
regid =self.Tree.item(key,”text”)
name = self.Tree.item(key,”values”)

sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb2.current()].CourseId
sem = self.cmb3.get()

db = DBMarks()
MarksList = db.CheckMarks(regid,sem)

obj = ViewMarksForm(sem,regid,name,sessid,cid,MarksList)
obj.showDialog()

def showDialog(self):
self.root.mainloop()

10.datalayer.py

import pyodbc
from abc import ABC
from components import Course, Session, Subject, Student, SemesterSubjects, SubjectNames,AttendanceRecord

class DBOperations(ABC):
def __init__(self):
self.con = pyodbc.connect(“DRIVER={SQL SERVER};SERVER=DESKTOP-4GE4N50\DALJEETSERVER;database=myproject;username=sa;pwd=1@Daljeet”)

class DBCourse(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def AddCourse(self, c):

cur = self.con.cursor()

query = “Insert into Courses values (?,?)”
row = (c.CourseName, c.Description)

cur.execute(query, row)
self.con.commit()

def GetCourse(self):
cur = self.con.cursor()
cur.execute(“Select * from Courses”)

records = cur.fetchall()
AllCourses = []

for record in records:
pro = Course()
pro.CourseId = record[0]
pro.CourseName = record[1]
pro.Description = record[2]

AllCourses.append(pro)

return AllCourses

def DeleteCourse(self, c):
cur = self.con.cursor()

query = “Delete from Courses where CourseId = ?”
row = (c.CourseId)

cur.execute(query,row)
self.con.commit()

class DBSessions(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def AddSession(self, ses):
cur = self.con.cursor()

query = “Insert into Sessions values(?)”
row = (ses.Session)

cur.execute(query,row)
self.con.commit()

def GetSession(self):
cur = self.con.cursor()
cur.execute(“Select * from Sessions”)

records = cur.fetchall()
AllSessions = []

for record in records:
pro = Session()
pro.SessionId = record[0]
pro.Session = record[1]

AllSessions.append(pro)

return AllSessions

def DeleteSessions(self, c):
cur = self.con.cursor()

query = “Delete from Sessions where SessionId = ?”
row = (c.SessionId)

cur.execute(query,row)
self.con.commit()

class DBSubjects(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def AddSubject(self, sub):
cur = self.con.cursor()

query = “Insert into Subjects values(?,?)”
row = (sub.Subject, sub.Description)

cur.execute(query,row)
self.con.commit()

def GetSubjects(self):
cur = self.con.cursor()
cur.execute(“Select * from Subjects”)

records = cur.fetchall()
AllSubjects = []

for record in records:
pro = Subject()
pro.SubjectId = record[0]
pro.Subject = record[1]
pro.Description = record[2]

AllSubjects.append(pro)

return AllSubjects

def DeleteSubjects(self, c):
cur = self.con.cursor()

query = “Delete from Subjects where SubjectId = ?”
row = (c.SubjectId)

cur.execute(query,row)
self.con.commit()

class DBStudents(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def AddStudent(self, stud):
cur = self.con.cursor()

query = “Insert into Students values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)”
#row =(stud.RollNo, stud.RegistrationDate, stud.Name, stud.Dob, stud.Gender, stud.FatherName, stud.MotherName, stud.Address, stud.City, stud.ContactNo, stud.EmailId, stud.Nationality, stud.CourseId, stud.SessionID)
row=(stud.RollNo, stud.RegistrationDate,stud.Name,stud.Dob, stud.Gender,stud.FatherName,stud.MotherName,stud.Address, stud.City, stud.ContactNo,stud.EmailId,stud.Nationality,stud.CourseId,stud.SessionID)
cur.execute(query,row)
self.con.commit()

def ViewStudents(self, cid , sid):
cur = self.con.cursor()

query=”Select RegistrationId,Name,RollNo,RegistrationDate,Dob,ContactNo from Students where CourseId = ? and SessionId = ?”
row = (cid,sid)

cur.execute(query, row)
records = cur.fetchall()
StudentDetailsList = []

for record in records:
comp = Student()
comp.RegistrationId = record[0]
comp.Name = record[1]
comp.RollNo = record[2]
comp.RegistrationDate = record[3]
comp.Dob = record[4]
comp.ContactNo = record[5]

StudentDetailsList.append(comp)

return StudentDetailsList

def FindStudent(self,sessid,cid,sem):
cur = self.con.cursor()

query = “select * from students where CourseId=? and SessionId=? and RegistrationId IN (Select RegistrationId From Enrollments Where Semester=? and IsCurrent=1)”
row = (cid,sessid,sem)

cur.execute(query,row)
records = cur.fetchall()

AllDetails = []

for record in records:
st = Student()
st.RegistrationId = record[0]
st.RollNo = record[1]
st.RegistrationDate = record[2]
st.Name = record[3]
st.Dob = record[4]
st.Gender = record[5]
st.FatherName = record[6]
st.MotherName = record[7]
st.Address = record[8]
st.City = record[9]
st.ContactNo = record[10]
st.EmailId = record[11]
st.Nationality = record[12]
st.CourseId = record[13]
st.SessionID = record[14]

AllDetails.append(st)

return AllDetails

class DBSemesterSubjects(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def StoreValues(self, val):
cur = self.con.cursor()

query = “Insert into SemesterSubjects values (?,?,?,?)”
row = (val.Semester, val.CourseId, val.SubjectId, val.SessionId)

cur.execute(query,row)
self.con.commit()

def Getdata(self, val):
cur = self.con.cursor()

query = “Select ss.SemesterSubjectId, ss.Semester, sub.Subject from SemesterSubjects as ss,Sessions as sess, Courses as c,Subjects as sub where ss.CourseId = c.CourseId and ss.SubjectId = sub.SubjectId and ss.SessionId = sess.SessionId and ss.CourseId = ? and ss.SessionId = ? and ss.Semester = ?”
row = (val.CourseId, val.SessionId , val.Semester)

cur.execute(query, row)

records = cur.fetchall()
SemesterSubjectsList = []

for record in records:
ss = SemesterSubjects()
ss.SemesterSubjectId = record[0]
ss.Semester = record[1]
ss.SubjectId = record[2]

SemesterSubjectsList.append(ss)
return SemesterSubjectsList

class DBEnrollment(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def FindRoll(self, roll):
cur = self.con.cursor()

query = “Select RegistrationId,RollNo,RegistrationDate,Name,Dob,Gender,FatherName,MotherName,Address,City,ContactNo,EmailId,Nationality,c.courseName, s.session from Students as st ,Courses as c ,Sessions as s where st.CourseId = c.CourseId and st.SessionId = s.SessionId and RollNo = ?”
row = roll

cur.execute(query, row)
records = cur.fetchall()
AllData = []

for record in records:
st = Student()
st.RegistrationId = record[0]
st.RollNo = record[1]
st.RegistrationDate = record[2]
st.Name = record[3]
st.Dob = record[4]
st.Gender = record[5]
st.FatherName = record[6]
st.MotherName = record[7]
st.Address = record[8]
st.City = record[9]
st.ContactNo = record[10]
st.EmailId = record[11]
st.Nationality = record[12]
st.CourseId = record[13]
st.SessionID = record[14]

AllData.append(st)
return AllData

def Register(self,date,sem,rid):
cur = self.con.cursor()

cur.execute(“Update Enrollments set IsCurrent=0 where RegistrationId=?”,(rid))

cur.execute(“Insert into Enrollments values(?,?,?,?)”,(date,sem,rid,1))
self.con.commit()

class DBMarks(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def CheckMarks(self,rid,sem):
cur = self.con.cursor()

cur.execute(“select Marks from Marks as [M] , SemesterSubjects[SS] where M.SemesterSubjectId = SS.SemesterSubjectId and RegistrationId = ? and SS.Semester = ?”,(rid,sem))
dbMarks = cur.fetchall()
MarksList = []
for marks in dbMarks:
MarksList.append(marks[0])

return MarksList

def GetSubjects(self, sessid,cid,sem):
cur = self.con.cursor()

query = “Select SS.SemesterSubjectId, S.Subject From SemesterSubjects as [SS], Subjects as [S] Where SS.SubjectId=S.SubjectId and SS.SessionId = ? and SS.CourseId = ? and SS.Semester = ?”
row = (sessid,cid,sem)

cur.execute(query, row)
records = cur.fetchall()

AllSubjects = []

for record in records:
sn = SubjectNames()
sn.SemesterSubjectId = record[0]
sn.Subject = record[1]

AllSubjects.append(sn)

return AllSubjects

def AddMarks(self, ssid, rid, marks,date):
cur = self.con.cursor()

query = “Insert into Marks values (?,?,?,?)”
row = (ssid,rid,marks,date)

cur.execute(query,row)
self.con.commit()

def UpdateMarks(self, regid,ssid, marks):
cur = self.con.cursor()

query = “Update Marks set Marks = ? where RegistrationId = ? and SemesterSubjectId = ?”
row = (marks, regid, ssid)

cur.execute(query,row)
self.con.commit()

class DBAttendance(DBOperations):
def __init__(self):
DBOperations.__init__(self)

def SaveAttendance(self,date,rid,eid,att):
cur = self.con.cursor()

query = “Insert into Attendance values(?,?,?,?)”
row = (date, rid, eid, att)

cur.execute(query,row)
self.con.commit()

def GetEnrollmentId(self, regid):
cur = self.con.cursor()

cur.execute(“Select EnrollmentId from Enrollments where RegistrationId = ? and IsCurrent = 1”, (regid))
records = cur.fetchall()
EnrollmentIdList = []

for record in records:
EnrollmentIdList.append(record[0])

return EnrollmentIdList

def GetAttendance(self, sem, cid, sid):
cur = self.con.cursor()

query = “select S.RegistrationId, S.Name, DatePart(Day, A.Date) as [Day], A.Attendence From Attendance as [A], Students as [S] Where A.RegistrationId=S.RegistrationId and A.RegistrationId IN (Select RegistrationId From Enrollments where Semester=? and IsCurrent=1) and S.CourseId = ? and S.SessionId = ? Order by A.RegistrationId, [Day]”
row = (sem, cid, sid)

cur.execute(query, row)
records = cur.fetchall()
AttendanceList = []

for record in records:
Att = AttendanceRecord()
Att.RegistrationId = int(record[0])
Att.Name = record[1]
Att.Day = record[2]
Att.Attendance = record[3]

AttendanceList.append(Att)

return AttendanceList

11.components.py

class Course:
def __init__(self):
self.CourseId = 0
self.CourseName = “”
self.Description = “”

class Session:
def __init__(self):
self.SessionId = 0
self.Session = 0

class Subject:
def __init__(self):
self.SubjectId = 0
self.Subject = “”
self.Description = “”

class Student:
def __init__(self):
self.RegistrationId = 0
self.RollNo = 0
self.RegistrationDate = “”
self.Name = “”
self.Dob = “”
self.Gender = “”
self.FatherName = “”
self.MotherName = “”
self.Address = “”
self.City = “”
self.ContactNo = 0
self.EmailId = “”
self.Nationality = “”
self.CourseId = 0
self.SessionID = 0

class SemesterSubjects:
def __init__(self):
self.SemesterSubjectId = 0
self.Semester = “”
self.CourseId = 0
self.SubjectId = 0
self.SessionId = 0

class SubjectNames:
def __init__(self):
self.SemesterSubjectId = 0
self.Subject = “”

class AttendanceRecord:
def __init__(self):
self.RegistrationId = 0
self.Name = “”
self.Day = 0
self.Attendance = 0

12.Attendance.py

import tkinter as tk
from tkinter import Canvas, Scrollbar,messagebox
from tkinter.ttk import Combobox
from datalayer import DBSessions, DBCourse, DBStudents, DBAttendance

class Attendance:
def __init__(self):
self.root = tk.Toplevel()
self.root.geometry(“505×480”)
self.root.title(“Marks”)
self.Date = tk.StringVar()

self.topframe = tk.Frame(self.root, width = 505 , height = 120)
self.lbl1 = tk.Label(self.topframe, text = “Session”)
self.lbl1.place(x = 10 , y = 10)
self.cmb1 = Combobox(self.topframe, state = “readonly”)
self.cmb1.place(x = 70, y = 10)
dbsessions = DBSessions()
self.AllSessions = dbsessions.GetSession()
SessionList = []
for sess in self.AllSessions:
SessionList.append(sess.Session)
self.cmb1[‘values’] = SessionList

self.lbl2 = tk.Label(self.topframe, text = “Course”)
self.lbl2.place(x = 290 , y =10)
self.cmb2 = Combobox(self.topframe, state = “readonly”)
self.cmb2.place(x = 350, y = 10)
dbcourses = DBCourse()
self.AllCourses = dbcourses.GetCourse()
CourseList = []
for cour in self.AllCourses:
CourseList.append(cour.CourseName)
self.cmb2[‘values’] = CourseList

self.lbl3 = tk.Label(self.topframe, text = “Semester”)
self.lbl3.place(x = 10 , y = 40)
self.cmb3 = Combobox(self.topframe, state = “readonly”)
self.cmb3.place(x = 70, y = 40)
self.cmb3[‘values’] = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’]

self.lbl4 = tk.Label(self.topframe, text = “Date”)
self.lbl4.place(x = 290, y = 40)
self.ent4 = tk.Entry(self.topframe, textvariable = self.Date, width = 23)
self.ent4.place(x = 350, y = 40)
self.errlbl = tk.Label(self.topframe, text = “”, fg = “Gray”)
self.errlbl.place(x = 350, y = 60)

self.ShowButton = tk.Button(self.topframe, text = “Show”,command = self.ShowClicked, width = 12)
self.ShowButton.place(x = 205, y = 80)

self.topframe.pack(side = “top”)

self.myframe = tk.Frame(self.root, width = 400, height = 100, bd = 1)
self.myframe.place(x = 10 , y = 140)
self.scrollableframe()

self.btn= tk.Button(self.root, text = “Mark Attendence”, command = self.MarkAttendance)
self.btn.place(x = 200, y = 445)

def ShowClicked(self):
self.r = 1
sessid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb2.current()].CourseId
sem = self.cmb3.get()

db = DBStudents()
StudentsList = db.FindStudent(sessid,cid,sem)
self.AttendanceList = []
self.EnrollmentIdList = []

self.frame.destroy()
self.myframe = tk.Frame(self.root, width = 465, height = 100, bd = 1)
self.myframe.place(x = 10 , y = 140)
self.scrollableframe()

for Student in StudentsList:
listvar = tk.StringVar()
listvar.set(0)
lbl5 = tk.Label(self.frame, text = Student.RegistrationId, bg = “White”)
lbl5.grid(row = self.r, column = 0)
lbl6 = tk.Label(self.frame, text = Student.Name, bg = “White”)
lbl6.grid(row = self.r, column = 1)
lbl7 = tk.Label(self.frame, text = Student.RollNo, bg = “White”)
lbl7.grid(row = self.r, column = 2)
chk = tk.Checkbutton(self.frame, variable = listvar, text = “”, bg = “White”)
chk.grid(row = self.r, column = 3)
self.r += 1

self.AttendanceList.append((listvar,Student.RegistrationId))
db = DBAttendance()
EIL = db.GetEnrollmentId(Student.RegistrationId)
self.EnrollmentIdList.append(EIL)

def MarkAttendance(self):
Check = self.CheckEntries()
if Check == True:
db = DBAttendance()
for a,m in zip(self.AttendanceList, self.EnrollmentIdList):
att = a[0].get()
rid = a[1]
eid = m[0]
date = self.Date.get()
db.SaveAttendance(date,rid,eid,att)
messagebox.showinfo(“Attendance”, “Attendance has been Marked”)

def CheckEntries(self):
Err = True
self.errlbl.config(text = “”)

if self.Date.get() == “”:
self.errlbl.config(text = “*Field cannot be empty.”)
messagebox.showerror(“Attendence”, “Fill the required fields!”)
Err = False

return Err

def scrollableframe(self):
self.canvas = Canvas(self.myframe, bg = “White”)
self.frame = tk.Frame(self.canvas, bg = “White”)
self.myscrollbar = Scrollbar(self.myframe, orient = “vertical”, command = self.canvas.yview)
self.canvas.configure(yscrollcommand = self.myscrollbar.set)

self.myscrollbar.pack(side = “right”, fill = “y”)
self.canvas.pack(side = “left”)
self.canvas.create_window((0,0),window = self.frame, anchor = ‘nw’)
self.frame.bind(“<Configure>”, self.myfunction)

self.lbl1 = tk.Label(self.frame, text = “RegistrationId” , bg = “White”)
self.lbl1.grid(row = 0, column = 0)
self.lbl2 = tk.Label(self.frame, text = “Name” , bg = “White”)
self.lbl2.grid(row = 0, column = 1)
self.lbl3 = tk.Label(self.frame, text = “Roll No.” , bg = “White”)
self.lbl3.grid(row = 0, column = 2)
self.lbl4 = tk.Label(self.frame, text = “Attendance” , bg = “White”)
self.lbl4.grid(row = 0, column = 3)
self.frame.grid_columnconfigure(0, minsize =80)
self.frame.grid_columnconfigure(1, minsize =180)
self.frame.grid_columnconfigure(2, minsize =100)
self.frame.grid_columnconfigure(3, minsize =100)

def myfunction(self,event):
self.canvas.configure(scrollregion = self.canvas.bbox(“all”), width = 465, height = 270)

def showDiaog(self):
self.root.mainloop()

13.AddSubject.py

import tkinter as tk
from datalayer import DBSubjects
from components import Subject
from tkinter import messagebox

class AddSubject:
def __init__(self):
self.root = tk.Toplevel()
self.root.grab_set()

self.SubjectName = tk.StringVar()
self.Description = tk.StringVar()

self.root.geometry(“250×100”)
self.root.title(“Add Subject”)

self.lbl1 = tk.Label(self.root, text = “Subject”)
self.lbl1.place(x = 10, y = 10)

self.ent1 = tk.Entry(self.root, textvariable = self.SubjectName)
self.ent1.place(x = 110, y = 10)

self.lbl3 = tk.Label(self.root, text=”Description”)
self.lbl3.place(x = 10, y = 40)

self.ent3 = tk.Entry(self.root, textvariable = self.Description)
self.ent3.place(x = 110, y =40)

self.btn1 = tk.Button(self.root, text = “Save”, command = self.SaveClicked, width = 12)
self.btn1.place(x = 90, y =70)

def SaveClicked(self):
p = Subject()

p.Subject = self.SubjectName.get()
p.Description = self.Description.get()
obj=DBSubjects()
obj.AddSubject(p)
messagebox.showinfo(“AddSubject”,”Subject has been Added successfully.”)

def showDialog(self):
self.root.mainloop()

14.AddSession.py

import tkinter as tk
from components import Session
from datalayer import DBSessions
from tkinter import messagebox

class AddSession:
def __init__(self):
self.root = tk.Toplevel()
self.root.grab_set()
self.root.geometry(“240×80”)
self.root.title(“Session”)
self.session = tk.StringVar()

self.lbl = tk.Label(self.root, text= “Enter Session”)
self.lbl.place(x = 10, y = 10)
self.ent = tk.Entry(self.root, textvariable = self.session)
self.ent.place(x = 100, y = 10)

self.btn = tk.Button(self.root, text = “Add”, command = self.addButton, width = 12)
self.btn.place(x = 70, y = 40)

def addButton(self):
s = Session()
s.Session = self.session.get()
db = DBSessions()
db.AddSession(s)
messagebox.showinfo(“Add Session”, “Session was added successfully.”)

def showDialog(self):
self.root.mainloop()

15.AddCourse.py

import tkinter as tk
from datalayer import DBCourse
from components import Course
from tkinter import messagebox

class AddCourse:
def __init__(self):
self.root = tk.Toplevel()
self.root.grab_set()
self.root.title(“Add Course”)

self.CourseName = tk.StringVar()
self.Description = tk.StringVar()

self.root.geometry(“245×115”)

self.lbl1 = tk.Label(self.root, text = “Course Name”)
self.lbl1.place(x = 10, y = 10)

self.ent1 = tk.Entry(self.root, textvariable = self.CourseName)
self.ent1.place(x = 110, y = 10)

self.lbl3 = tk.Label(self.root, text=”Description”)
self.lbl3.place(x = 10, y = 40)

self.ent3 = tk.Entry(self.root, textvariable = self.Description)
self.ent3.place(x = 110, y =40)

self.btn1 = tk.Button(self.root, text = “Save”, command = self.SaveClicked, width = 12)
self.btn1.place(x = 70, y =80)

def SaveClicked(self):
p = Course()

p.CourseName = self.CourseName.get()
p.Description = self.Description.get()
obj=DBCourse()
obj.AddCourse(p)
messagebox.showinfo(“Add Course”, “Course was added successfully.”)

def showDialog(self):
self.root.mainloop()

16.ViewAttendance.py

import tkinter as tk
from tkinter.ttk import Combobox, Treeview
from datalayer import DBSessions, DBCourse, DBStudents, DBAttendance

class ViewAttendance:
def __init__ (self):
self.root=tk.Toplevel()
self.root.geometry(“1055×340”)
self.root.title(“ViewAttendance”)
self.root.resizable(“false”,”false”)

self.lbl1 = tk.Label(self.root, text = “Session”)
self.lbl1.place(x = 10 , y = 10)
self.cmb1 = Combobox(self.root, state = “readonly”)
self.cmb1.place(x = 70, y = 10)
dbsessions = DBSessions()
self.AllSessions = dbsessions.GetSession()
SessionList = []
for sess in self.AllSessions:
SessionList.append(sess.Session)
self.cmb1[‘values’] = SessionList

self.lbl2 = tk.Label(self.root, text = “Course”)
self.lbl2.place(x = 260 , y =10)
self.cmb2 = Combobox(self.root, state = “readonly”)
self.cmb2.place(x = 330, y = 10)
dbcourses = DBCourse()
self.AllCourses = dbcourses.GetCourse()
CourseList = []
for cour in self.AllCourses:
CourseList.append(cour.CourseName)
self.cmb2[‘values’] = CourseList

self.lbl3 = tk.Label(self.root, text = “Semester”)
self.lbl3.place(x = 540 , y = 10)
self.cmb3 = Combobox(self.root, state = “readonly”)
self.cmb3.place(x = 620, y = 10)
self.cmb3[‘values’] = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’]
self.cmb3.bind(“<<ComboboxSelected>>”, self.SemesterChanged)

self.lbl4 = tk.Label(self.root, text = “Month”)
self.lbl4.place(x = 820 , y = 10)
self.cmb4 = Combobox(self.root, state = “readonly”)
self.cmb4.place(x = 900, y = 10)

self.btn = tk.Button(self.root, text = “Show”, command = self.ShowClicked, width = 12)
self.btn.place(x = 350, y = 50)

self.btn1 = tk.Button(self.root, text = “Exit”, command = self.root.destroy, width = 12)
self.btn1.place(x = 650, y = 50)

self.Tree = Treeview(self.root)
self.Tree.place(x = 10, y = 100, width = 1035)

def SemesterChanged(self, event):
semesterindex = self.cmb3.current()+1

if semesterindex%2==0:
self.cmb4[‘values’]=[“Aug”,”Sept”,”Oct”,”Nov”,”Dec”]
else:
self.cmb4[‘values’]=[“Jan”,”Feb”,”Mar”,”Apr”,”May”]

def ShowClicked(self):
self.Tree.column(“#0”,width=100)
semesterindex = self.cmb3.current()+1

month = 0

if semesterindex%2==0:
month = self.cmb4.current()+7
else:
month = self.cmb4.current()+1

headings = []

if month==2:
for i in range(1,29):
headings.append(str(i))

elif month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12:
for i in range(1,32):
headings.append(str(i))

else:
for i in range(1,31):
headings.append(str(i))

self.Tree[“columns”] = headings

for heading in headings:
self.Tree.heading(heading, text=heading)

if len(headings) == 28:
print(“28”)
self.Set28Widths()
elif len(headings) == 30:
self.Set30Widths()
else:
self.Set31Widths()

sid = self.AllSessions[self.cmb1.current()].SessionId
cid = self.AllCourses[self.cmb2.current()].CourseId
sem = self.cmb3.get()

db = DBAttendance()
records = db.GetAttendance(sem, cid ,sid)

i = 0
att = [”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”]

regid = records[0].RegistrationId
Name = “”

for record in records:

if record.RegistrationId==regid:
att[record.Day-1] = record.Attendance
else:
self.Tree.insert(“”, i, text = Name , values= (att))
att = [”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”]
att[record.Day-1] = record.Attendance

regid=record.RegistrationId

Name=record.Name

i += 1

if i==len(records):
self.Tree.insert(“”, i, text = Name , values= (att))

def Set31Widths(self):

self.Tree.column(“1”,width=30)
self.Tree.column(“2”,width=30)
self.Tree.column(“3”,width=30)
self.Tree.column(“4”,width=30)
self.Tree.column(“5”,width=30)
self.Tree.column(“6”,width=30)
self.Tree.column(“7”,width=30)
self.Tree.column(“8”,width=30)
self.Tree.column(“9”,width=30)
self.Tree.column(“10”,width=30)
self.Tree.column(“11”,width=30)
self.Tree.column(“12”,width=30)
self.Tree.column(“13”,width=30)
self.Tree.column(“14”,width=30)
self.Tree.column(“15”,width=30)
self.Tree.column(“16”,width=30)
self.Tree.column(“17”,width=30)
self.Tree.column(“18”,width=30)
self.Tree.column(“19”,width=30)
self.Tree.column(“20”,width=30)
self.Tree.column(“21”,width=30)
self.Tree.column(“22”,width=30)
self.Tree.column(“23”,width=30)
self.Tree.column(“24”,width=30)
self.Tree.column(“25”,width=30)
self.Tree.column(“26”,width=30)
self.Tree.column(“27”,width=30)
self.Tree.column(“28”,width=30)
self.Tree.column(“29”,width=30)
self.Tree.column(“30”,width=30)
self.Tree.column(“31”,width=30)

def Set30Widths(self):
self.Tree.column(“1”,width=30)
self.Tree.column(“2”,width=30)
self.Tree.column(“3”,width=30)
self.Tree.column(“4”,width=30)
self.Tree.column(“5”,width=30)
self.Tree.column(“6”,width=30)
self.Tree.column(“7”,width=30)
self.Tree.column(“8”,width=30)
self.Tree.column(“9”,width=30)
self.Tree.column(“10”,width=30)
self.Tree.column(“11”,width=30)
self.Tree.column(“12”,width=30)
self.Tree.column(“13”,width=30)
self.Tree.column(“14”,width=30)
self.Tree.column(“15”,width=30)
self.Tree.column(“16”,width=30)
self.Tree.column(“17”,width=30)
self.Tree.column(“18”,width=30)
self.Tree.column(“19”,width=30)
self.Tree.column(“20”,width=30)
self.Tree.column(“21”,width=30)
self.Tree.column(“22”,width=30)
self.Tree.column(“23”,width=30)
self.Tree.column(“24”,width=30)
self.Tree.column(“25”,width=30)
self.Tree.column(“26”,width=30)
self.Tree.column(“27”,width=30)
self.Tree.column(“28”,width=30)
self.Tree.column(“29”,width=30)
self.Tree.column(“30”,width=30)

def Set28Widths(self):
self.Tree.column(“1”,width=30)
self.Tree.column(“2”,width=30)
self.Tree.column(“3”,width=30)
self.Tree.column(“4”,width=30)
self.Tree.column(“5”,width=30)
self.Tree.column(“6”,width=30)
self.Tree.column(“7”,width=30)
self.Tree.column(“8”,width=30)
self.Tree.column(“9”,width=30)
self.Tree.column(“10”,width=30)
self.Tree.column(“11”,width=30)
self.Tree.column(“12”,width=30)
self.Tree.column(“13”,width=30)
self.Tree.column(“14”,width=30)
self.Tree.column(“15”,width=30)
self.Tree.column(“16”,width=30)
self.Tree.column(“17”,width=30)
self.Tree.column(“18”,width=30)
self.Tree.column(“19”,width=30)
self.Tree.column(“20”,width=30)
self.Tree.column(“21”,width=30)
self.Tree.column(“22”,width=30)
self.Tree.column(“23”,width=30)
self.Tree.column(“24”,width=30)
self.Tree.column(“25”,width=30)
self.Tree.column(“26”,width=30)
self.Tree.column(“27”,width=30)
self.Tree.column(“28”,width=30)

def showDialog(self):
self.root.mainloop()

17.ViewCourses.py

import tkinter as tk
from tkinter.ttk import Treeview
from tkinter import messagebox
from datalayer import DBCourse
from components import Course

class ViewCourses:
def __init__(self):
self.root = tk.Toplevel()
self.root.grab_set()

self.tree = Treeview(self.root)
self.tree.pack()

self.tree[‘columns’] = (“c1″,”c2”)
self.tree.heading(“c1”, text = “Course”)
self.tree.heading(“c2”, text = “Description”)

db = DBCourse()
AllCourses = db.GetCourse()

i = 1

for c in AllCourses:
self.tree.insert(“”,i,text = c.CourseId, values= (c.CourseName, c.Description))
i = i+1

self.DeleteButton = tk.Button(self.root,text=”Delete”, command = self.DeleteClicked)
self.DeleteButton.pack()

def DeleteClicked(self):
ret = messagebox.askyesno(“Courses”,”Do you want to delete the course?”)
if ret == True:
key = self.tree.focus()
cid = int(self.tree.item(key,”text”))
c = Course()
db = DBCourse()
c.CourseId = cid
db.DeleteCourse(c)
self.tree.delete(key)

def showDialog(self):
self.root.mainloop()

18.ViewMarksForm.py

import tkinter as tk
from tkinter.ttk import Combobox
from datalayer import DBMarks
from functools import partial

class ViewMarksForm:
def __init__(self,sem,regid,name,sessid,cid,Marks):
self.root = tk.Toplevel()
self.root.geometry(“530×385”)
self.root.title(“View Marks”)
self.y = 5
self.rid = tk.StringVar()
self.Name = tk.StringVar()

self.lbl2 = tk.Label(self.root, text = “RegistrationId”)
self.lbl2.place(x = 10, y = 10)
self.ent2 = tk.Entry(self.root, textvariable = self.rid, state = “readonly”)
self.ent2.place(x = 110, y = 10)
self.rid.set(regid)

self.lbl3 = tk.Label(self.root, text = “Name”)
self.lbl3.place(x = 250, y = 10)
self.ent3 = tk.Entry(self.root, textvariable = self.Name, state = “readonly”)
self.ent3.place(x = 350, y = 10)
self.Name.set(name)

self.lbl1 = tk.Label(self.root, text = “Semester”)
self.lbl1.place(x = 10, y = 50)
self.cmb = Combobox(self.root)
self.cmb.place(x = 110, y = 50)
self.cmb[‘values’] = [‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8’]

self.ShowButton = tk.Button(self.root, text = “Show”, command = partial(self.ShowClicked,sessid,cid,regid))
self.ShowButton.place(x = 350, y = 50)

self.frame = tk.Frame(self.root, width = 400, height = 400)
self.frame.place(x = 105, y = 100)

self.GetMarks(sessid,cid,sem,Marks)
omarks = 0
for mark in Marks:
omarks += mark

if Marks != []:
obt = tk.Label(self.frame, text = “Obtained Marks”)
obt.place(x = 25, y = self.y + 20)
obtlbl = tk.Label(self.frame, text = omarks).place(x = 125, y = self.y + 20)

total = tk.Label(self.frame, text = “Total Marks”)
total.place(x = 25, y = self.y + 50)
totallbl = tk.Label(self.frame, text = len(Marks)*100).place(x = 125, y = self.y + 50)

per = tk.Label(self.frame, text = “Percentage”)
per.place(x = 25, y = self.y + 80)
perlbl = tk.Label(self.frame, text = (omarks/len(Marks))).place(x = 125, y = self.y + 80)

def ShowClicked(self,sessid,cid,regid):
self.y = 5
self.frame.destroy()
self.frame = tk.Frame(self.root, width = 400, height = 400)
self.frame.place(x = 105, y = 100)
sem = self.cmb.get()
db = DBMarks()
Marks = db.CheckMarks(regid,sem)
self.GetMarks(sessid,cid,sem,Marks)

if Marks != []:
omarks = 0
for mark in Marks:
omarks += mark
obt = tk.Label(self.frame, text = “Obtained Marks”)
obt.place(x = 25, y = self.y + 20)
obtlbl = tk.Label(self.frame, text = omarks).place(x = 125, y = self.y + 20)

total = tk.Label(self.frame, text = “Total Marks”)
total.place(x = 25, y = self.y + 50)
totallbl = tk.Label(self.frame, text = len(Marks)*100).place(x = 125, y = self.y + 50)

per = tk.Label(self.frame, text = “Percentage”)
per.place(x = 25, y = self.y + 80)
perlbl = tk.Label(self.frame, text = (omarks/len(Marks))).place(x = 125, y = self.y + 80)

def GetMarks(self,sessid,cid,sem,Marks):
db = DBMarks()
self.AllSubjects = db.GetSubjects(sessid,cid,sem)
self.MarksList = []

if Marks == []:
Marks = [“NULL”] * len(self.AllSubjects)

for a,m in zip(self.AllSubjects,Marks):
listvar = tk.StringVar()
self.MarksList.append((listvar,a.SemesterSubjectId))
lbl = tk.Label(self.frame, text = a.Subject)
lbl.place(x = 5, y = self.y)
ent = tk.Entry(self.frame, textvariable = listvar, state = “readonly”)
ent.place(x = 95, y = self.y)
self.y += 40
listvar.set(m)

def showDialog(self):

self.root.mainloop()

19.ViewSessions.py

import tkinter as tk
from tkinter.ttk import Treeview
from tkinter import messagebox
from datalayer import DBSessions
from components import Session

class ViewSessions:
def __init__(self):
self.root=tk.Toplevel()
self.root.grab_set()

self.tree=Treeview(self.root)
self.tree.pack()

self.tree[‘columns’]=(“c1”)
self.tree.heading(“c1″,text=”Session”)

db=DBSessions()
AllSessions=db.GetSession()

i=1

for c in AllSessions:
self.tree.insert(“”,i,text=c.SessionId,values=(c.Session))
i=i+1

self.btn=tk.Button(self.root,text=”Delete”,command=self.delete)
self.btn.pack()

def delete(self):
ret=messagebox.askyesno(“Session”,”do you want to delete Session?”)
if ret==True:
key=self.tree.focus()
cid=int(self.tree.item(key,”text”))
c=Session()
c.SessionId=cid
db=DBSessions()
db.DeleteSessions(c)
self.tree.delete(key)

def showDialog(self):
self.root.mainloop()

20.ViewSubjects.py

import tkinter as tk
from tkinter.ttk import Treeview
from tkinter import messagebox
from datalayer import DBSubjects
from components import Subject

class ViewSubjects:
def __init__(self):
self.root = tk.Toplevel()
self.root.grab_set()
self.root.title(“View Subject”)

self.tree = Treeview(self.root)
self.tree.pack()

self.tree[‘columns’] = (“c1″,”c2”)
self.tree.heading(“c1”, text = “Course”)
self.tree.heading(“c2”, text = “Description”)

db = DBSubjects()
AllSubjects = db.GetSubjects()

i = 1

for c in AllSubjects:
self.tree.insert(“”,i,text = c.SubjectId, values= (c.Subject, c.Description))
i = i+1

self.DeleteButton = tk.Button(self.root,text=”Delete”, command = self.DeleteClicked)
self.DeleteButton.pack()

def DeleteClicked(self):
ret = messagebox.askyesno(“Courses”,”Do you want to delete the subject?”)
if ret == True:
key = self.tree.focus()
sid = int(self.tree.item(key,”text”))
c = Subject()
db = DBSubjects()
c.SubjectId = sid
db.DeleteSubjects(c)
self.tree.delete(key)

def showDialog(self):
self.root.mainloop()

College Automation Syetem Data Base Code

USE [master]
GO
/****** Object: Database [ProjectDB] Script Date: 7/18/2019 2:52:01 PM ******/
CREATE DATABASE [ProjectDB]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N’ProjectDB’, FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\ProjectDB.mdf’ , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N’ProjectDB_log’, FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\ProjectDB_log.ldf’ , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
ALTER DATABASE [ProjectDB] SET COMPATIBILITY_LEVEL = 140
GO
IF (1 = FULLTEXTSERVICEPROPERTY(‘IsFullTextInstalled’))
begin
EXEC [ProjectDB].[dbo].[sp_fulltext_database] @action = ‘enable’
end
GO
ALTER DATABASE [ProjectDB] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [ProjectDB] SET ANSI_NULLS OFF
GO
ALTER DATABASE [ProjectDB] SET ANSI_PADDING OFF
GO
ALTER DATABASE [ProjectDB] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [ProjectDB] SET ARITHABORT OFF
GO
ALTER DATABASE [ProjectDB] SET AUTO_CLOSE ON
GO
ALTER DATABASE [ProjectDB] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [ProjectDB] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [ProjectDB] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [ProjectDB] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [ProjectDB] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [ProjectDB] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [ProjectDB] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [ProjectDB] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [ProjectDB] SET DISABLE_BROKER
GO
ALTER DATABASE [ProjectDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [ProjectDB] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [ProjectDB] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [ProjectDB] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [ProjectDB] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [ProjectDB] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [ProjectDB] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [ProjectDB] SET RECOVERY SIMPLE
GO
ALTER DATABASE [ProjectDB] SET MULTI_USER
GO
ALTER DATABASE [ProjectDB] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [ProjectDB] SET DB_CHAINING OFF
GO
ALTER DATABASE [ProjectDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [ProjectDB] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [ProjectDB] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [ProjectDB] SET QUERY_STORE = OFF
GO
USE [ProjectDB]
GO
/****** Object: Table [dbo].[Attendance] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Attendance](
[uid] [int] IDENTITY(1,1) NOT NULL,
[Date] [date] NULL,
[RegistrationId] [int] NULL,
[EnrollmentId] [int] NULL,
[Attendance] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[uid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Courses] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Courses](
[CourseId] [int] IDENTITY(1,1) NOT NULL,
[courseName] [varchar](50) NULL,
[Description] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[CourseId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Enrollments] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Enrollments](
[EnrollmentId] [int] IDENTITY(1,1) NOT NULL,
[EDate] [date] NULL,
[Semester] [varchar](3) NULL,
[RegistrationId] [int] NULL,
[IsCurrent] [int] NULL,
PRIMARY KEY CLUSTERED
(
[EnrollmentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Marks] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Marks](
[SerialNo] [int] IDENTITY(1,1) NOT NULL,
[SemesterSubjectId] [int] NULL,
[RegistrationId] [int] NULL,
[Marks] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[SerialNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[SemesterSubjects] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SemesterSubjects](
[SemesterSubjectId] [int] IDENTITY(1,1) NOT NULL,
[Semester] [varchar](3) NULL,
[CourseId] [int] NULL,
[SubjectId] [int] NULL,
[SessionId] [int] NULL,
PRIMARY KEY CLUSTERED
(
[SemesterSubjectId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Sessions] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sessions](
[SessionId] [int] IDENTITY(1,1) NOT NULL,
[Session] [varchar](9) NULL,
PRIMARY KEY CLUSTERED
(
[SessionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Students] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Students](
[RegistrationId] [int] IDENTITY(1,1) NOT NULL,
[RollNo] [int] NULL,
[RegistrationDate] [date] NULL,
[Name] [varchar](40) NULL,
[DOB] [date] NULL,
[Gender] [varchar](6) NULL,
[FatherName] [varchar](40) NULL,
[MotherName] [varchar](40) NULL,
[Address] [varchar](50) NULL,
[City] [varchar](20) NULL,
[ContactNo] [int] NULL,
[EmailId] [varchar](50) NULL,
[Nationality] [varchar](20) NULL,
[CourseId] [int] NULL,
[SessionId] [int] NULL,
PRIMARY KEY CLUSTERED
(
[RegistrationId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Subjects] Script Date: 7/18/2019 2:52:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Subjects](
[SubjectId] [int] IDENTITY(1,1) NOT NULL,
[Subject] [varchar](10) NULL,
[Description] [varchar](40) NULL,
PRIMARY KEY CLUSTERED
(
[SubjectId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Courses] ON
GO
INSERT [dbo].[Courses] ([CourseId], [courseName], [Description]) VALUES (12, N’B.Tech EE’, N’Electrical Engineering’)
GO
INSERT [dbo].[Courses] ([CourseId], [courseName], [Description]) VALUES (13, N’B.Tech ME’, N’Mechanical engineering’)
GO
INSERT [dbo].[Courses] ([CourseId], [courseName], [Description]) VALUES (14, N’B.Tech CSE’, N’Computer Science and Engineering’)
GO
INSERT [dbo].[Courses] ([CourseId], [courseName], [Description]) VALUES (15, N’B.Tech ECE’, N’Electronics and Communication Engineering’)
GO
INSERT [dbo].[Courses] ([CourseId], [courseName], [Description]) VALUES (16, N’BTech IT’, N’Information Technology’)
GO
SET IDENTITY_INSERT [dbo].[Courses] OFF
GO
SET IDENTITY_INSERT [dbo].[Enrollments] ON
GO
INSERT [dbo].[Enrollments] ([EnrollmentId], [EDate], [Semester], [RegistrationId], [IsCurrent]) VALUES (3, CAST(N’2019-07-18′ AS Date), N’5th’, 5, 1)
GO
INSERT [dbo].[Enrollments] ([EnrollmentId], [EDate], [Semester], [RegistrationId], [IsCurrent]) VALUES (4, CAST(N’2019-07-18′ AS Date), N’5th’, 8, 1)
GO
INSERT [dbo].[Enrollments] ([EnrollmentId], [EDate], [Semester], [RegistrationId], [IsCurrent]) VALUES (5, CAST(N’2019-07-18′ AS Date), N’5th’, 7, 1)
GO
SET IDENTITY_INSERT [dbo].[Enrollments] OFF
GO
SET IDENTITY_INSERT [dbo].[SemesterSubjects] ON
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (1, N”, 16, 6, 16)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (2, N”, 16, 6, 16)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (3, N’2nd’, 13, 3, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (4, N’1st’, 14, 3, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (5, N’1st’, 14, 4, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (6, N’1st’, 14, 5, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (7, N’1st’, 14, 6, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (8, N’1st’, 14, 6, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (9, N’2nd’, 14, 3, 13)
GO
INSERT [dbo].[SemesterSubjects] ([SemesterSubjectId], [Semester], [CourseId], [SubjectId], [SessionId]) VALUES (10, N’2nd’, 14, 4, 13)
GO
SET IDENTITY_INSERT [dbo].[SemesterSubjects] OFF
GO
SET IDENTITY_INSERT [dbo].[Sessions] ON
GO
INSERT [dbo].[Sessions] ([SessionId], [Session]) VALUES (13, N’2017-2021′)
GO
INSERT [dbo].[Sessions] ([SessionId], [Session]) VALUES (14, N’2018-2022′)
GO
INSERT [dbo].[Sessions] ([SessionId], [Session]) VALUES (15, N’2019-2023′)
GO
INSERT [dbo].[Sessions] ([SessionId], [Session]) VALUES (16, N’2020-2024′)
GO
SET IDENTITY_INSERT [dbo].[Sessions] OFF
GO
SET IDENTITY_INSERT [dbo].[Students] ON
GO
INSERT [dbo].[Students] ([RegistrationId], [RollNo], [RegistrationDate], [Name], [DOB], [Gender], [FatherName], [MotherName], [Address], [City], [ContactNo], [EmailId], [Nationality], [CourseId], [SessionId]) VALUES (5, 11701131, CAST(N’2019-08-18′ AS Date), N’Ankush Kamboj’, CAST(N’2000-02-16′ AS Date), N’Male’, N”, N”, N”, N’Abohar’, 75893, N’ankush@gmail.com’, N’Indian’, 14, 13)
GO
INSERT [dbo].[Students] ([RegistrationId], [RollNo], [RegistrationDate], [Name], [DOB], [Gender], [FatherName], [MotherName], [Address], [City], [ContactNo], [EmailId], [Nationality], [CourseId], [SessionId]) VALUES (7, 11701042, CAST(N’2019-08-18′ AS Date), N’Vanshika’, CAST(N’1999-08-06′ AS Date), N’Female’, N”, N”, N”, N’Sunam’, 78945, N’Vanshika@gmail.com’, N’Indian’, 14, 13)
GO
INSERT [dbo].[Students] ([RegistrationId], [RollNo], [RegistrationDate], [Name], [DOB], [Gender], [FatherName], [MotherName], [Address], [City], [ContactNo], [EmailId], [Nationality], [CourseId], [SessionId]) VALUES (8, 11701029, CAST(N’2019-08-18′ AS Date), N’Mehak’, CAST(N’2000-04-21′ AS Date), N’Female’, N”, N”, N”, N’Fazilka’, 78945, N’Mehak@gmail.com’, N’Indian’, 14, 13)
GO
SET IDENTITY_INSERT [dbo].[Students] OFF
GO
SET IDENTITY_INSERT [dbo].[Subjects] ON
GO
INSERT [dbo].[Subjects] ([SubjectId], [Subject], [Description]) VALUES (3, N’CP’, N’Computer Programming’)
GO
INSERT [dbo].[Subjects] ([SubjectId], [Subject], [Description]) VALUES (4, N’CN’, N’Computer Networks’)
GO
INSERT [dbo].[Subjects] ([SubjectId], [Subject], [Description]) VALUES (5, N’OOPs’, N’Object Oriented Programming’)
GO
INSERT [dbo].[Subjects] ([SubjectId], [Subject], [Description]) VALUES (6, N’SE’, N’Software Enginnering’)
GO
SET IDENTITY_INSERT [dbo].[Subjects] OFF
GO
ALTER TABLE [dbo].[Attendance] WITH CHECK ADD FOREIGN KEY([EnrollmentId])
REFERENCES [dbo].[Enrollments] ([EnrollmentId])
GO
ALTER TABLE [dbo].[Attendance] WITH CHECK ADD FOREIGN KEY([RegistrationId])
REFERENCES [dbo].[Students] ([RegistrationId])
GO
ALTER TABLE [dbo].[Enrollments] WITH CHECK ADD FOREIGN KEY([RegistrationId])
REFERENCES [dbo].[Students] ([RegistrationId])
GO
ALTER TABLE [dbo].[Marks] WITH CHECK ADD FOREIGN KEY([RegistrationId])
REFERENCES [dbo].[Students] ([RegistrationId])
GO
ALTER TABLE [dbo].[Marks] WITH CHECK ADD FOREIGN KEY([SemesterSubjectId])
REFERENCES [dbo].[SemesterSubjects] ([SemesterSubjectId])
GO
ALTER TABLE [dbo].[SemesterSubjects] WITH CHECK ADD FOREIGN KEY([CourseId])
REFERENCES [dbo].[Courses] ([CourseId])
GO
ALTER TABLE [dbo].[SemesterSubjects] WITH CHECK ADD FOREIGN KEY([SessionId])
REFERENCES [dbo].[Sessions] ([SessionId])
GO
ALTER TABLE [dbo].[SemesterSubjects] WITH CHECK ADD FOREIGN KEY([SubjectId])
REFERENCES [dbo].[Subjects] ([SubjectId])
GO
ALTER TABLE [dbo].[Students] WITH CHECK ADD FOREIGN KEY([CourseId])
REFERENCES [dbo].[Courses] ([CourseId])
GO
ALTER TABLE [dbo].[Students] WITH CHECK ADD FOREIGN KEY([SessionId])
REFERENCES [dbo].[Sessions] ([SessionId])
GO
USE [master]
GO
ALTER DATABASE [ProjectDB] SET READ_WRITE
GO

College and Home Automation System Project Using IOT Database Script

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Almost Ready ! Please Wait