Example #1
0
    def update_details_of_staff_member():
        def back_to_page1():
            show_employee_frame.grid_forget()
            page1()

        def update_that_particular_employee():
            show_employee_frame.grid_forget()

            def back_to_page1_from_update():
                update_frame.destroy()
                page1()

            def update_name_in_database():
                def database_calling():
                    new_name = entry19.get()
                    if len(new_name) != 0:
                        old_name = staff_name.get()
                        backend.update_employee_name(new_name, old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error',
                                                    'Please fill entry')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=1, column=1, padx=4)
                global update_button
                update_button = Button(update_frame,
                                       text='Update',
                                       command=database_calling)
                update_button.grid(row=1, column=2, padx=4)

            def update_password_in_database():
                def database_calling():
                    new_password = entry19.get()
                    old_name = staff_name.get()
                    if len(new_password) != 0:
                        backend.update_employee_password(
                            new_password, old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error',
                                                    'Please Fill Entry')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=2, column=1, padx=4)
                global update_button
                update_button = Button(update_frame,
                                       text='Update',
                                       command=database_calling)
                update_button.grid(row=2, column=2, padx=4)

            def update_salary_in_database():
                def database_calling():
                    new_salary = entry19.get()
                    r = check_string_in_account_no(new_salary)
                    if len(new_salary) != 0 and r:

                        old_name = staff_name.get()
                        backend.update_employee_salary(new_salary, old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error', 'Invalid Input')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=3, column=1, padx=4)
                global update_button
                update_button = Button(update_frame,
                                       text='Update',
                                       command=database_calling)
                update_button.grid(row=3, column=2, padx=4)

            def update_position_in_database():
                def database_calling():
                    new_position = entry19.get()
                    if len(new_position) != 0:

                        old_name = staff_name.get()
                        backend.update_employee_position(
                            new_position, old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error',
                                                    'Please Fill Entry')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=4, column=1, padx=4)
                global update_button
                update_button = Button(update_frame,
                                       text='Update',
                                       command=database_calling)
                update_button.grid(row=4, column=2, padx=4)

            global update_frame
            update_frame = Frame(tk)
            update_frame.grid(padx=400, pady=250)

            label = Label(update_frame,
                          text='press what do you want to update',
                          font='bold')
            label.grid(pady=6)

            button = Button(update_frame,
                            text='Name',
                            command=update_name_in_database,
                            width=14,
                            height=2)
            button.grid(row=1, column=0, padx=2, pady=2)

            button = Button(update_frame,
                            text='password',
                            command=update_password_in_database,
                            width=14,
                            height=2)
            button.grid(row=2, column=0, padx=2, pady=2)

            button = Button(update_frame,
                            text='salary',
                            command=update_salary_in_database,
                            width=14,
                            height=2)
            button.grid(row=3, column=0, padx=2, pady=2)

            button = Button(update_frame,
                            text='position',
                            command=update_position_in_database,
                            width=14,
                            height=2)
            button.grid(row=4, column=0, padx=2, pady=2)

            button = Button(update_frame,
                            text='Back',
                            command=back_to_page1_from_update,
                            width=14,
                            height=2)
            button.grid(row=5, column=0, pady=2)

        name = staff_name.get()
        if len(name) != 0:
            result = backend.check_name_in_staff(name)
            if result:

                update_that_particular_employee()
            else:
                label = Label(show_employee_frame, text='Employee not found')
                label.grid()

                button = Button(show_employee_frame,
                                text='Exit',
                                command=back_to_page1)
                button.grid()

        else:
            label = Label(show_employee_frame, text='Fill the name')
            label.grid()

            button = Button(show_employee_frame,
                            text='Exit',
                            command=back_to_page1)
            button.grid()
Example #2
0
    def update_details_of_staff_member():
        def back_to_page1():
            show_employee_frame.grid_forget()
            page1()
        def update_that_particular_employee():
            show_employee_frame.grid_forget()
            def back_to_page1_from_update():
                update_frame.destroy()
                page1()

            def update_name_in_database():

                def database_calling():
                    new_name = entry19.get()
                    if len(new_name)!=0:
                        old_name=staff_name.get()
                        backend.update_employee_name(new_name,old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error','Please fill entry')
                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=1, column=1, padx=4)
                global update_button
                update_button = Button(update_frame, text='Update', command=database_calling)
                update_button.grid(row=1, column=2, padx=4)

            def update_password_in_database():

                def database_calling():
                    new_password = entry19.get()
                    old_name=staff_name.get()
                    if len(new_password)!=0:
                        backend.update_employee_password(new_password,old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error','Please Fill Entry')
                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=2, column=1, padx=4)
                global update_button
                update_button = Button(update_frame, text='Update', command=database_calling)
                update_button.grid(row=2, column=2, padx=4)

            def update_salary_in_database():

                def database_calling():
                    new_salary = entry19.get()
                    r=check_string_in_account_no(new_salary)
                    if len(new_salary)!=0 and r:

                        old_name=staff_name.get()
                        backend.update_employee_salary(new_salary,old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error','Invalid Input')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=3, column=1, padx=4)
                global update_button
                update_button = Button(update_frame, text='Update', command=database_calling)
                update_button.grid(row=3, column=2, padx=4)

            def update_position_in_database():

                def database_calling():
                    new_position = entry19.get()
                    if len(new_position)!=0:

                        old_name=staff_name.get()
                        backend.update_employee_position(new_position,old_name)
                        entry19.destroy()
                        update_button.destroy()
                    else:
                        entry19.destroy()
                        update_button.destroy()
                        tkinter.messagebox.showinfo('Error','Please Fill Entry')

                global entry19
                entry19 = Entry(update_frame)
                entry19.grid(row=4, column=1, padx=4)
                global update_button
                update_button = Button(update_frame, text='Update', command=database_calling)
                update_button.grid(row=4, column=2, padx=4)

            global update_frame
            update_frame = Frame(tk)
            update_frame.grid(padx=400, pady=250)

            label = Label(update_frame, text='press what do you want to update',font='bold')
            label.grid(pady=6)

            button = Button(update_frame, text='Name', command=update_name_in_database,width=14,height=2)
            button.grid(row=1, column=0, padx=2,pady=2)

            button = Button(update_frame, text='password',command=update_password_in_database,width=14,height=2)
            button.grid(row=2, column=0, padx=2,pady=2)

            button = Button(update_frame, text='salary',command=update_salary_in_database,width=14,height=2)
            button.grid(row=3, column=0, padx=2,pady=2)

            button = Button(update_frame, text='position',command=update_position_in_database,width=14,height=2)
            button.grid(row=4, column=0, padx=2,pady=2)

            button = Button(update_frame, text='Back', command=back_to_page1_from_update,width=14,height=2)
            button.grid(row=5, column=0,pady=2)




        name=staff_name.get()
        if len(name)!=0:
            result=backend.check_name_in_staff(name)
            if result:

                update_that_particular_employee()
            else:
                label = Label(show_employee_frame, text='Employee not found')
                label.grid()

                button = Button(show_employee_frame, text='Exit', command=back_to_page1)
                button.grid()

        else:
            label=Label(show_employee_frame,text='Fill the name')
            label.grid()

            button=Button(show_employee_frame,text='Exit',command=back_to_page1)
            button.grid()