Advertisement
danyalbasar

test

Sep 6th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 55.89 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. import geocoder
  10. import requests
  11.  
  12. date_live, time_live = "", ""
  13. admin_main_window, user_main_window = "", ""
  14.  
  15. def general_window_setup(size, window, title, icon):
  16.     window.title(title)
  17.     window.iconbitmap(icon)
  18.  
  19.     window_width = size[0]
  20.     window_height = size[1]
  21.     window_x = int((window.winfo_screenwidth() / 2) - (window_width / 2))
  22.     window_y = int((window.winfo_screenheight() / 2) - (window_height / 2))
  23.  
  24.     window_geometry = str(window_width) + 'x' + str(window_height) + '+' + str(window_x) + '+' + str(window_y)
  25.     window.geometry(window_geometry)
  26.  
  27.     window.resizable(False, False)
  28.  
  29.     return
  30.  
  31. def check_login_cred():
  32.     if ent_username.get() == "" or ent_password.get() == "":
  33.         #messagebox.showerror("Error", "All fields are required")
  34.         #messagebox.showinfo("Success", f"Welcome {ent_username.get()}")
  35.         ent_username.delete(0, END)
  36.         ent_password.delete(0, END)
  37.         admin_home_pg()
  38.     '''elif ent_username.get() == "admin":
  39.         if ent_password.get() == "admin@123":
  40.             messagebox.showinfo("Success", f"Welcome {ent_username.get()}")
  41.             ent_username.delete(0, END)
  42.             ent_password.delete(0, END)
  43.             admin_home_pg()
  44.         else:
  45.             messagebox.showerror("Error", "Invalid Password")
  46.             ent_password.delete(0, END)
  47.             ent_password.focus()
  48.     elif ent_username.get() == "user":
  49.         if ent_password.get() == "user@123":   
  50.             messagebox.showinfo("Success", f"Welcome {ent_username.get()}")
  51.             ent_username.delete(0, END)
  52.             ent_password.delete(0, END)
  53.             user_home_pg()
  54.         else:
  55.             messagebox.showerror("Error", "Invalid Password")
  56.             ent_password.delete(0, END)
  57.             ent_password.focus()
  58.     elif ent_username.get() != "admin" or ent_password.get() != "admin@123" or ent_username.get() != "user" or ent_password.get() != "user@123":
  59.         messagebox.showerror("Error", "Invalid Username & password")
  60.     else:
  61.         ent_username.delete(0, END)
  62.         ent_password.delete(0, END)
  63.         ent_username.focus()'''
  64.  
  65. # ---------------------------------------------------------------------------------------------------- Temperature -----------------------------------------------------------------------------------------------------------
  66. def tmp():
  67.     try:
  68.         api_key = "6aec4029e4a643f15b82009ac24ae555"
  69.         base_url = "http://api.openweathermap.org/data/2.5/weather?q="
  70.         city_name = "Mumbai"
  71.  
  72.         complete_url = base_url + city_name + "&appid=" + api_key + "&units=metric"
  73.  
  74.         res = requests.get(complete_url)
  75.         data = res.json()
  76.  
  77.         tmp = str(data['main']['temp']) + "°C"
  78.  
  79.     except Exception as e:
  80.         tmp = "Error"
  81.  
  82.     return tmp
  83.  
  84. # ------------------------------------------------------------------------------------------------------ Location -------------------------------------------------------------------------------------------------------------
  85. def location_live():
  86.     try:
  87.         loc = geocoder.ip('me')
  88.  
  89.         loc_city = loc.city
  90.         loc_state = loc.state
  91.         loc_country = loc.country
  92.        
  93.         location_live = loc_city + ", " + loc_state + ", " + loc_country
  94.  
  95.     except Exception as e:
  96.         location_live = "Error"
  97.  
  98.     return location_live
  99.  
  100. # --------------------------------------------------------------------------------------------------------- Date ----------------------------------------------------------------------------------------------------------------
  101. def date_live():
  102.     try:
  103.         global date_live
  104.         datetime_live = datetime.datetime.now()
  105.  
  106.         date_live = datetime_live.strftime('%d-%m-%Y')
  107.  
  108.     except Exception as e:
  109.         date_live = "Error"
  110.  
  111.     return date_live
  112.  
  113. # ---------------------------------------------------------------------------------------------------------- Time ----------------------------------------------------------------------------------------------------------------
  114. def time_live():
  115.     try:
  116.         global time_live
  117.         datetime_live = datetime.datetime.now()
  118.  
  119.         time_live = datetime_live.strftime('%H:%M:%S')
  120.  
  121.     except Exception as e:
  122.         time_live = "Error"
  123.  
  124.     return time_live
  125.  
  126. # ------------------------------------------------------------------------------------------------------ Admin Page -------------------------------------------------------------------------------------------------------------
  127. def admin_home_pg():
  128.     global admin_main_window
  129.     login_window.withdraw()
  130.  
  131.     admin_main_window = Toplevel(login_window)
  132.     admin_main_window.withdraw()
  133.     general_window_setup((500, 530), admin_main_window, "Admin Homepage", "download.ico")
  134.  
  135.     bg_image = ImageTk.PhotoImage(file="home_pg_bg_img.jpg")
  136.  
  137.     admin_main_window_canvas = Canvas(admin_main_window, width=500, height=530, bd=0, highlightthickness=0)
  138.     admin_main_window_canvas.pack(fill="both", expand=True)
  139.     admin_main_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  140.  
  141.     def admin_home_pg_sign_out():
  142.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to sign out?', icon='warning')
  143.         #if res == 'yes':
  144.         login_window.deiconify()
  145.         admin_main_window.destroy()
  146.  
  147.     f = ("Arial", 18, "bold")
  148.  
  149.     admin_main_window_canvas.create_text(100, 485, text=location_live(), font=("Goudy old style", 12, "bold"), fill="#1d1d1d")
  150.     admin_main_window_canvas.create_text(455, 485, text=time_live(), font=("Goudy old style", 12, "bold"), fill="#1d1d1d")
  151.     admin_main_window_canvas.create_text(450, 510, text=date_live(), font=("Goudy old style", 12, "bold"), fill="#1d1d1d")
  152.     admin_main_window_canvas.create_text(37, 510, text=tmp(), font=("Goudy old style", 12, "bold"), fill="#1d1d1d")
  153.  
  154.     mw_btn_add = Button(admin_main_window, text="Add", bd=1, font=f, width=12, bg="#6162FF", fg="white", command=admin_home_pg_add)
  155.     mw_btn_add.place(x=154, y=20)
  156.     mw_btn_update = Button(admin_main_window, text="Update", bd=1, font=f, bg="#6162FF", fg="white", width=12, command=admin_home_pg_update)
  157.     mw_btn_update.place(x=154, y=90)
  158.     mw_btn_delete = Button(admin_main_window, text="Delete", bd=1, font=f, bg="#6162FF", fg="white", width=12, command=admin_home_pg_delete)
  159.     mw_btn_delete.place(x=154, y=160)
  160.     mw_btn_view = Button(admin_main_window, text="View", bd=1, font=f, bg="#6162FF", fg="white", width=12, command=admin_home_pg_view)
  161.     mw_btn_view.place(x=154, y=230)
  162.     mw_btn_sign_out = Button(admin_main_window, text="Sign Out", bd=1, font=f, width=12, bg="red", fg="white", command=admin_home_pg_sign_out)
  163.     mw_btn_sign_out.place(x=154, y=300)
  164.  
  165.     admin_main_window.deiconify()
  166.     admin_main_window.mainloop()
  167.  
  168. def admin_home_pg_add():
  169.     global admin_main_window
  170.     admin_main_window.withdraw()
  171.  
  172.     admin_window =Toplevel(admin_main_window)
  173.     admin_window.withdraw()
  174.     general_window_setup((1280, 768), admin_window, "Admin Add Page", "download.ico")
  175.  
  176.     bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  177.  
  178.     admin_window_canvas = Canvas(admin_window, width=1280, height=768, bd=0, highlightthickness=0)
  179.     admin_window_canvas.pack(fill="both", expand=True)
  180.     admin_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  181.  
  182.     def admin_add_exit():  
  183.         res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  184.         if res == 'yes':
  185.             #admin_main_window.deiconify()
  186.             admin_window.destroy()
  187.             admin_main_window.destroy()
  188.             login_window.destroy()
  189.  
  190.     def admin_add_clear():
  191.         ent_ref_no.delete(0, END)
  192.         ent_date.delete(0, END)
  193.         combo_issue_reported.delete(0, END)
  194.         scr_issue_reported.delete(1.0, END)
  195.         combo_issue_diagnosed.delete(0, END)
  196.         scr_issue_diagnosed.delete(1.0, END)
  197.         ent_issue_logged_by.delete(0, END)
  198.         combo_machine_type.delete(0, END)
  199.         ent_machine_model.delete(0, END)
  200.         ent_machine_sr_no.delete(0, END)
  201.         scr_machine_details.delete(1.0, END)
  202.  
  203.     def admin_add_next():
  204.         admin_window.withdraw()
  205.  
  206.         admin_add_next_window =Toplevel(admin_window)
  207.         admin_add_next_window.withdraw()
  208.         general_window_setup((1280, 768), admin_add_next_window, "Admin Add Page", "download.ico")
  209.  
  210.         bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  211.  
  212.         admin_add_next_window_canvas = Canvas(admin_add_next_window, width=1280, height=768, bd=0, highlightthickness=0)
  213.         admin_add_next_window_canvas.pack(fill="both", expand=True)
  214.         admin_add_next_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  215.  
  216.         def admin_add_next_back():
  217.             admin_window.deiconify()
  218.             admin_add_next_window.withdraw()
  219.  
  220.         def admin_add_next_clear():
  221.             ent_first_name.delete(0, END)
  222.             ent_last_name.delete(0, END)
  223.             ent_email_1.delete(0, END)
  224.             ent_email_2.delete(0, END)
  225.             ent_mobile_no_1.delete(0, END)
  226.             ent_mobile_no_2.delete(0, END)
  227.             ent_co_name.delete(0, END)
  228.             ent_co_loc.delete(0, END)
  229.             ent_customer_of.delete(0, END)
  230.             ent_address.delete(1.0, END)
  231.             ent_city.delete(0, END)
  232.             combo_state.delete(0, END)
  233.             ent_pincode.delete(0, END)
  234.  
  235.         def admin_add_next_2():
  236.             con = None
  237.             try:
  238.                 con = connect("customer_data.db")
  239.                 cursor = con.cursor()
  240.                 cursor.execute("""CREATE TABLE if not exists customers (
  241.                     ref_no int primary key,
  242.                     issue_reported_date text,
  243.                     issue_reported text,
  244.                     issue_reported_details text,
  245.                     issue_diagnosed text,
  246.                     issue_diagnosed_details text,
  247.                     issue_logged_by text,
  248.                     machine_type text,
  249.                     machine_model text,
  250.                     machine_sr_no text,
  251.                     machine_details text,
  252.                     f_name text,
  253.                     l_name text,
  254.                     email text,
  255.                     second_email text,
  256.                     mob_no int,
  257.                     alter_mob_no int,
  258.                     company_name text,
  259.                     company_loc text,
  260.                     customer_of text,
  261.                     address text,
  262.                     city text,
  263.                     state text,
  264.                     country text,
  265.                     pincode text)
  266.                     """)
  267.                 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')"
  268.  
  269.                 ref_no = ent_ref_no.get()
  270.                 issue_reported_date = ent_date.get()
  271.                 issue_reported = combo_issue_reported.get()
  272.                 issue_reported_details = scr_issue_reported.get("1.0",'end-1c')
  273.                 issue_diagnosed = combo_issue_diagnosed.get()
  274.                 issue_diagnosed_details = scr_issue_diagnosed.get("1.0",'end-1c')
  275.                 issue_logged_by = ent_issue_logged_by.get()
  276.                 machine_type = combo_machine_type.get()
  277.                 machine_model =ent_machine_model.get()
  278.                 machine_sr_no = ent_machine_sr_no.get()
  279.                 machine_details = scr_machine_details.get("1.0",'end-1c')
  280.                 f_name = ent_first_name.get()
  281.                 l_name = ent_last_name.get()
  282.                 email = ent_email_1.get()
  283.                 second_email = ent_email_2.get()
  284.                 mob_no = ent_mobile_no_1.get()
  285.                 alter_mob_no = ent_mobile_no_2.get()
  286.                 company_name = ent_co_name.get()
  287.                 company_loc = ent_co_loc.get()
  288.                 customer_of = ent_customer_of.get()
  289.                 address = ent_address.get("1.0",'end-1c')
  290.                 city = ent_city.get()
  291.                 state = combo_state.get()
  292.                 country = ent_country.get()
  293.                 pincode = ent_pincode.get()
  294.    
  295.                 if len(f_name) == 0:
  296.                     showerror("First Name Issue", "Name cannot be empty")
  297.                     ent_first_name.delete(0, END)
  298.                     ent_first_name.focus()
  299.                     return
  300.                 if (not f_name.isalpha()):
  301.                     showerror("First Name Issue", "Name cannot be a number")
  302.                     ent_first_name.delete(0, END)
  303.                     ent_first_name.focus()
  304.                     return
  305.                 if (len(f_name) < 2):
  306.                     showerror("First Name Issue", "Name cannot be less than two letters")
  307.                     ent_first_name.delete(0, END)
  308.                     ent_first_name.focus()
  309.                     return
  310.                 if (not l_name.isalpha()) and (len(l_name) != 0):
  311.                     showerror("Last Name Issue", "Name cannot be a number")
  312.                     ent_last_name.delete(0, END)
  313.                     ent_last_name.focus()
  314.                     return
  315.                 if (len(l_name) < 2) and (len(l_name) != 0):
  316.                     showerror("Last Name Issue", "Name cannot be less than two letters")
  317.                     ent_last_name.delete(0, END)
  318.                     ent_last_name.focus()
  319.                     return
  320.                 if len(mob_no) == 0:
  321.                     showerror("Mobile No Issue", "Mobile No cannot be empty")
  322.                     ent_mobile_no_1.delete(0, END)
  323.                     ent_mobile_no_1.focus()
  324.                     return
  325.                 if (not mob_no.isdigit()):
  326.                     showerror("Mobile No Issue", "Mobile No should be in digits only")     
  327.                     ent_mobile_no_1.delete(0, END)
  328.                     ent_mobile_no_1.focus()
  329.                     return
  330.                 if (len(mob_no) < 10):
  331.                     showerror("Mobile No Issue", "Mobile No cannot be less than 10 digits")
  332.                     ent_mobile_no_1.delete(0, END)
  333.                     ent_mobile_no_1.focus()
  334.                     return
  335.                 if (len(mob_no) > 10):
  336.                     showerror("Mobile No Issue", "Mobile No cannot be more than 10 digits")
  337.                     ent_mobile_no_1.delete(0, END)
  338.                     ent_mobile_no_1.focus()
  339.                     return
  340.                 if (not alter_mob_no.isdigit()) and (len(alter_mob_no) != 0):
  341.                     showerror("Alternate Mobile No Issue", "Mobile No should be in digits only")       
  342.                     ent_mobile_no_2.delete(0, END)
  343.                     ent_mobile_no_2.focus()
  344.                     return
  345.                 if (len(alter_mob_no) < 10) and (len(alter_mob_no) != 0):
  346.                     showerror("Alternate Mobile No Issue", "Mobile No cannot be less than 10 digits")
  347.                     ent_mobile_no_2.delete(0, END)
  348.                     ent_mobile_no_2.focus()
  349.                     return
  350.                 if (len(alter_mob_no) > 10):
  351.                     showerror("Alternate Mobile No Issue", "Mobile No cannot be more than 10 digits")
  352.                     ent_mobile_no_2.delete(0, END)
  353.                     ent_mobile_no_2.focus()
  354.                     return
  355.  
  356.                 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, f_name, l_name, email, second_email, mob_no, alter_mob_no, company_name, company_loc, customer_of, address, city, state, country, pincode))
  357.                 con.commit()
  358.                 showinfo("Success","Record added successfully")
  359.  
  360.             except Exception as e:
  361.                 con.rollback()
  362.                 showerror("Error", str(e))
  363.  
  364.             finally:
  365.                 if con is not None:
  366.                     con.close()
  367.  
  368.         option = StringVar()
  369.    
  370.         admin_add_next_window_canvas.create_text(180, 40, text="Contact Details", font=("Impact", 35, "bold"), fill="#6162FF")
  371.         admin_add_next_window_canvas.create_text(152, 95, text="Enter Contact Information", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  372.         admin_add_next_window_canvas.create_text(82, 140, text="First Name", font=("Goudy old style", 15, "bold"), fill="grey")
  373.         admin_add_next_window_canvas.create_text(401, 140, text="Last Name", font=("Goudy old style", 15, "bold"), fill="grey")
  374.         admin_add_next_window_canvas.create_text(55, 225, text="Email", font=("Goudy old style", 15, "bold"), fill="grey")
  375.         admin_add_next_window_canvas.create_text(430, 225, text="Secondary Email", font=("Goudy old style", 15, "bold"), fill="grey")
  376.         admin_add_next_window_canvas.create_text(81, 310, text="Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  377.         admin_add_next_window_canvas.create_text(447, 310, text="Alternate Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  378.         admin_add_next_window_canvas.create_text(104, 395, text="Company Name", font=("Goudy old style", 15, "bold"), fill="grey")
  379.         admin_add_next_window_canvas.create_text(118, 480, text="Company Location", font=("Goudy old style", 15, "bold"), fill="grey")
  380.         admin_add_next_window_canvas.create_text(91, 565, text="Customer Of", font=("Goudy old style", 15, "bold"), fill="grey")
  381.         admin_add_next_window_canvas.create_text(820, 95, text="Address for Machine Location", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  382.         admin_add_next_window_canvas.create_text(720, 140, text="Address", font=("Goudy old style", 15, "bold"), fill="grey")
  383.         admin_add_next_window_canvas.create_text(700, 395, text="City", font=("Goudy old style", 15, "bold"), fill="grey")
  384.         admin_add_next_window_canvas.create_text(1015, 395, text="State", font=("Goudy old style", 15, "bold"), fill="grey")
  385.         admin_add_next_window_canvas.create_text(719, 480, text="Country", font=("Goudy old style", 15, "bold"), fill="grey")
  386.         admin_add_next_window_canvas.create_text(1029, 480, text="Pincode", font=("Goudy old style", 15, "bold"), fill="grey")
  387.  
  388.         ent_first_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  389.         ent_first_name.place(x=30, y=160, width=275, height=35)
  390.  
  391.         ent_last_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  392.         ent_last_name.place(x=350, y=160, width=275, height=35)
  393.  
  394.         ent_email_1 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  395.         ent_email_1.place(x=30, y=245, width=275, height=35)
  396.  
  397.         ent_email_2 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  398.         ent_email_2.place(x=350, y=245, width=275, height=35)
  399.  
  400.         ent_mobile_no_1 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  401.         ent_mobile_no_1.place(x=30, y=330, width=275, height=35)
  402.  
  403.         ent_mobile_no_2 = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  404.         ent_mobile_no_2.place(x=350, y=330, width=275, height=35)
  405.    
  406.         ent_co_name = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  407.         ent_co_name.place(x=30, y=415, width=600, height=35)
  408.  
  409.         ent_co_loc = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  410.         ent_co_loc.place(x=30, y=500, width=600, height=35)
  411.  
  412.         ent_customer_of = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  413.         ent_customer_of.place(x=30, y=587, width=600, height=35)
  414.  
  415.         ent_address = ScrolledText(admin_add_next_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  416.         ent_address.place(x=680, y=160)
  417.  
  418.         ent_city = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  419.         ent_city.place(x=680, y=415, width=275, height=35)
  420.  
  421.         f=("Goudy old style", 15)
  422.  
  423.         style = ttk.Style()
  424.         style.configure('combo_state.TCombobox', selectbackground='blue', arrowsize=15)
  425.  
  426.         combo_state = ttk.Combobox(admin_add_next_window, textvariable=option, style='combo_state.TCombobox', font=("Goudy old style", 15))
  427.         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']
  428.         combo_state.option_add("*TCombobox*Listbox*Font", f)
  429.         combo_state.place(x=990, y=415, width=260, height=35)
  430.         combo_state.set("")
  431.  
  432.         ent_country = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  433.         ent_country.insert(END, 'India')
  434.         ent_country.bind("<Key>", lambda a: "break")
  435.         ent_country.place(x=680, y=500, width=275, height=35)
  436.  
  437.         ent_pincode = Entry(admin_add_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  438.         ent_pincode.place(x=990, y=500, width=260, height=35)
  439.  
  440.         admin_add_next_btn = Button(admin_add_next_window, text="Next", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_next_2)
  441.         admin_add_next_btn.place(x=1125, y=685)
  442.         admin_add_back_btn = Button(admin_add_next_window, text="Back", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_next_back)
  443.         admin_add_back_btn.place(x=977, y=685)
  444.         admin_add_clear_btn = Button(admin_add_next_window, text="Clear", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_next_clear)
  445.         admin_add_clear_btn.place(x=830, y=685)
  446.         admin_exit_btn = Button(admin_add_next_window, text="Exit", bg="red", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_exit)
  447.         admin_exit_btn.place(x=682, y=685)
  448.    
  449.         admin_add_next_window.deiconify()
  450.         admin_add_next_window.mainloop()
  451.  
  452.     option1 = StringVar()
  453.     option2 = StringVar()
  454.     option3 = StringVar()
  455.  
  456.     admin_window_canvas.create_text(256, 40, text="Issue/Machine Details", font=("Impact", 35, "bold"), fill="#6162FF")
  457.     admin_window_canvas.create_text(120, 95, text="Enter Issue Details ", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  458.     admin_window_canvas.create_text(69, 140, text="Ref. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  459.     admin_window_canvas.create_text(438, 140, text="Issue Reported on", font=("Goudy old style", 15, "bold"), fill="grey")
  460.     admin_window_canvas.create_text(103, 225, text="Issue Reported", font=("Goudy old style", 15, "bold"), fill="grey")
  461.     admin_window_canvas.create_text(430, 225, text="Issue Diagnosed", font=("Goudy old style", 15, "bold"), fill="grey")
  462.     admin_window_canvas.create_text(63, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  463.     admin_window_canvas.create_text(384, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  464.     admin_window_canvas.create_text(205, 565, text="Issue Logged By (Engineers's Name)", font=("Goudy old style", 15, "bold"), fill="grey")
  465.     admin_window_canvas.create_text(752, 95, text="Machine Details", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  466.     admin_window_canvas.create_text(747, 140, text="Machine Type", font=("Goudy old style", 15, "bold"), fill="grey")
  467.     admin_window_canvas.create_text(752, 225, text="Machine Model", font=("Goudy old style", 15, "bold"), fill="grey")
  468.     admin_window_canvas.create_text(1061, 225, text="Machine Sr. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  469.     admin_window_canvas.create_text(820, 315, text="Machine Details & Accesories", font=("Goudy old style", 15, "bold"), fill="grey")  
  470.  
  471.     ent_ref_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  472.     ent_ref_no.place(x=30, y=160, width=275, height=35)
  473.  
  474.     con = None 
  475.     try:
  476.         con = connect("customer_data.db")
  477.         cursor = con.cursor()
  478.  
  479.         sql = ("select ref_no from customers")
  480.         cursor.execute(sql)
  481.         data = cursor.fetchall()
  482.         if len(data) != 0:
  483.             count = len(data) +1
  484.         else:
  485.             count = 1
  486.     except Exception as e:
  487.         con.rollback()
  488.         showerror("Error", str(e))
  489.     finally:
  490.         if con is not None:
  491.             con.close()
  492.  
  493.     ent_ref_no.insert(END, count)
  494.  
  495.     ent_date = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  496.     ent_date.insert(END, date_live)
  497.     ent_date.bind("<Key>", lambda a: "break")
  498.     ent_date.place(x=350, y=160, width=275, height=35)
  499.  
  500.     f=("Goudy old style", 15)
  501.  
  502.     style = ttk.Style()
  503.  
  504.     style.configure('combo_issue_reported.TCombobox', selectbackground='blue', arrowsize=15)
  505.  
  506.     combo_issue_reported = ttk.Combobox(admin_window, textvariable=option1, style='combo_issue_reported.TCombobox', font=("Goudy old style", 15))
  507.     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']
  508.     combo_issue_reported.option_add("*TCombobox*Listbox*Font", f)
  509.     combo_issue_reported.place(x=30, y=245, width=276, height=35)
  510.     combo_issue_reported.set("")
  511.  
  512.     scr_issue_reported = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  513.     scr_issue_reported.place(x=30, y=335)
  514.  
  515.     style.configure('combo_issue_diagnosed.TCombobox', selectbackground='blue', arrowsize=15)
  516.  
  517.     combo_issue_diagnosed = ttk.Combobox(admin_window, textvariable=option2, style='combo_issue_diagnosed.TCombobox', font=("Goudy old style", 15))
  518.     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']
  519.     combo_issue_diagnosed.option_add("*TCombobox*Listbox*Font", f)
  520.     combo_issue_diagnosed.place(x=350, y=245, width=276, height=35)
  521.     combo_issue_diagnosed.set("")
  522.  
  523.     scr_issue_diagnosed = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  524.     scr_issue_diagnosed.place(x=350, y=335)
  525.  
  526.     ent_issue_logged_by = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  527.     ent_issue_logged_by.place(x=30, y=588, width=600, height=35)
  528.  
  529.     style.configure('combo_machine_type.TCombobox', selectbackground='blue', arrowsize=15)
  530.  
  531.     combo_machine_type = ttk.Combobox(admin_window, textvariable=option3, style='combo_machine_type.TCombobox', font=("Goudy old style", 15))
  532.     combo_machine_type["values"] = ['Desktop', 'Laptop', 'All-In-One', 'Server', 'Switch', 'Router', 'UPS', 'External HDD', 'Modem', 'Printer', 'Scanner', 'Projector', 'Speakers', 'Headphones', 'Mouse', 'Keyboard', 'Others']
  533.     combo_machine_type.option_add("*TCombobox*Listbox*Font", f)
  534.     combo_machine_type.place(x=680, y=160, width=270, height=35)
  535.     combo_machine_type.set("")
  536.  
  537.     ent_machine_model = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  538.     ent_machine_model.place(x=680, y=245, width=270, height=35)
  539.  
  540.     ent_machine_sr_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  541.     ent_machine_sr_no.place(x=985, y=245, width=270, height=35)
  542.  
  543.     scr_machine_details = ScrolledText(admin_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  544.     scr_machine_details.place(x=680, y=335)
  545.                
  546.     admin_next_btn = Button(admin_window, text="Next", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_next)
  547.     admin_next_btn.place(x=1125, y=685)
  548.     admin_clear_btn = Button(admin_window, text="Clear", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_clear)
  549.     admin_clear_btn.place(x=977, y=685)
  550.     admin_exit_btn = Button(admin_window, text="Exit", bg="red", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_add_exit)
  551.     admin_exit_btn.place(x=830, y=685)
  552.        
  553.     admin_window.deiconify()
  554.     admin_window.mainloop()
  555.  
  556.  
  557. def admin_home_pg_update():
  558.     global admin_main_window, date_live, time_live, ent_ref_no
  559.     admin_main_window.withdraw()
  560.  
  561.     admin_select_window =Toplevel(admin_main_window)
  562.     admin_select_window .withdraw()
  563.     general_window_setup((480, 360), admin_select_window , "Admin Update Page", "download.ico")
  564.  
  565.     bg_image = ImageTk.PhotoImage(file="update_pg_bg_img.jpg")
  566.  
  567.     admin_select_window_canvas = Canvas(admin_select_window, width=480, height=360, bd=0, highlightthickness=0)
  568.     admin_select_window_canvas.pack(fill="both", expand=True)
  569.     admin_select_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  570.  
  571.     admin_select_window_canvas.create_text(237, 80, text="Enter the Ref. No. to update:", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  572.    
  573.     def admin_select_exit():   
  574.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  575.         #if res == 'yes':
  576.         admin_main_window.deiconify()
  577.         admin_select_window.destroy()
  578.  
  579.     def admin_update():
  580.         ref_no_typed = ent_ref_no_typed.get()
  581.  
  582.         if len(ref_no_typed) == 0:
  583.             showerror("Error", "No Ref No. provided")
  584.             ent_ref_no_typed.focus()
  585.             return
  586.         if not ref_no_typed.isdigit():
  587.             showerror("Error", "Ref No. only accepts digits as input")
  588.             ent_ref_no_typed.focus()
  589.             return
  590.  
  591.         con = None 
  592.         try:
  593.             con = connect("customer_data.db")
  594.             cursor = con.cursor()
  595.  
  596.             sql = ("select ref_no from customers")
  597.             cursor.execute(sql)
  598.             data = cursor.fetchall()
  599.             new_data = str(data).strip('[]')
  600.  
  601.            
  602.             if not ref_no_typed in new_data:
  603.                 showerror("Error", "Ref. No. does not exist")
  604.             else:  
  605.                 sql_2 = ("select * from customers where ref_no=?")
  606.                 cursor.execute(sql_2, (ref_no_typed,))
  607.                 data_2 = cursor.fetchall()
  608.  
  609.                 for d in data_2:
  610.                     ref_no = str(d[0])
  611.                     issue_reported_date = str(d[1])
  612.                     issue_reported = str(d[2])
  613.                     issue_reported_details = str(d[3])
  614.                     issue_diagnosed = str(d[4])
  615.                     issue_diagnosed_details = str(d[5])
  616.                     issue_logged_by = str(d[6])
  617.                     machine_type = str(d[7])
  618.                     machine_model = str(d[8])
  619.                     machine_sr_no = str(d[9])
  620.                     machine_details = str(d[10])
  621.                     f_name = str(d[11])
  622.                     l_name = str(d[12])
  623.                     email = str(d[13])
  624.                     second_email = str(d[14])
  625.                     mob_no = str(d[15])
  626.                     alter_mob_no = str(d[16])
  627.                     company_name = str(d[17])
  628.                     company_loc = str(d[18])
  629.                     customer_of = str(d[19])
  630.                     address = str(d[20])
  631.                     city = str(d[21])
  632.                     state = str(d[22])
  633.                     country = str(d[23])
  634.                     pincode = str(d[24])
  635.                    
  636.                 admin_select_window.withdraw()
  637.  
  638.                 admin_window =Toplevel(admin_select_window)
  639.                 admin_window.withdraw()
  640.                 general_window_setup((1280, 720), admin_window, "Admin Update Page", "download.ico")
  641.  
  642.                 bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  643.  
  644.                 admin_window_canvas = Canvas(admin_window, width=1280, height=720, bd=0, highlightthickness=0)
  645.                 admin_window_canvas.pack(fill="both", expand=True)
  646.                 admin_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  647.  
  648.                 def admin_update_exit():   
  649.                     #res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  650.                     #if res == 'yes':
  651.                     admin_select_window.deiconify()
  652.                     admin_window.destroy()
  653.  
  654.                 def admin_update_clear():
  655.                     ent_ref_no.delete(0, END)
  656.                     ent_date.delete(0, END)
  657.                     combo_issue_reported.delete(0, END)
  658.                     scr_issue_reported.delete(1.0, END)
  659.                     combo_issue_diagnosed.delete(0, END)
  660.                     scr_issue_diagnosed.delete(1.0, END)
  661.                     ent_issue_logged_by.delete(0, END)
  662.                     combo_machine_type.delete(0, END)
  663.                     ent_machine_model.delete(0, END)
  664.                     ent_machine_sr_no.delete(0, END)
  665.                     scr_machine_details.delete(1.0, END)
  666.  
  667.                 def admin_update_next():
  668.                     admin_window.withdraw()
  669.  
  670.                     admin_update_next_window =Toplevel(admin_window)
  671.                     admin_update_next_window.withdraw()
  672.                     general_window_setup((1280, 720), admin_update_next_window, "Admin Update Page", "download.ico")
  673.  
  674.                     bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  675.  
  676.                     admin_update_next_window_canvas = Canvas(admin_update_next_window, width=1280, height=720, bd=0, highlightthickness=0)
  677.                     admin_update_next_window_canvas.pack(fill="both", expand=True)
  678.                     admin_update_next_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  679.    
  680.                     def admin_update_next_back():
  681.                         admin_window.deiconify()
  682.                         admin_update_next_window.withdraw()
  683.  
  684.                     def admin_update_next_clear():
  685.                         ent_first_name.delete(0, END)
  686.                         ent_last_name.delete(0, END)
  687.                         ent_email_1.delete(0, END)
  688.                         ent_email_2.delete(0, END)
  689.                         ent_mobile_no_1.delete(0, END)
  690.                         ent_mobile_no_2.delete(0, END)
  691.                         ent_co_name.delete(0, END)
  692.                         ent_co_loc.delete(0, END)
  693.                         ent_customer_of.delete(0, END)
  694.                         ent_address.delete(1.0, END)
  695.                         ent_city.delete(0, END)
  696.                         combo_state.delete(0, END)
  697.                         ent_pincode.delete(0, END)
  698.  
  699.                     def admin_update_next_2():
  700.                         con = None
  701.                         try:
  702.                             con = connect("customer_data.db")
  703.                             cursor = con.cursor()
  704.                             sql ="update customers set  issue_reported_date='%s', issue_reported='%s', issue_reported_details='%s', issue_diagnosed='%s', issue_diagnosed_details='%s', issue_logged_by='%s', machine_type='%s', machine_model='%s', machine_sr_no='%s', machine_details='%s', f_name='%s', l_name='%s', email='%s', second_email='%s', mob_no='%s', alter_mob_no='%s', company_name='%s', company_loc='%s', customer_of='%s', address='%s', city='%s', state='%s', country='%s', pincode='%s' where ref_no ='%s'"
  705.                             issue_reported_date = ent_date.get()
  706.                             issue_reported = combo_issue_reported.get()
  707.                             issue_reported_details = scr_issue_reported.get("1.0",'end-1c')
  708.                             issue_diagnosed = combo_issue_diagnosed.get()
  709.                             issue_diagnosed_details = scr_issue_diagnosed.get("1.0",'end-1c')
  710.                             issue_logged_by = ent_issue_logged_by.get()
  711.                             machine_type = combo_machine_type.get()
  712.                             machine_model =ent_machine_model.get()
  713.                             machine_sr_no = ent_machine_sr_no.get()
  714.                             machine_details = scr_machine_details.get("1.0",'end-1c')
  715.                             f_name = ent_first_name.get()
  716.                             l_name = ent_last_name.get()
  717.                             email = ent_email_1.get()
  718.                             second_email = ent_email_2.get()
  719.                             mob_no = ent_mobile_no_1.get()
  720.                             alter_mob_no = ent_mobile_no_2.get()
  721.                             company_name = ent_co_name.get()
  722.                             company_loc = ent_co_loc.get()
  723.                             customer_of = ent_customer_of.get()
  724.                             address = ent_address.get("1.0",'end-1c')
  725.                             city = ent_city.get()
  726.                             state = combo_state.get()
  727.                             country = ent_country.get()
  728.                             pincode = ent_pincode.get()
  729.                             ref_no = ent_ref_no.get()
  730.    
  731.                             if len(f_name) == 0:
  732.                                 showerror("First Name Issue", "Name cannot be empty")
  733.                                 ent_first_name.delete(0, END)
  734.                                 ent_first_name.focus()
  735.                                 return
  736.                             if (not f_name.isalpha()):
  737.                                 showerror("First Name Issue", "Name cannot be a number")
  738.                                 ent_first_name.delete(0, END)
  739.                                 ent_first_name.focus()
  740.                                 return
  741.                             if (len(f_name) < 2):
  742.                                 showerror("First Name Issue", "Name cannot be less than two letters")
  743.                                 ent_first_name.delete(0, END)
  744.                                 ent_first_name.focus()
  745.                                 return
  746.                             if (not l_name.isalpha()) and (len(l_name) != 0):
  747.                                 showerror("Last Name Issue", "Name cannot be a number")
  748.                                 ent_last_name.delete(0, END)
  749.                                 ent_last_name.focus()
  750.                                 return
  751.                             if (len(l_name) < 2) and (len(l_name) != 0):
  752.                                 showerror("Last Name Issue", "Name cannot be less than two letters")
  753.                                 ent_last_name.delete(0, END)
  754.                                 ent_last_name.focus()
  755.                                 return
  756.                             if len(mob_no) == 0:
  757.                                 showerror("Mobile No Issue", "Mobile No cannot be empty")
  758.                                 ent_mobile_no_1.delete(0, END)
  759.                                 ent_mobile_no_1.focus()
  760.                                 return
  761.                             if (not mob_no.isdigit()):
  762.                                 showerror("Mobile No Issue", "Mobile No should be in digits only")     
  763.                                 ent_mobile_no_1.delete(0, END)
  764.                                 ent_mobile_no_1.focus()
  765.                                 return
  766.                             if (len(mob_no) < 10):
  767.                                 showerror("Mobile No Issue", "Mobile No cannot be less than 10 digits")
  768.                                 ent_mobile_no_1.delete(0, END)
  769.                                 ent_mobile_no_1.focus()
  770.                                 return
  771.                             if (len(mob_no) > 10):
  772.                                 showerror("Mobile No Issue", "Mobile No cannot be more than 10 digits")
  773.                                 ent_mobile_no_1.delete(0, END)
  774.                                 ent_mobile_no_1.focus()
  775.                                 return
  776.                             if (not alter_mob_no.isdigit()) and (len(alter_mob_no) != 0):
  777.                                 showerror("Alternate Mobile No Issue", "Mobile No should be in digits only")       
  778.                                 ent_mobile_no_2.delete(0, END)
  779.                                 ent_mobile_no_2.focus()
  780.                                 return
  781.                             if (len(alter_mob_no) < 10) and (len(alter_mob_no) != 0):
  782.                                 showerror("Alternate Mobile No Issue", "Mobile No cannot be less than 10 digits")
  783.                                 ent_mobile_no_2.delete(0, END)
  784.                                 ent_mobile_no_2.focus()
  785.                                 return
  786.                             if (len(alter_mob_no) > 10):
  787.                                 showerror("Alternate Mobile No Issue", "Mobile No cannot be more than 10 digits")
  788.                                 ent_mobile_no_2.delete(0, END)
  789.                                 ent_mobile_no_2.focus()
  790.                                 return
  791.  
  792.                             cursor.execute(sql % (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, f_name, l_name, email, second_email, mob_no, alter_mob_no, company_name, company_loc, customer_of, address, city, state, country, pincode, ref_no))
  793.                             if cursor.rowcount == 1:
  794.                                 con.commit()
  795.                                 showinfo("Success","Record updated successfully")
  796.  
  797.                         except Exception as e:
  798.                             con.rollback()
  799.                             showerror("Error", str(e))
  800.  
  801.                         finally:
  802.                             if con is not None:
  803.                                 con.close()
  804.  
  805.                     option = StringVar()
  806.    
  807.                     admin_update_next_window_canvas.create_text(180, 40, text="Contact Details", font=("Impact", 35, "bold"), fill="#6162FF")
  808.                     admin_update_next_window_canvas.create_text(152, 95, text="Enter Contact Information", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  809.                     admin_update_next_window_canvas.create_text(82, 140, text="First Name", font=("Goudy old style", 15, "bold"), fill="grey")
  810.                     admin_update_next_window_canvas.create_text(401, 140, text="Last Name", font=("Goudy old style", 15, "bold"), fill="grey")
  811.                     admin_update_next_window_canvas.create_text(55, 225, text="Email", font=("Goudy old style", 15, "bold"), fill="grey")
  812.                     admin_update_next_window_canvas.create_text(430, 225, text="Secondary Email", font=("Goudy old style", 15, "bold"), fill="grey")
  813.                     admin_update_next_window_canvas.create_text(81, 310, text="Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  814.                     admin_update_next_window_canvas.create_text(447, 310, text="Alternate Mobile No.", font=("Goudy old style", 15, "bold"), fill="grey")
  815.                     admin_update_next_window_canvas.create_text(104, 395, text="Company Name", font=("Goudy old style", 15, "bold"), fill="grey")
  816.                     admin_update_next_window_canvas.create_text(118, 480, text="Company Location", font=("Goudy old style", 15, "bold"), fill="grey")
  817.                     admin_update_next_window_canvas.create_text(91, 565, text="Customer Of", font=("Goudy old style", 15, "bold"), fill="grey")
  818.                     admin_update_next_window_canvas.create_text(820, 95, text="Address for Machine Location", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  819.                     admin_update_next_window_canvas.create_text(720, 140, text="Address", font=("Goudy old style", 15, "bold"), fill="grey")
  820.                     admin_update_next_window_canvas.create_text(700, 395, text="City", font=("Goudy old style", 15, "bold"), fill="grey")
  821.                     admin_update_next_window_canvas.create_text(1015, 395, text="State", font=("Goudy old style", 15, "bold"), fill="grey")
  822.                     admin_update_next_window_canvas.create_text(719, 480, text="Country", font=("Goudy old style", 15, "bold"), fill="grey")
  823.                     admin_update_next_window_canvas.create_text(1029, 480, text="Pincode", font=("Goudy old style", 15, "bold"), fill="grey")
  824.  
  825.                     ent_first_name = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  826.                     ent_first_name.place(x=30, y=160, width=275, height=35)
  827.  
  828.                     ent_last_name = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  829.                     ent_last_name.place(x=350, y=160, width=275, height=35)
  830.  
  831.                     ent_email_1 = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  832.                     ent_email_1.place(x=30, y=245, width=275, height=35)
  833.    
  834.                     ent_email_2 = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  835.                     ent_email_2.place(x=350, y=245, width=275, height=35)
  836.  
  837.                     ent_mobile_no_1 = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  838.                     ent_mobile_no_1.place(x=30, y=330, width=275, height=35)
  839.  
  840.                     ent_mobile_no_2 = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  841.                     ent_mobile_no_2.place(x=350, y=330, width=275, height=35)
  842.    
  843.                     ent_co_name = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  844.                     ent_co_name.place(x=30, y=415, width=600, height=35)
  845.  
  846.                     ent_co_loc = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  847.                     ent_co_loc.place(x=30, y=500, width=600, height=35)
  848.  
  849.                     ent_customer_of = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  850.                     ent_customer_of.place(x=30, y=587, width=600, height=35)
  851.  
  852.                     ent_address = ScrolledText(admin_update_next_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  853.                     ent_address.place(x=680, y=160)
  854.        
  855.                     ent_city = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  856.                     ent_city.place(x=680, y=415, width=275, height=35)
  857.    
  858.                     f=("Goudy old style", 15)
  859.  
  860.                     style = ttk.Style()
  861.                     style.configure('combo_state.TCombobox', selectbackground='blue', arrowsize=15)
  862.  
  863.                     combo_state = ttk.Combobox(admin_update_next_window, textvariable=option, style='combo_state.TCombobox', font=("Goudy old style", 15))
  864.                     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']
  865.                     combo_state.option_add("*TCombobox*Listbox*Font", f)
  866.                     combo_state.place(x=990, y=415, width=260, height=35)
  867.                     combo_state.set("")
  868.  
  869.                     ent_country = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  870.                     ent_country.insert(END, 'India')
  871.                     ent_country.bind("<Key>", lambda a: "break")
  872.                     ent_country.place(x=680, y=500, width=275, height=35)
  873.  
  874.                     ent_pincode = Entry(admin_update_next_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  875.                     ent_pincode.place(x=990, y=500, width=260, height=35)
  876.  
  877.                     ent_first_name.insert(END, f_name)
  878.                     ent_last_name.insert(END, l_name)
  879.                     ent_email_1.insert(END, email)
  880.                     ent_email_2.insert(END, second_email)
  881.                     ent_mobile_no_1.insert(END, mob_no)
  882.                     ent_mobile_no_2.insert(END, alter_mob_no)
  883.                     ent_co_name.insert(END, company_name)
  884.                     ent_co_loc.insert(END, company_loc)
  885.                     ent_customer_of.insert(END, customer_of)
  886.                     ent_address.insert(END, address)
  887.                     ent_city.insert(END, city)
  888.                     combo_state.insert(END, state)
  889.                     ent_pincode.insert(END, pincode)
  890.                
  891.  
  892.                     admin_update_next_btn = Button(admin_update_next_window, text="Next", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_next_2)
  893.                     admin_update_next_btn.place(x=1125, y=625)
  894.                     admin_update_back_btn = Button(admin_update_next_window, text="Back", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_next_back)
  895.                     admin_update_back_btn.place(x=977, y=625)
  896.                     admin_update_clear_btn = Button(admin_update_next_window, text="Clear", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_next_clear)
  897.                     admin_update_clear_btn.place(x=830, y=625)
  898.                     admin_update_btn = Button(admin_update_next_window, text="Exit", bg="red", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_exit)
  899.                     admin_update_btn.place(x=682, y=625)
  900.    
  901.                     admin_update_next_window.deiconify()
  902.                     admin_update_next_window.mainloop()
  903.    
  904.                 option1 = StringVar()
  905.                 option2 = StringVar()
  906.                 option3 = StringVar()
  907.  
  908.                 admin_window_canvas.create_text(256, 40, text="Issue/Machine Details", font=("Impact", 35, "bold"), fill="#6162FF")
  909.                 admin_window_canvas.create_text(120, 95, text="Enter Issue Details ", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  910.                 admin_window_canvas.create_text(69, 140, text="Ref. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  911.                 admin_window_canvas.create_text(438, 140, text="Issue Reported on", font=("Goudy old style", 15, "bold"), fill="grey")
  912.                 admin_window_canvas.create_text(103, 225, text="Issue Reported", font=("Goudy old style", 15, "bold"), fill="grey")
  913.                 admin_window_canvas.create_text(430, 225, text="Issue Diagnosed", font=("Goudy old style", 15, "bold"), fill="grey")
  914.                 admin_window_canvas.create_text(63, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  915.                 admin_window_canvas.create_text(384, 315, text="Details", font=("Goudy old style", 15, "bold"), fill="grey")
  916.                 admin_window_canvas.create_text(205, 565, text="Issue Logged By (Engineers's Name)", font=("Goudy old style", 15, "bold"), fill="grey")
  917.                 admin_window_canvas.create_text(752, 95, text="Machine Details", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  918.                 admin_window_canvas.create_text(747, 140, text="Machine Type", font=("Goudy old style", 15, "bold"), fill="grey")
  919.                 admin_window_canvas.create_text(752, 225, text="Machine Model", font=("Goudy old style", 15, "bold"), fill="grey")
  920.                 admin_window_canvas.create_text(1061, 225, text="Machine Sr. No.", font=("Goudy old style", 15, "bold"), fill="grey")
  921.                 admin_window_canvas.create_text(820, 315, text="Machine Details & Accesories", font=("Goudy old style", 15, "bold"), fill="grey")  
  922.    
  923.                 ent_ref_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  924.                 ent_ref_no.place(x=30, y=160, width=275, height=35)
  925.  
  926.                 ent_date = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  927.                 ent_date.bind("<Key>", lambda a: "break")
  928.                 ent_date.place(x=350, y=160, width=275, height=35)
  929.        
  930.                 f=("Goudy old style", 15)
  931.  
  932.                 style = ttk.Style()
  933.  
  934.                 style.configure('combo_issue_reported.TCombobox', selectbackground='blue', arrowsize=15)
  935.  
  936.                 combo_issue_reported = ttk.Combobox(admin_window, textvariable=option1, style='combo_issue_reported.TCombobox', font=("Goudy old style", 15))
  937.                 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']
  938.                 combo_issue_reported.option_add("*TCombobox*Listbox*Font", f)
  939.                 combo_issue_reported.place(x=30, y=245, width=276, height=35)
  940.                 combo_issue_reported.set("")
  941.  
  942.                 scr_issue_reported = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  943.                 scr_issue_reported.place(x=30, y=335)
  944.  
  945.                 style.configure('combo_issue_diagnosed.TCombobox', selectbackground='blue', arrowsize=15)
  946.  
  947.                 combo_issue_diagnosed = ttk.Combobox(admin_window, textvariable=option2, style='combo_issue_diagnosed.TCombobox', font=("Goudy old style", 15))
  948.                 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']
  949.                 combo_issue_diagnosed.option_add("*TCombobox*Listbox*Font", f)
  950.                 combo_issue_diagnosed.place(x=350, y=245, width=276, height=35)
  951.                 combo_issue_diagnosed.set("")
  952.  
  953.                 scr_issue_diagnosed = ScrolledText(admin_window, width=23, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  954.                 scr_issue_diagnosed.place(x=350, y=335)
  955.  
  956.                 ent_issue_logged_by = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  957.                 ent_issue_logged_by.place(x=30, y=588, width=600, height=35)
  958.  
  959.                 style.configure('combo_machine_type.TCombobox', selectbackground='blue', arrowsize=15)
  960.        
  961.                 combo_machine_type = ttk.Combobox(admin_window, textvariable=option3, style='combo_machine_type.TCombobox', font=("Goudy old style", 15))
  962.                 combo_machine_type["values"] = ['Desktop', 'Laptop', 'All-In-One', 'Server', 'Switch', 'Router', 'UPS', 'External HDD', 'Modem', 'Printer', 'Scanner', 'Projector', 'Speakers', 'Headphones', 'Mouse', 'Keyboard', 'Others']
  963.                 combo_machine_type.option_add("*TCombobox*Listbox*Font", f)
  964.                 combo_machine_type.place(x=680, y=160, width=270, height=35)
  965.                 combo_machine_type.set("")
  966.  
  967.                 ent_machine_model = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  968.                 ent_machine_model.place(x=680, y=245, width=270, height=35)
  969.    
  970.                 ent_machine_sr_no = Entry(admin_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  971.                 ent_machine_sr_no.place(x=985, y=245, width=270, height=35)
  972.  
  973.                 scr_machine_details = ScrolledText(admin_window, width=50, height=8.45, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  974.                 scr_machine_details.place(x=680, y=335)
  975.  
  976.                 ent_ref_no.insert(END, ref_no)
  977.                 ent_date.insert(END, issue_reported_date)
  978.                 combo_issue_reported.insert(END, issue_reported)
  979.                 scr_issue_reported.insert(END, issue_reported_details)
  980.                 combo_issue_diagnosed.insert(END, issue_diagnosed)
  981.                 scr_issue_diagnosed.insert(END, issue_diagnosed_details)
  982.                 ent_issue_logged_by.insert(END, issue_logged_by)
  983.                 combo_machine_type.insert(END, machine_type)
  984.                 ent_machine_model.insert(END, machine_model)
  985.                 ent_machine_sr_no.insert(END, machine_sr_no)
  986.                 scr_machine_details.insert(END, machine_details)
  987.  
  988.                 admin_next_btn = Button(admin_window, text="Next", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_next)
  989.                 admin_next_btn.place(x=1125, y=625)
  990.                 admin_clear_btn = Button(admin_window, text="Clear", bg="#6162FF", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_clear)
  991.                 admin_clear_btn.place(x=977, y=625)
  992.                 admin_exit_btn = Button(admin_window, text="Exit", bg="red", fg="white", width=8, bd=1, font=("Arial", 18, "bold"), command=admin_update_exit)
  993.                 admin_exit_btn.place(x=830, y=625)
  994.                
  995.                 admin_window.deiconify()
  996.                 admin_window.mainloop()
  997.  
  998.         except Exception as e:
  999.             con.rollback()
  1000.             showerror("Error", str(e))
  1001.  
  1002.         finally:
  1003.             if con is not None:
  1004.                 con.close()
  1005.  
  1006.     ent_ref_no_typed = Entry(admin_select_window, font=("Goudy old style", 15), bd=1, bg="white", fg="black")
  1007.     ent_ref_no_typed.place(x=95, y=110, width=290, height=35)
  1008.  
  1009.     admin_select_update_btn = Button(admin_select_window, text="Update", bg="#6162FF", fg="white", width=10, bd=1, font=("Arial", 17, "bold"), command=admin_update)
  1010.     admin_select_update_btn.place(x=162, y=172)
  1011.     admin_select_exit_btn = Button(admin_select_window, text="Exit", bg="red", fg="white", width=10, bd=1, font=("Arial", 17, "bold"), command=admin_select_exit)
  1012.     admin_select_exit_btn.place(x=162, y=240)
  1013.  
  1014.     admin_select_window.deiconify()
  1015.     admin_select_window.mainloop()
  1016.    
  1017. def admin_home_pg_delete():
  1018.     global admin_main_window
  1019.  
  1020.     admin_delete_window =Toplevel(admin_main_window)
  1021.     admin_delete_window.withdraw()
  1022.     general_window_setup((1600, 900), admin_delete_window, "Admin Update Page", "download.ico")
  1023.  
  1024.     bg_image = ImageTk.PhotoImage(file="delete_pg_bg_img.jpg")
  1025.  
  1026.     admin_delete_window_canvas = Canvas(admin_delete_window, width=1600, height=900, bd=0, highlightthickness=0)
  1027.     admin_delete_window_canvas.pack(fill="both", expand=True)
  1028.     admin_delete_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  1029.  
  1030.     def admin_delete_exit():   
  1031.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  1032.         #if res == 'yes':
  1033.         admin_main_window.deiconify()
  1034.         admin_delete_window.destroy()
  1035.    
  1036.     admin_exit_btn = Button(admin_delete_window, text="Exit", bg="red", fg="white", width=12, bd=1, font=("Arial", 18, "bold"), command=admin_delete_exit)
  1037.     admin_exit_btn.place(x=670, y=800)
  1038.  
  1039.     admin_delete_window.deiconify()
  1040.     admin_delete_window.mainloop()
  1041.  
  1042. def admin_home_pg_view():
  1043.     global admin_main_window
  1044.     admin_main_window.withdraw()
  1045.  
  1046.     admin_window = Toplevel(user_main_window)
  1047.     admin_window.withdraw()
  1048.     general_window_setup((1280, 720), admin_window, "Admin View Page", "download.ico")
  1049.  
  1050.     bg_image = ImageTk.PhotoImage(file="add_update_view_pg_bg_img.jpg")
  1051.  
  1052.     admin_window_canvas = Canvas(admin_window, width=1280, height=720, bd=0, highlightthickness=0)
  1053.     admin_window_canvas.pack(fill="both", expand=True)
  1054.     admin_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  1055.  
  1056.     def admin_exit():
  1057.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  1058.         #if res == 'yes':
  1059.         admin_main_window.deiconify()
  1060.         admin_window.destroy()
  1061.  
  1062.     admin_exit_btn = Button(admin_window, text="Exit", bg="red", fg="white", width=12, bd=1, font=("Arial", 18, "bold"), command=admin_exit)
  1063.     admin_exit_btn.place(x=550, y=600)
  1064.  
  1065.     admin_window.deiconify()
  1066.     admin_window.mainloop()
  1067.  
  1068. # ------------------------------------------------------------------------------------------------------- User Page -------------------------------------------------------------------------------------------------------------
  1069.  
  1070. def user_home_pg():
  1071.     global user_main_window
  1072.     login_window.withdraw()
  1073.  
  1074.     user_main_window = Toplevel(login_window)
  1075.     user_main_window.withdraw()
  1076.     general_window_setup((500, 530), user_main_window, "Admin Homepage", "download.ico")
  1077.  
  1078.     bg_image = ImageTk.PhotoImage(file="home_pg_bg_img.jpg")
  1079.  
  1080.     user_main_window_canvas = Canvas(user_main_window, width=500, height=530, bd=0, highlightthickness=0)
  1081.     user_main_window_canvas.pack(fill="both", expand=True)
  1082.     user_main_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  1083.  
  1084.     def user_home_pg_exit():
  1085.         #res = messagebox.askquestion('Confirm', 'Are you sure you want to sign out?', icon='warning')
  1086.         #if res == 'yes':
  1087.         login_window.deiconify()
  1088.         user_main_window.destroy()
  1089.  
  1090.     f = ("Arial", 18, "bold")
  1091.  
  1092.     mw_btn_view = Button(user_main_window, text="View", bd=1, font=f, bg="#6162FF", fg="white", width=12)
  1093.     mw_btn_view.place(x=154, y=20)
  1094.     mw_btn_exit= Button(user_main_window, text="Log Out", bd=1, font=f, width=12, bg="red", fg="white", command=user_home_pg_exit)
  1095.     mw_btn_exit.place(x=154, y=90)
  1096.  
  1097.     user_main_window.deiconify()
  1098.     user_main_window.mainloop()
  1099.  
  1100. def user_home_view():
  1101.     global user_main_window
  1102.     user_main_window.withdraw()
  1103.  
  1104.     user_window = Toplevel(user_main_window)
  1105.     user_window.withdraw()
  1106.     general_window_setup((1280, 720), user_window, "User Homepage", "download.ico")
  1107.    
  1108.     bg_image = ImageTk.PhotoImage(file="add_update_view_bg_img.jpg")
  1109.  
  1110.     user_window_canvas = Canvas(user_window, width=1280, height=720, bd=0, highlightthickness=0)
  1111.     user_window_canvas.pack(fill="both", expand=True)
  1112.     user_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  1113.  
  1114.     def user_exit():
  1115.         res = messagebox.askquestion('Confirm', 'Are you sure you want to exit?', icon='warning')
  1116.         if res == 'yes':
  1117.             user_main_window.deiconify()
  1118.             user_window.destroy()
  1119.  
  1120.     user_exit_btn = Button(user_window, text="EXIT", bg="red", fg="white", font=("Arial", 25, "bold"), command=user_exit)
  1121.     user_exit_btn.place(x=550, y=600)
  1122.  
  1123.     user_window.deiconify()
  1124.     admin_window.mainloop()
  1125.  
  1126. # ------------------------------------------------------------------------------------------------------ Login Page -------------------------------------------------------------------------------------------------------------
  1127.  
  1128. login_window = Tk()
  1129. login_window.withdraw()
  1130. general_window_setup((500, 500), login_window, "Login Page", "download.ico")
  1131.  
  1132. bg_image = ImageTk.PhotoImage(file="login_pg_bg_img.jpg")
  1133.  
  1134. login_window_canvas = Canvas(login_window, width=500, height=500, bd=0, highlightthickness=0)
  1135. login_window_canvas.pack(fill="both", expand=True)
  1136. login_window_canvas.create_image(0, 0, image=bg_image, anchor="nw")
  1137.  
  1138. login_window_canvas.create_text(144, 80, text="Login", font=("Impact", 35, "bold"), fill="#6162FF")
  1139. login_window_canvas.create_text(191, 130, text="Employee Login Area", font=("Goudy old style", 15, "bold"), fill="#1d1d1d")
  1140. login_window_canvas.create_text(138, 173, text="Username", font=("Goudy old style", 15, "bold"), fill="grey")
  1141. login_window_canvas.create_text(138, 244, text="Password", font=("Goudy old style", 15, "bold"), fill="grey")
  1142.  
  1143. ent_username = Entry(login_window, font=("Goudy old style", 15), bg="white", fg="black")
  1144. ent_username.place(x=90, y=190, width=320, height=35)
  1145.  
  1146. ent_password = Entry(login_window, font=("Goudy old style", 15), bg="white", fg="black", show="*")
  1147. ent_password.place(x=90, y=260, width=320, height=35)
  1148.  
  1149. #btn_forgot_pass = Button(login_window, text="forgot password?", font=("Goudy old style", 12), bd=0, fg="#6162FF")
  1150. #btn_forgot_pass.place(x=90, y=280)
  1151.  
  1152. btn_login = Button(login_window, text="Login", font=("Goudy old style", 15), bd=1, bg="#6162FF", fg="white", command=check_login_cred)
  1153. btn_login.place(x=90, y=320, width=180, height=40)
  1154.  
  1155. login_window.deiconify()
  1156. login_window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement