def create_person_press():
    global conn
    if v.valid_name_check(fName.get()):
        if v.valid_name_check(lName.get()):
            with conn:
                person = (fName.get(), lName.get())
                ds.create_person(conn, person)
        else:
            mb.showinfo(title='Last name input error', message='Invalid last name.')
    else:
        mb.showinfo(title='First name input error', message='Invalid first name.')
def view_student_table():
    global conn
    outputStr = []
    with conn:
        rows = ds.select_all_students(conn)
        for row in rows:
            outputStr.append(row)

    outputLabel.config(text = print_table_output(outputStr))
def create_student_press():
    global conn
    if v.valid_name_check(fName.get()):
        if v.valid_name_check(lName.get()):
            if v.valid_alpha_check(major.get()):
                if v.valid_date(sDate.get()):
                    if ds.find_person_id(conn, fName.get(), lName.get()) == None:
                        mb.showinfo(title='No person found', message='Person not found. Please check the name.')
                    else:
                        with conn:
                            student = (ds.find_person_id(conn, fName.get(), lName.get()), major.get(), sDate.get())
                            student_id = ds.create_student(conn, student)
                else:
                    mb.showinfo(title='Date input error', message='Invalid date. Please use DD-MM-YYYY format.')
            else:
                mb.showinfo(title='Major input error', message='Invalid major. Please use alphabetic characters'
                                                              ' and spaces only.')
        else:
            mb.showinfo(title='Last name input error', message='Invalid last name.')
    else:
        mb.showinfo(title='First name input error', message='Invalid first name.')
def test_press():
    global conn
    if ds.find_person_id(conn, fName.get(), lName.get()) == None:
        outputLabel.config(text='No matching person found.')
    else:
        outputLabel.config(text =ds.find_person_id(conn, fName.get(), lName.get()))
def reset_press():
    global conn
    with conn:
        ds.drop_tables("StudentInfo.db")
        ds.create_tables("StudentInfo.db")
        outputLabel.config(text = 'Database reset')
        outputString = (outputString + str(i) + '\n')
    return outputString

def test_press():
    global conn
    if ds.find_person_id(conn, fName.get(), lName.get()) == None:
        outputLabel.config(text='No matching person found.')
    else:
        outputLabel.config(text =ds.find_person_id(conn, fName.get(), lName.get()))

'''Defining gui object'''
DatabaseGUI = tk.Tk()
DatabaseGUI.title('Student Records')

'''Establishing DB connection'''
conn = ds.create_connection("StudentInfo.db")

testButton = tk.Button(DatabaseGUI, text='test', width=15, command=test_press).grid(row=7, column=4)

'''Defining input prompt labels'''
fNameLabel = ttk.Label(DatabaseGUI, text="First Name")
fNameLabel.grid(column=0, row=0)

lNameLabel = ttk.Label(DatabaseGUI, text="Last Name")
lNameLabel.grid(column=0, row=1)

majorLabel = ttk.Label(DatabaseGUI, text="Major")
majorLabel.grid(column=0, row=2)

startDateLabel = ttk.Label(DatabaseGUI, text="Start Date")
startDateLabel.grid(column=0, row=3)