danyalbasar

save_error

Sep 12th, 2021 (edited)
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 28.61 KB | None | 0 0
  1. from tkinter import ttk
  2. from tkinter import *
  3. from tkinter.messagebox import *
  4. from tkinter import messagebox
  5. from tkinter.scrolledtext import *
  6. from PIL import Image, ImageTk
  7. from sqlite3 import *
  8. import datetime
  9.  
  10. admin_main_window, user_main_window = "", ""
  11. count1 = 0
  12.  
  13. def general_window_setup(size, window, title, icon):
  14.     window.title(title)
  15.     window.iconbitmap(icon)
  16.  
  17.     window_width = size[0]
  18.     window_height = size[1]
  19.     window_x = int((window.winfo_screenwidth() / 2) - (window_width / 2))
  20.     window_y = int((window.winfo_screenheight() / 2) - (window_height / 2))
  21.  
  22.     window_geometry = str(window_width) + 'x' + str(window_height) + '+' + str(window_x) + '+' + str(window_y)
  23.     window.geometry(window_geometry)
  24.  
  25.     window.resizable(False, False)
  26.  
  27.     return
  28.  
  29. def check_login_cred():
  30.     if ent_username.get() == "" or ent_password.get() == "":
  31.         ent_username.delete(0, END)
  32.         ent_password.delete(0, END)
  33.         admin_home_pg()
  34.  
  35. def admin_home_pg():
  36.     global admin_main_window
  37.     login_window.withdraw()
  38.  
  39.     admin_main_window = Toplevel(login_window)
  40.     admin_main_window.withdraw()
  41.     general_window_setup((500, 500), admin_main_window, "Admin Homepage", "download.ico")
  42.  
  43.     bg_image = ImageTk.PhotoImage(file="login_home_pg_bg_img.jpg")
  44.  
  45.     admin_main_window_canvas = Canvas(admin_main_window, width=500, height=500, bd=0, highlightthickness=0)
  46.     admin_main_window_canvas.pack(fill="both", expand=True)
  47.     admin_main_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  48.  
  49.     def admin_home_pg_sign_out():
  50.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to sign out?', icon='warning')
  51.         #if res == 'yes':
  52.         login_window.deiconify()
  53.         admin_main_window.destroy()
  54.  
  55.     f = ("Arial", 17, "bold")
  56.  
  57.     mw_btn_add = Button(admin_main_window, text="Add", activebackground='#6162FF', activeforeground="white", bd=1, font=f, width=12, bg="#6162FF", fg="white", command=admin_home_pg_add)
  58.     mw_btn_add.place(x=153, y=75)
  59.     mw_btn_add.bind("<Enter>", lambda e: mw_btn_add.config(fg='white', bg='#8080ff'))
  60.     mw_btn_add.bind("<Leave>", lambda e: mw_btn_add.config(fg='white', bg='#6162FF'))
  61.  
  62.     mw_btn_update = Button(admin_main_window, text="Update", activebackground='#6162FF', activeforeground="white", bd=1, font=f, bg="#6162FF", fg="white", width=12)
  63.     mw_btn_update.place(x=153, y=145)
  64.     mw_btn_update.bind("<Enter>", lambda e: mw_btn_update.config(fg='white', bg='#8080ff'))
  65.     mw_btn_update.bind("<Leave>", lambda e: mw_btn_update.config(fg='white', bg='#6162FF'))
  66.  
  67.     mw_btn_delete = Button(admin_main_window, text="Delete", activebackground='#6162FF', activeforeground="white", bd=1, font=f, bg="#6162FF", fg="white", width=12)
  68.     mw_btn_delete.place(x=153, y=213)
  69.     mw_btn_delete .bind("<Enter>", lambda e: mw_btn_delete .config(fg='white', bg='#8080ff'))
  70.     mw_btn_delete .bind("<Leave>", lambda e: mw_btn_delete .config(fg='white', bg='#6162FF'))
  71.  
  72.     mw_btn_view = Button(admin_main_window, text="View", bd=1, activebackground='#6162FF', activeforeground="white", font=f, bg="#6162FF", fg="white", width=12)
  73.     mw_btn_view.place(x=153, y=280)
  74.     mw_btn_view.bind("<Enter>", lambda e: mw_btn_view.config(fg='white', bg='#8080ff'))
  75.     mw_btn_view.bind("<Leave>", lambda e: mw_btn_view.config(fg='white', bg='#6162FF'))
  76.  
  77.     mw_btn_sign_out = Button(admin_main_window, text="Log Out", activebackground='red', activeforeground="white", bd=1, font=f, width=12, bg="red", fg="white", command=admin_home_pg_sign_out)
  78.     mw_btn_sign_out.place(x=153, y=350)
  79.     mw_btn_sign_out .bind("<Enter>", lambda e: mw_btn_sign_out .config(fg='white', bg='#ff6464'))
  80.     mw_btn_sign_out .bind("<Leave>", lambda e: mw_btn_sign_out .config(fg='white', bg='red'))
  81.  
  82.     admin_main_window.deiconify()
  83.     admin_main_window.mainloop()
  84.  
  85. def admin_home_pg_add():
  86.     global admin_main_window
  87.  
  88.     admin_main_window.withdraw()
  89.  
  90.     admin_window =Toplevel(admin_main_window)
  91.     admin_window.withdraw()
  92.     general_window_setup((1280, 768), admin_window, "Admin Add Page", "download.ico")
  93.  
  94.     bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  95.  
  96.     admin_window_canvas = Canvas(admin_window, width=1280, height=768, bd=0, highlightthickness=0)
  97.     admin_window_canvas.pack(fill="both", expand=True)
  98.     admin_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  99.  
  100.     def admin_add_exit():  
  101.         res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  102.         if res == 'yes':
  103.             #admin_main_window.deiconify()
  104.             admin_window.destroy()
  105.             admin_main_window.destroy()
  106.             login_window.destroy()
  107.  
  108.     def admin_add_clear():
  109.         ent_ref_no.delete(0, END)
  110.         ent_date.delete(0, END)
  111.         combo_issue_reported.delete(0, END)
  112.         scr_issue_reported.delete(1.0, END)
  113.         combo_issue_diagnosed.delete(0, END)
  114.         scr_issue_diagnosed.delete(1.0, END)
  115.         ent_issue_logged_by.delete(0, END)
  116.         combo_machine_type.delete(0, END)
  117.         ent_machine_model.delete(0, END)
  118.         ent_machine_sr_no.delete(0, END)
  119.         scr_machine_details.delete(1.0, END)
  120.         ent_machine_brought_in_by.delete(0, END)
  121.  
  122.     def admin_add_next():
  123.         ref_no = ent_ref_no.get()
  124.  
  125.         if len(ref_no) == 0:
  126.             showerror("Ref. No. Issue", "Ref. No. cannot be empty")
  127.             ent_ref_no.delete(0, END)
  128.             ent_ref_no.focus()
  129.             return
  130.  
  131.         admin_window.withdraw()
  132.  
  133.         admin_add_next_window =Toplevel(admin_window)
  134.         admin_add_next_window.withdraw()
  135.         general_window_setup((1280, 768), admin_add_next_window, "Admin Add Page", "download.ico")
  136.  
  137.         bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  138.  
  139.         admin_add_next_window_canvas = Canvas(admin_add_next_window, width=1280, height=768, bd=0, highlightthickness=0)
  140.         admin_add_next_window_canvas.pack(fill="both", expand=True)
  141.         admin_add_next_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  142.  
  143.         def admin_add_next_back():
  144.             admin_window.deiconify()
  145.             admin_add_next_window.withdraw()       
  146.  
  147.         def admin_add_next_clear():
  148.             ent_first_name.delete(0, END)
  149.             ent_last_name.delete(0, END)
  150.             ent_email_1.delete(0, END)
  151.             ent_email_2.delete(0, END)
  152.             ent_mobile_no_1.delete(0, END)
  153.             ent_mobile_no_2.delete(0, END)
  154.             ent_co_name.delete(0, END)
  155.             ent_co_loc.delete(0, END)
  156.             ent_customer_of.delete(0, END)
  157.             ent_address.delete(1.0, END)
  158.             ent_landmark.delete(0, END)
  159.             ent_city.delete(0, END)
  160.             combo_state.delete(0, END)
  161.             ent_pincode.delete(0, END)
  162.  
  163.         def admin_add_next_2():
  164.             con = None
  165.             try:
  166.                 con = connect("customer_data.db")
  167.                 cursor = con.cursor()
  168.                 cursor.execute("""CREATE TABLE if not exists customers (
  169.                     ref_no int primary key,
  170.                     issue_reported_date text,
  171.                     issue_reported text,
  172.                     issue_reported_details text,
  173.                     issue_diagnosed text,
  174.                     issue_diagnosed_details text,
  175.                     issue_logged_by text,
  176.                     machine_type text,
  177.                     machine_model text,
  178.                     machine_sr_no text,
  179.                     machine_details text,
  180.                     machine_brought_in_by text,
  181.                     f_name text,
  182.                     l_name text,
  183.                     email text,
  184.                     second_email text,
  185.                     mob_no int,
  186.                     alter_mob_no int,
  187.                     company_name text,
  188.                     company_loc text,
  189.                     customer_of text,
  190.                     address text,
  191.                     landmark text,
  192.                     city text,
  193.                     state text,
  194.                     country text,
  195.                     pincode text)
  196.                     """)
  197.                 sql ="insert into customers values('%s', '%s', '%s', '%s', '%s', '%s,' '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')"
  198.  
  199.                 ref_no = ent_ref_no.get()
  200.                 issue_reported_date = ent_date.get()
  201.                 issue_reported = combo_issue_reported.get()
  202.                 issue_reported_details = scr_issue_reported.get("1.0",'end-1c')
  203.                 issue_diagnosed = combo_issue_diagnosed.get()
  204.                 issue_diagnosed_details = scr_issue_diagnosed.get("1.0",'end-1c')
  205.                 issue_logged_by = ent_issue_logged_by.get()
  206.                 machine_type = combo_machine_type.get()
  207.                 machine_model = ent_machine_model.get()
  208.                 machine_sr_no = ent_machine_sr_no.get()
  209.                 machine_details = scr_machine_details.get("1.0",'end-1c')
  210.                 machine_brought_in_by = ent_machine_brought_in_by.get()
  211.                 f_name = ent_first_name.get()
  212.                 l_name = ent_last_name.get()
  213.                 email = ent_email_1.get()
  214.                 second_email = ent_email_2.get()
  215.                 mob_no = ent_mobile_no_1.get()
  216.                 alter_mob_no = ent_mobile_no_2.get()
  217.                 company_name = ent_co_name.get()
  218.                 company_loc = ent_co_loc.get()
  219.                 customer_of = ent_customer_of.get()
  220.                 address = ent_address.get("1.0",'end-1c')
  221.                 landmark = ent_landmark.get()
  222.                 city = ent_city.get()
  223.                 state = combo_state.get()
  224.                 country = ent_country.get()
  225.                 pincode = ent_pincode.get()
  226.    
  227.                 if len(f_name) == 0:
  228.                     showerror("First Name Issue", "Name cannot be empty")
  229.                     ent_first_name.delete(0, END)
  230.                     ent_first_name.focus()
  231.                     return
  232.                 if (not f_name.isalpha()):
  233.                     showerror("First Name Issue", "Name cannot be a number")
  234.                     ent_first_name.delete(0, END)
  235.                     ent_first_name.focus()
  236.                     return
  237.                 if (len(f_name) < 2):
  238.                     showerror("First Name Issue", "Name cannot be less than two letters")
  239.                     ent_first_name.delete(0, END)
  240.                     ent_first_name.focus()
  241.                     return
  242.                 if (not l_name.isalpha()) and (len(l_name) != 0):
  243.                     showerror("Last Name Issue", "Name cannot be a number")
  244.                     ent_last_name.delete(0, END)
  245.                     ent_last_name.focus()
  246.                     return
  247.                 if (len(l_name) < 2) and (len(l_name) != 0):
  248.                     showerror("Last Name Issue", "Name cannot be less than two letters")
  249.                     ent_last_name.delete(0, END)
  250.                     ent_last_name.focus()
  251.                     return
  252.                 if len(mob_no) == 0:
  253.                     showerror("Mobile No Issue", "Mobile No cannot be empty")
  254.                     ent_mobile_no_1.delete(0, END)
  255.                     ent_mobile_no_1.focus()
  256.                     return
  257.                 if (not mob_no.isdigit()):
  258.                     showerror("Mobile No Issue", "Mobile No should be in digits only")     
  259.                     ent_mobile_no_1.delete(0, END)
  260.                     ent_mobile_no_1.focus()
  261.                     return
  262.                 if (len(mob_no) < 10):
  263.                     showerror("Mobile No Issue", "Mobile No cannot be less than 10 digits")
  264.                     ent_mobile_no_1.delete(0, END)
  265.                     ent_mobile_no_1.focus()
  266.                     return
  267.                 if (len(mob_no) > 10):
  268.                     showerror("Mobile No Issue", "Mobile No cannot be more than 10 digits")
  269.                     ent_mobile_no_1.delete(0, END)
  270.                     ent_mobile_no_1.focus()
  271.                     return
  272.                 if (not alter_mob_no.isdigit()) and (len(alter_mob_no) != 0):
  273.                     showerror("Alternate Mobile No Issue", "Mobile No should be in digits only")       
  274.                     ent_mobile_no_2.delete(0, END)
  275.                     ent_mobile_no_2.focus()
  276.                     return
  277.                 if (len(alter_mob_no) < 10) and (len(alter_mob_no) != 0):
  278.                     showerror("Alternate Mobile No Issue", "Mobile No cannot be less than 10 digits")
  279.                     ent_mobile_no_2.delete(0, END)
  280.                     ent_mobile_no_2.focus()
  281.                     return
  282.                 if (len(alter_mob_no) > 10):
  283.                     showerror("Alternate Mobile No Issue", "Mobile No cannot be more than 10 digits")
  284.                     ent_mobile_no_2.delete(0, END)
  285.                     ent_mobile_no_2.focus()
  286.                     return
  287.  
  288.                 cursor.execute(sql % (ref_no, issue_reported_date, issue_reported, issue_reported_details, issue_diagnosed, issue_diagnosed_details, issue_logged_by, machine_type, machine_model, machine_sr_no, machine_details, machine_brought_in_by, f_name, l_name, email, second_email, mob_no, alter_mob_no, company_name, company_loc, customer_of, address, landmark, city, state, country, pincode))
  289.                 con.commit()
  290.                 showinfo("Success","Record added successfully")
  291.  
  292.             except Exception as e:
  293.                 con.rollback()
  294.                 showerror("Error", str(e))
  295.  
  296.             finally:
  297.                 if con is not None:
  298.                     con.close()
  299.  
  300.         option = StringVar()
  301.    
  302.         admin_add_next_window_canvas.create_text(180, 40, text="Contact Details", font=("Impact", 35, "bold"), fill="#6162FF")
  303.         admin_add_next_window_canvas.create_text(152, 95, text="Enter Contact Information", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  304.         admin_add_next_window_canvas.create_text(82, 140, text="First Name", font=("Goudy old style", 15, "bold"), fill="grey")
  305.         admin_add_next_window_canvas.create_text(401, 140, text="Last Name", font=("Goudy old style", 15, "bold"), fill="grey")
  306.         admin_add_next_window_canvas.create_text(55, 225, text="Email", font=("Goudy old style", 15, "bold"), fill="grey")
  307.         admin_add_next_window_canvas.create_text(430, 225, text="Secondary Email", font=("Goudy old style", 15, "bold"), fill="grey")
  308.         admin_add_next_window_canvas.create_text(81, 310, text="Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  309.         admin_add_next_window_canvas.create_text(447, 310, text="Alternate Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  310.         admin_add_next_window_canvas.create_text(104, 395, text="Company Name", font=("Goudy old style", 15, "bold"), fill="grey")
  311.         admin_add_next_window_canvas.create_text(118, 480, text="Company Location", font=("Goudy old style", 15, "bold"), fill="grey")
  312.         admin_add_next_window_canvas.create_text(91, 565, text="Customer of", font=("Goudy old style", 15, "bold"), fill="grey")
  313.         admin_add_next_window_canvas.create_text(820, 95, text="Address for Machine Location", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  314.         admin_add_next_window_canvas.create_text(720, 140, text="Address", font=("Goudy old style", 15, "bold"), fill="grey")
  315.         admin_add_next_window_canvas.create_text(728, 395, text="Landmark", font=("Goudy old style", 15, "bold"), fill="grey")
  316.         admin_add_next_window_canvas.create_text(700, 480, text="City", font=("Goudy old style", 15, "bold"), fill="grey")
  317.         admin_add_next_window_canvas.create_text(1015, 480, text="State", font=("Goudy old style", 15, "bold"), fill="grey")
  318.         admin_add_next_window_canvas.create_text(719, 565, text="Country", font=("Goudy old style", 15, "bold"), fill="grey")
  319.         admin_add_next_window_canvas.create_text(1029, 565, text="Pincode", font=("Goudy old style", 15, "bold"), fill="grey")
  320.  
  321.         ent_first_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  322.         ent_first_name.place(x=30, y=160, width=275, height=35)
  323.    
  324.         ent_last_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  325.         ent_last_name.place(x=350, y=160, width=275, height=35)
  326.  
  327.         ent_email_1 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  328.         ent_email_1.place(x=30, y=245, width=275, height=35)
  329.  
  330.         ent_email_2 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  331.         ent_email_2.place(x=350, y=245, width=275, height=35)
  332.  
  333.         ent_mobile_no_1 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  334.         ent_mobile_no_1.place(x=30, y=330, width=275, height=35)
  335.  
  336.         ent_mobile_no_2 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  337.         ent_mobile_no_2.place(x=350, y=330, width=275, height=35)
  338.    
  339.         ent_co_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  340.         ent_co_name.place(x=30, y=415, width=600, height=35)
  341.  
  342.         ent_co_loc = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  343.         ent_co_loc.place(x=30, y=500, width=600, height=35)
  344.  
  345.         ent_customer_of = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  346.         ent_customer_of.place(x=30, y=587, width=600, height=35)
  347.    
  348.         ent_address = ScrolledText(admin_add_next_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  349.         ent_address.place(x=680, y=160)
  350.  
  351.         ent_landmark = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  352.         ent_landmark.place(x=680, y=415, width=572, height=35)
  353.    
  354.         ent_city = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  355.         ent_city.place(x=680, y=500, width=275, height=35)
  356.  
  357.         f=("Goudy old style", 15)
  358.  
  359.         style = ttk.Style()
  360.         style.configure('combo_state.TCombobox', selectbackground='blue', arrowsize=15)
  361.  
  362.         combo_state = ttk.Combobox(admin_add_next_window, textvariable=option, style='combo_state.TCombobox', font=("Goudy old style", 15))
  363.         combo_state["values"] = ['Andaman and Nicobar Islands', 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Dadra and Nagar Haveli', 'Daman and Diu', 'Delhi', 'Goa', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu', 'Jharkhand', 'Karnataka', 'Kashmir', 'Kerala', 'Ladakh', 'Lakshadweep', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttarakhand', 'Uttar Pradesh', 'West Bengal']
  364.         combo_state.option_add("*TCombobox*Listbox*Font", f)
  365.         combo_state.place(x=990, y=500, width=260, height=35)
  366.         combo_state.set("")
  367.  
  368.         ent_country = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  369.         ent_country.insert(END, "India")
  370.         #ent_country.bind("<Key>", lambda a: "break")
  371.         ent_country.place(x=680, y=587, width=275, height=35)
  372.  
  373.         ent_pincode = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  374.         ent_pincode.place(x=990, y=587, width=260, height=35)
  375.    
  376.         admin_add_next_btn = Button(admin_add_next_window, text="Next", activebackground='#6162FF', activeforeground="white", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_next_2)
  377.         admin_add_next_btn.place(x=1125, y=685)
  378.         admin_add_next_btn.bind("<Enter>", lambda e: admin_add_next_btn.config(fg='white', bg='#8080ff'))
  379.         admin_add_next_btn.bind("<Leave>", lambda e: admin_add_next_btn.config(fg='white', bg='#6162FF'))
  380.  
  381.         admin_add_back_btn = Button(admin_add_next_window, text="Back", activebackground='#6162FF', activeforeground="white", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_next_back)
  382.         admin_add_back_btn.place(x=977, y=685) 
  383.         admin_add_back_btn.bind("<Enter>", lambda e: admin_add_back_btn.config(fg='white', bg='#8080ff'))
  384.         admin_add_back_btn.bind("<Leave>", lambda e: admin_add_back_btn.config(fg='white', bg='#6162FF'))
  385.  
  386.         admin_add_clear_btn = Button(admin_add_next_window, text="Clear", activebackground='#6162FF', activeforeground="white", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_next_clear)
  387.         admin_add_clear_btn.place(x=830, y=685)
  388.         admin_add_clear_btn.bind("<Enter>", lambda e: admin_add_clear_btn.config(fg='white', bg='#8080ff'))
  389.         admin_add_clear_btn.bind("<Leave>", lambda e: admin_add_clear_btn.config(fg='white', bg='#6162FF'))
  390.  
  391.         admin_exit_btn = Button(admin_add_next_window, text="Exit", activebackground='red', activeforeground="white", bg="red", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_exit)
  392.         admin_exit_btn.place(x=682, y=685)
  393.         admin_exit_btn.bind("<Enter>", lambda e: admin_exit_btn.config(fg='white', bg='#ff6464'))
  394.         admin_exit_btn.bind("<Leave>", lambda e: admin_exit_btn.config(fg='white', bg='red'))
  395.  
  396.         admin_add_next_window.deiconify()
  397.         admin_add_next_window.mainloop()
  398.  
  399.     option1 = StringVar()
  400.     option2 = StringVar()
  401.     option3 = StringVar()
  402.  
  403.     admin_window_canvas.create_text(256, 40, text="Issue/Machine Details", font=("Impact", 35, "bold"), fill="#6162FF")
  404.     admin_window_canvas.create_text(120, 95, text="Enter Issue Details ", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  405.     admin_window_canvas.create_text(69, 140, text="Ref. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  406.     admin_window_canvas.create_text(113, 138, text="*", font=("Goudy old style", 15, "bold"), fill="red")
  407.     admin_window_canvas.create_text(438, 140, text="Issue Reported on", font=("Goudy old style", 15, "bold"), fill="grey")
  408.     admin_window_canvas.create_text(535, 138, text="*", font=("Goudy old style", 15, "bold"), fill="red")
  409.     admin_window_canvas.create_text(103, 225, text="Issue Reported", font=("Goudy old style", 15, "bold"), fill="grey")
  410.     admin_window_canvas.create_text(430, 225, text="Issue Diagnosed", font=("Goudy old style", 15, "bold"), fill="grey")
  411.     admin_window_canvas.create_text(63, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  412.     admin_window_canvas.create_text(384, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  413.     admin_window_canvas.create_text(205, 563, text="Issue Logged By (Engineers's Name)", font=("Goudy old style", 15, "bold"), fill="grey")
  414.     admin_window_canvas.create_text(388, 561, text="*", font=("Goudy old style", 15, "bold"), fill="red")
  415.     admin_window_canvas.create_text(752, 95, text="Machine Details", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  416.     admin_window_canvas.create_text(747, 140, text="Machine Type", font=("Goudy old style", 15, "bold"), fill="grey")
  417.     admin_window_canvas.create_text(752, 225, text="Machine Model", font=("Goudy old style", 15, "bold"), fill="grey")
  418.     admin_window_canvas.create_text(1061, 225, text="Machine Sr. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  419.     admin_window_canvas.create_text(820, 315, text="Machine Details & Accesories", font=("Goudy old style", 15, "bold"), fill="grey")
  420.     admin_window_canvas.create_text(790, 563, text="Machine Brought In By", font=("Goudy old style", 15, "bold"), fill="grey") 
  421.  
  422.     ent_ref_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  423.     ent_ref_no.place(x=30, y=160, width=275, height=35)
  424.  
  425.     con = None 
  426.     try:
  427.         con = connect("customer_data.db")
  428.         cursor = con.cursor()
  429.         cursor.execute("""CREATE TABLE if not exists customers (
  430.             ref_no int primary key,
  431.             issue_reported_date text,
  432.             issue_reported text,
  433.             issue_reported_details text,
  434.             issue_diagnosed text,
  435.             issue_diagnosed_details text,
  436.             issue_logged_by text,
  437.             machine_type text,
  438.             machine_model text,
  439.             machine_sr_no text,
  440.             machine_details text,
  441.             machine_brought_in_by text,
  442.             f_name text,
  443.             l_name text,
  444.             email text,
  445.             second_email text,
  446.             mob_no int,
  447.             alter_mob_no int,
  448.             company_name text,
  449.             company_loc text,
  450.             customer_of text,
  451.             address text,
  452.             landmark text,
  453.             city text,
  454.             state text,
  455.             country text,
  456.             pincode text)
  457.             """)
  458.         sql = ("select ref_no from customers")
  459.         cursor.execute(sql)
  460.         data = cursor.fetchall()
  461.        
  462.         if len(data) != 0:
  463.             count = len(data) +1
  464.         else:
  465.             count = 1
  466.  
  467.     except Exception as e:
  468.         con.rollback()
  469.         showerror("Error", str(e))
  470.     finally:
  471.         if con is not None:
  472.             con.close()
  473.  
  474.     ent_ref_no.insert(END, count)
  475.  
  476.     ent_date = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  477.     ent_date.insert(END, date_live)
  478.     ent_date.place(x=350, y=160, width=275, height=35)
  479.  
  480.     f=("Goudy old style", 15)
  481.    
  482.     style = ttk.Style()
  483.     style.configure('combo_issue_reported.TCombobox', selectbackground='blue', arrowsize=15)
  484.  
  485.     combo_issue_reported = ttk.Combobox(admin_window, textvariable=option1, style='combo_issue_reported.TCombobox', font=("Goudy old style", 15))
  486.     combo_issue_reported["values"] = ['Video Display Issue', 'Power & Startup', 'Operating System Errors & Blue Screen', 'Hard Drive Related', 'Keyboard Mouse & Accessories', 'Internet Connectivity Issues', 'Battery & Adapter', 'Audio & Speakers', 'USB Port Issues', 'Bluetooth & Wifi', 'Software & 3rd Party Applications', 'System Hardware Performance', 'Status Updates', 'Other Issues']
  487.     combo_issue_reported.option_add("*TCombobox*Listbox*Font", f)
  488.     combo_issue_reported.place(x=30, y=245, width=276, height=35)
  489.     combo_issue_reported.set("")
  490.  
  491.     scr_issue_reported = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  492.     scr_issue_reported.place(x=30, y=335)
  493.  
  494.     style.configure('combo_issue_diagnosed.TCombobox', selectbackground='blue', arrowsize=15)
  495.  
  496.     combo_issue_diagnosed = ttk.Combobox(admin_window, textvariable=option2, style='combo_issue_diagnosed.TCombobox', font=("Goudy old style", 15))
  497.     combo_issue_diagnosed["values"] = ['Video Display Issue', 'Power & Startup', 'Operating System Errors & Blue Screen', 'Hard Drive Related', 'Keyboard, Mouse & Accessories', 'Internet Connectivity Issues', 'Battery & Adapter', 'Audio & Speakers', 'USB Port Issues', 'Bluetooth & Wifi', 'Software & 3rd Party Applications', 'System Hardware Performance', 'Status Updates', 'Other Issues']
  498.     combo_issue_diagnosed.option_add("*TCombobox*Listbox*Font", f)
  499.     combo_issue_diagnosed.place(x=350, y=245, width=276, height=35)
  500.     combo_issue_diagnosed.set("")
  501.  
  502.     scr_issue_diagnosed = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  503.     scr_issue_diagnosed.place(x=350, y=335)
  504.  
  505.     ent_issue_logged_by = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  506.     ent_issue_logged_by.place(x=30, y=586, width=600, height=35)
  507.  
  508.     style.configure('combo_machine_type.TCombobox', selectbackground='blue', arrowsize=15)
  509.  
  510.     combo_machine_type = ttk.Combobox(admin_window, textvariable=option3, style='combo_machine_type.TCombobox', font=("Goudy old style", 15))
  511.     combo_machine_type["values"] = ['Desktop', 'Laptop', 'All-In-One', 'Tablet', 'Server', 'Switch', 'Router', 'NAS', 'UPS', 'External HDD', 'Modem', 'Printer', 'Scanner', 'Projector', 'Speakers', 'Headphones', 'Mouse', 'Keyboard', 'Others']
  512.     combo_machine_type.option_add("*TCombobox*Listbox*Font", f)
  513.     combo_machine_type.place(x=680, y=160, width=270, height=35)
  514.     combo_machine_type.set("")
  515.  
  516.     ent_machine_model = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  517.     ent_machine_model.place(x=680, y=245, width=270, height=35)
  518.  
  519.     ent_machine_sr_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  520.     ent_machine_sr_no.place(x=985, y=245, width=266, height=35)
  521.  
  522.     scr_machine_details = ScrolledText(admin_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  523.     scr_machine_details.place(x=680, y=335)
  524.  
  525.     ent_machine_brought_in_by = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  526.     ent_machine_brought_in_by.place(x=680, y=586, width=572, height=35)    
  527.                
  528.     admin_next_btn = Button(admin_window, text="Next", activebackground='#6162FF', activeforeground="white", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_next)
  529.     admin_next_btn.place(x=1125, y=685)
  530.     admin_next_btn.bind("<Enter>", lambda e: admin_next_btn.config(fg='white', bg='#8080ff'))
  531.     admin_next_btn.bind("<Leave>", lambda e: admin_next_btn.config(fg='white', bg='#6162FF'))
  532.  
  533.     admin_clear_btn = Button(admin_window, text="Clear", activebackground='#6162FF', activeforeground="white", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_clear)
  534.     admin_clear_btn.place(x=977, y=685)
  535.     admin_clear_btn.bind("<Enter>", lambda e: admin_clear_btn.config(fg='white', bg='#8080ff'))
  536.     admin_clear_btn.bind("<Leave>", lambda e: admin_clear_btn.config(fg='white', bg='#6162FF'))
  537.  
  538.     admin_exit_btn = Button(admin_window, text="Exit", activebackground='red', activeforeground="white", bg="red", fg="white", width=8, bd=1, font=("Arial", 17, "bold"), command=admin_add_exit)
  539.     admin_exit_btn.place(x=830, y=685)
  540.     admin_exit_btn.bind("<Enter>", lambda e: admin_exit_btn.config(fg='white', bg='#ff6464'))
  541.     admin_exit_btn.bind("<Leave>", lambda e: admin_exit_btn.config(fg='white', bg='red'))
  542.    
  543.     admin_window.deiconify()
  544.     admin_window.mainloop()
  545.  
  546. login_window = Tk()
  547. login_window.withdraw()
  548. general_window_setup((500, 500), login_window, "Login Page", "download.ico")
  549.  
  550. bg_image = ImageTk.PhotoImage(file="login_home_pg_bg_img.jpg")
  551.  
  552. login_window_canvas = Canvas(login_window, width=500, height=500, bd=0, highlightthickness=0)
  553. login_window_canvas.pack(fill="both", expand=True)
  554. login_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  555.  
  556. login_window_canvas.create_text(144, 80, text="Login", font=("Impact", 35, "bold"), fill="#6162FF")
  557. login_window_canvas.create_text(191, 130, text="Employee Login Area", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  558. login_window_canvas.create_text(138, 173, text="Username", font=("Goudy old style", 15, "bold"), fill="grey")
  559. login_window_canvas.create_text(138, 244, text="Password", font=("Goudy old style", 15, "bold"), fill="grey")
  560.  
  561. ent_username = Entry(login_window, font=("Goudy old style", 15), bg="white", fg="black")
  562. ent_username.focus()
  563. ent_username.place(x=90, y=190, width=320, height=35)
  564.  
  565. ent_password = Entry(login_window, font=("Goudy old style", 15), bg="white", fg="black", show="*")
  566. ent_password.place(x=90, y=260, width=320, height=35)
  567.  
  568. #btn_forgot_pass = Button(login_window, text="forgot password?", font=("Goudy old style", 12), bd=0, fg="#6162FF")
  569. #btn_forgot_pass.place(x=90, y=280)
  570.  
  571. btn_login = Button(login_window, text="Login", activebackground='#6162FF', activeforeground="white", font=("Goudy old style", 15, "bold"), bd=1, bg="#6162FF", fg="white", command=check_login_cred)
  572. btn_login.place(x=90, y=320, width=180, height=40)
  573. btn_login.bind("<Enter>", lambda e: btn_login.config(fg='white', bg='#8080ff'))
  574. btn_login.bind("<Leave>", lambda e: btn_login.config(fg='white', bg='#6162FF'))
  575.  
  576. login_window.deiconify()
  577. login_window.mainloop()
Add Comment
Please, Sign In to add comment