def Calculate_Incentive():

    if len(Name.get()) == 0:
        window2 = tk.Tk()
        window2.title("Error!")
        w = 310
        h = 65

        ws = window.winfo_screenwidth ()
        hs = window.winfo_screenheight ()

        x = (ws / 2) - (w / 2)
        y = (hs / 2) - (h / 2)

        window2.geometry('%dx%d+%d+%d' % (w, h, x, y))

        tk.Label(window2, text="Please Enter Your Name.", font=('Helvetica', 20), fg='red')\
            .grid(row=0, column=0, columnspan=3)
        tk.Button(window2, text="OK", command=window2.destroy, width=12, fg='red')\
            .grid(row=1, column=1)
        return
    else:
        User_name = Name.get()

    if len(No_Of_Cars_Sold.get()) == 0:
        e1.insert(tk.END, "0")
    if len(No_Of_MGA_Sold.get()) == 0:
        e2.insert(tk.END, "0")
    if len(No_Of_Warranty_Sold.get()) == 0:
        e3.insert(tk.END, "0")
    if len(Spot.get()) == 0:
        e4.insert(tk.END, "0")
    if len(Dzire.get()) == 0:
        e5.insert(tk.END, "0")
    if len(Brezza.get()) == 0:
        e6.insert(tk.END, "0")

    Backend.Writig_Users(User_name, No_Of_Cars_Sold.get(), No_Of_MGA_Sold.get(), No_Of_Warranty_Sold.get(),
                         Spot.get(), Dzire.get(), Brezza.get())
    frame.destroy()

    C = Backend.Calculate_Car_Incentive(int(No_Of_Cars_Sold.get()))
    M = Backend.Calculate_MGA_Incentive(int(No_Of_MGA_Sold.get()))
    W = Backend.Calculate_Warranty_Incentive(int(No_Of_Warranty_Sold.get()))
    S = int(Spot.get()) * Backend.Spot_get()
    D = int(Dzire.get()) * Backend.Dzire_get()
    B = int(Brezza.get()) * Backend.Brezza_get()

    Incentive = C + M + W + S + D + B

    if M == 0:
        Incentive = Incentive - (Incentive * (20 / 100))
    else:
        pass

    Incentive_Window(User_name, C, M, W, S, D, B, Incentive)
def Others_values():

    global frame4
    global Warranty_Condition
    global Dzire_Condition
    global Brezza_Condition
    global Spot_Condition
    global window_place

    window_place = "Admin_Setting"

    Warranty_Condition = tk.StringVar()
    Brezza_Condition = tk.StringVar()
    Dzire_Condition = tk.StringVar()
    Spot_Condition = tk.StringVar()

    frame4 = tk.Frame(window)
    frame4.pack()

    tk.Label ( frame4 , text="Incentive Calculator" , font=("Helvetica" , 50) , bg="cyan" )\
        .grid(row=1, column=0, columnspan=3)
    tk.Label(frame4, text='Admin', fg='Red', font=('Helvetica', 15))\
        .grid(row=3, column=1)
    tk.Label(frame4, text='Warranty', font=('Helvetica', 20))\
        .grid(row=4, column=0, columnspan=2)
    tk.Label(frame4, text='AGS Retails', font=('Helvetica', 20))\
        .grid(row=5, column=0, columnspan=2)
    tk.Label(frame4, text='Dzire Booking', font=('Helvetica', 20))\
        .grid(row=6, column=0, columnspan=2)
    tk.Label(frame4, text='Brezza Booking', font=('Helvetica', 20))\
        .grid(row=7, column=0, columnspan=2)

    e1111 = tk.Entry(frame4, textvariable=Warranty_Condition, font=('Helvetica', 11), bd=10, justify='center')
    e2222 = tk.Entry(frame4, textvariable=Spot_Condition, font=('Helvetica', 11), bd=10, justify='center')
    e3333 = tk.Entry(frame4, textvariable=Dzire_Condition, font=('Helvetica', 11), bd=10, justify='center')
    e4444 = tk.Entry(frame4, textvariable=Brezza_Condition, font=('Helvetica', 11), bd=10, justify='center')

    tk.Button(frame4, text='Save', width=12, command=updateOther, border=7, bg='blue', fg='white')\
        .grid(row=8, column=1, columnspan=2)
    tk.Button(frame4, text='Close', width=12, command=window.destroy, border=7, bg='blue', fg='white')\
        .grid(row=8, column=0, columnspan=2)
    tk.Button(frame4, text='Other', width=12, command=Other_decision, border=7, bg='blue', fg='white')\
        .grid(row=2, column=0)
    tk.Button(frame4, text='MGA', width=12, command=Mga_values_decision, border=7, bg='blue', fg='white')\
        .grid(row=2, column=1)
    tk.Button(frame4, text='Cars', width=12, command=Car_values_decision, border=7, bg='blue', fg='white')\
        .grid(row=2, column=2)

    tem1 = Backend.Warranty_get()
    tem2 = Backend.Spot_get()
    tem3 = Backend.Brezza_get()
    tem4 = Backend.Dzire_get()

    e1111.insert(tk.END, tem1)
    e2222.insert(tk.END, tem2)
    e3333.insert(tk.END, tem3)
    e4444.insert(tk.END, tem4)

    e1111.grid(row=4, column=1, columnspan=2)
    e2222.grid(row=5, column=1, columnspan=2)
    e3333.grid(row=6, column=1, columnspan=2)
    e4444.grid(row=7, column=1, columnspan=2)