def update_student(self): if not self.rows: messagebox.showerror("Error", "Choose a student from the table first") return elif not SISdatabase.info_checker(self.id_no.get(), self.name.get().upper(), self.year.get(), self.course.get().upper(), self.gender.get().upper()): return else: if messagebox.askyesno( "Update Course", "Do you wish to update the student information?"): if SISdatabase.update_student_rec(self.rows[0], self.id_no.get(), self.name.get().upper(), self.year.get(), self.course.get().upper(), self.gender.get()): messagebox.showinfo( "Success", "Information on student has been updated!") self.clear_data() self.rows = [] displaytable.display_student_table(self.student_table)
def delete_student(self): cursor_row = self.student_table.focus() contents = self.student_table.item(cursor_row) rows = contents['values'] if rows == "": messagebox.showerror("Error", "Select a student first!") else: if messagebox.askyesno("Delete Student", "Do you wish to delete this student?"): SISdatabase.delete_student_rec(rows[0]) messagebox.showinfo("Success", "Student deleted in database!") disp.display_student_table(self.student_table) self.default_layout() return else: return
def update_course(self): if not self.rows: messagebox.showerror("Error", "Choose a course from the table first") elif self.edit_course_id_entry.get( ) == "" or self.edit_course_text.get(1.0, END) == "": messagebox.showerror("Error", "Please fill all fields") return else: if messagebox.askyesno( "Update Course", "Do you wish to update the course information? Some students might" " be enrolled in this course?"): if SISdatabase.update_course_rec( self.rows[0], self.course_id.get().upper(), self.edit_course_text.get(1.0, END).upper().replace( "\n", "")): messagebox.showinfo( "Success", "Information on course has been updated!") self.clear_data() self.rows = [] disp.display_course_table(self.course_table) return else: return
def search_course(self): result = SISdatabase.search_course_rec( self.search_course_id.get().upper()) self.course_table.delete(*self.course_table.get_children()) if not result: return else: for x in result: self.course_table.insert('', 0, values=(x[0], x[1]))
def search_student(self): result = SISdatabase.search_student_rec(self.search_stud.get().upper()) self.student_table.delete(*self.student_table.get_children()) if not result: return else: for x in result: self.student_table.insert('', 0, values=(x[0], x[1], x[3], x[2], x[4]))
def add_student(self): if messagebox.askyesno( "Add Student", "Do you want to add the student in the database"): if not SISdatabase.info_checker(self.id_no.get(), self.name.get().upper(), self.year.get(), self.course.get().upper(), self.gender.get().upper()): return else: if SISdatabase.add_student_rec(self.id_no.get(), self.name.get().upper(), self.year.get(), self.course.get().upper(), self.gender.get()): messagebox.showinfo("Success", "Student added to database") self.clear_data() displaytable.display_student_table(self.student_table) else: return
def add_course(self): if self.add_course_id_entry.get() == "" or self.add_course_text.get(1.0, END) == "": messagebox.showerror("Error", "Please fill all fields") return else: if messagebox.askyesno("Add Course", "Do you wish to add the course to database?"): if SISdatabase.add_course_rec(self.course_id.get().upper(), self.add_course_text.get(1.0, END).upper().replace("\n", "")): messagebox.showinfo("Success", "Course added to database.") self.clear_data() displaytable.display_course_table(self.course_table) else: return else: return
def delete_course(self): cursor_row = self.course_table.focus() contents = self.course_table.item(cursor_row) rows = contents['values'] if rows == "": messagebox.showerror("Error", "Select course first") return else: if messagebox.askyesno( "Delete Course", "Do you wish to delete this course? Some students might be enrolled" " in this course."): if SISdatabase.delete_course_rec(rows[0]): disp.display_course_table(self.course_table) messagebox.showinfo("Success", "Course deleted in database") self.default_layout() return else: return
def count_data(self): self.student_count.config(text=len(SISdatabase.view_student_rec())) self.course_count.config(text=len(SISdatabase.view_course_rec()))
def __init__(self, frame): # creates database table for students and courses SISdatabase.data() self.frame = frame self.frame.title("Student Information System") self.frame.geometry("1200x680+63+8") self.frame.resizable(False, False) self.frame.iconbitmap(r"images\logosis.ico") # background frames bg_frame = Frame(self.frame, bg="#A51d23") bg_frame.place(x=0, y=0, width=1200, height=680) # navigation frame self.nav_frame = Frame(bg_frame, bg="#A51d23") self.nav_frame.place(x=3, y=3, width=260, height=674) # contents frame self.right_frame = Frame(bg_frame, bg="#FA9412") self.right_frame.place(x=266, y=0, width=940, height=680) self.SISlogopic = PhotoImage( file=r"images\sislabellogo.png").subsample(2, 2) icon_pic_lbl = Label(self.nav_frame, image=self.SISlogopic) icon_pic_lbl.photo = self.SISlogopic icon_pic_lbl.place(x=5, y=10, width=250, height=180) self.dashboard_img = PhotoImage(file=r"images\dashboardimg.png") self.student_img = PhotoImage(file=r"images\studimg.png") self.course_img = PhotoImage(file=r"images\courseimg.png") self.about_img = PhotoImage(file=r"images\aboutimg.png") dashbrd_nav_button = Button(self.nav_frame, command=self.dashboard_frame_gui, relief=FLAT, activebackground="#A51d23", activeforeground="white", fg="#FA9412", bg="#A51d23", image=self.dashboard_img, text=" Dashboard", font=("Blinker", 17, "bold"), anchor="w", compound="left") dashbrd_nav_button.place(x=0, y=200, width=260, height=50) stud_nav_button = Button(self.nav_frame, command=self.student_frame_gui, relief=FLAT, activebackground="#A51d23", activeforeground="white", fg="#FA9412", bg="#A51d23", image=self.student_img, text=" Students", font=("Blinker", 17, "bold"), anchor="w", compound="left") stud_nav_button.place(x=0, y=250, width=260, height=50) course_nav_button = Button(self.nav_frame, command=self.courses_frame_gui, relief=FLAT, activebackground="#A51d23", activeforeground="white", fg="#FA9412", bg="#A51d23", image=self.course_img, text=" Courses", font=("Blinker", 17, "bold"), anchor="w", compound="left") course_nav_button.place(x=0, y=300, width=260, height=50) about_nav_button = Button(self.nav_frame, command=self.about_frame_gui, relief=FLAT, activebackground="#A51d23", activeforeground="white", fg="#FA9412", bg="#A51d23", image=self.about_img, text=" About", font=("Blinker", 17, "bold"), anchor="w", compound="left") about_nav_button.place(x=0, y=350, width=260, height=50) self.dashboard_cont_frame = Frame(self.right_frame, bg="white", highlightbackground="#A51d23", highlightthickness=2) self.student_cont_frame = Frame(self.right_frame, bg="white", highlightbackground="#A51d23", highlightthickness=2) self.courses_cont_frame = Frame(self.right_frame, bg="white", highlightbackground="#A51d23", highlightthickness=2) self.about_cont_frame = Frame(self.right_frame, bg="white", highlightbackground="#A51d23", highlightthickness=2) self.head_bldsgn_img = PhotoImage(file=r"images\label_design.png") self.heading_label = Label(self.right_frame, text="", bg="#A51d23", fg="white", anchor="w", font=("Blinker", 20, "bold")) self.heading_lbldsgn = Label(self.right_frame, image=self.head_bldsgn_img, bg="#A51d23", fg="white", anchor='sw') self.heading_label.place(x=20, y=50, width=900, height=50) self.heading_lbldsgn.place(x=800, y=50, width=120, height=50) self.dashboard_frame_gui()
def display_course_table(course_table): course_table.delete(*course_table.get_children()) course_data = SISdatabase.view_course_rec() for x in course_data: course_table.insert('', 0, values=(x[0], x[1]))
def display_student_table(student_table): student_table.delete(*student_table.get_children()) student_data = SISdatabase.view_student_rec() for x in student_data: student_table.insert('', 0, values=(x[0], x[1], x[3], x[2], x[4]))