-
Notifications
You must be signed in to change notification settings - Fork 0
/
Welcompage.py
212 lines (169 loc) · 9.53 KB
/
Welcompage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
from tkinter import *
from tkinter.font import BOLD
from PIL import ImageTk,Image # pip install pillow
import time
from tkinter import messagebox
from tkinter import ttk
import functools
import databaseConnection
from dashboard import *
from customerRegistration import customerRegClass
from driverDashboard import DriverDashboardClass
from bookTrip import bookTripClass
from forgotPassword import forgotPasswordClass
#======================================================================GUI_Designing======================================================================================
class CBS:
def __init__(self):
self.root=Tk()
self.root.geometry("1920x1080+0+0")
self.root.state('normal')
self.root.title("CarGO")
self.root.config(bg="#2E4CC5")
# ===========================All Variables===========
# self.var_email=StringVar()
self.var_password=StringVar()
self.var_utype=StringVar()
# var_email=StringVar()
self.var_email = StringVar()
#===========Title=============
self.icon_title=PhotoImage(file="images/logo.png")
title = Label(self.root, text="CarGO", image=self.icon_title,compound=LEFT, font=("time new roman", 40, "bold"),bg="#010c48",fg="white", anchor="w",padx=20).place(x=0,y=0, relwidth=1, height=70)
#===========ProjectIcon=============
photo = PhotoImage(file = "images/logo.png")
self.root.iconphoto(False, photo)
#============Clock===============
self.lbl_clock = Label(self.root,text="CarGO\t Date: DD-MM-YYYY\t Time: HH:MM:SS" ,font=("time new roman", 15),bg="#4d636d",fg="white")
self.lbl_clock.place(x=0,y=75, relwidth=1, height=30)
#=============LoginFrame===========
Frame_Login=Frame(self.root,bd=5,relief=RIDGE,bg="white")
Frame_Login.place(x=950, y=70, width=315, height=570)
#===============ComboBoxForGender-Row-1==============================
txt_Utype=ttk.Combobox(Frame_Login,textvariable=self.var_utype, values=("Select UserType","Customer","Driver","Employee"),state='readonly',justify=CENTER,font=("Andalus",10))
txt_Utype.place(x=65,y=100, width=200, height=30)
txt_Utype.current(0)
#===============Label==============
loginTitel=Label(Frame_Login,text="Login System", font=("Elephant",30,"bold"),bg="white").place(x=0,y=30,relwidth=1)
lbl_email=Label(Frame_Login,text="Email*",bg="white", font=("Andalus",15), fg="#767171").place(x=0,y=150, relwidth=1)
lbl_password=Label(Frame_Login,text="Password*", bg="white", font=("Andalus",15), fg="#767171").place(x=0,y=230,relwidth=1)
lbl_hr=Label(Frame_Login, bg="lightgray").place(x=38,y=490,width=250,height=2)
lbl_hrOR=Label(Frame_Login,text="OR", bg="white",font=("times new roman",15,"bold")).place(x=150,y=475)
lbl_member=Label(Frame_Login,text="Don't have an account?", bg="white",font=("times new roman",10)).place(x=80,y=535)
#===============TextBox==============
txtemail=Entry(Frame_Login, textvariable=self.var_email, font=("Andalus",10),bg="white", fg="#767171").place(x=65,y=190, width=200, height=30)
txtpassword=Entry(Frame_Login, textvariable=self.var_password, font=("Andalus",10), bg="white", show="*", fg="#767171").place(x=65,y=280, width=200, height=30)
#============btn_logout=========
btn_logIn=Button(Frame_Login, text="LogIn",command=self.LogIn, font=("time new roman", 15, "bold"), bg="#418BCA",activebackground="#418BCA", cursor="hand2").place(x=65,y=350, height=35, width=200)
btn_cancel=Button(Frame_Login, text="Cancel",command=quit, font=("time new roman", 15, "bold"), bg="#C42F11",activebackground="#C42F11", cursor="hand2").place(x=65,y=420, height=35, width=200)
btn_forgot=Button(Frame_Login, text="Forgot Password?", command=self.forgotPassword, font=("time new roman", 10),bd=0, bg="white",activebackground="white",fg="#418BCA",activeforeground="#418BCA", cursor="hand2").place(x=95,y=500, height=35, width=150)
btn_Signup=Button(Frame_Login, text="Sign Up", command=self.reg, font=("time new roman", 10),bd=0, bg="white",activebackground="white",fg="#418BCA",activeforeground="#418BCA", cursor="hand2").place(x=210,y=529, height=35, width=60)
#============images=====================
self.image1=ImageTk.PhotoImage(file="images/slide9.jpg")
self.image2=ImageTk.PhotoImage(file="images/slide8.jpg")
#=============SilderFrame=============
Frame_slider=Frame(self.root)
Frame_slider.place(x=0,y=110,width=940,height=700)
self.lblimg1=Label(Frame_slider,image=self.image1,bd=0)
self.lblimg1.place(x=0,y=0)
self.lblimg2=Label(Frame_slider,image=self.image2,bd=0)
self.lblimg2.place(x=1100,y=0)
self.x=940
self.slider_func()
#============Footer====================
self.update_date_time()
def update_date_time(self):
time_=time.strftime("%I:%M:%S")
date_=time.strftime("%d-%m-%Y")
self.lbl_clock.config(text=f"Welcome to CarGO\t Date:{str(date_)}\t Time:{str(time_)} ")
self.lbl_clock.after(20,self.update_date_time)
def DashboardFunc(self, email):
# self.root.destroy()
self.new_win=Toplevel(self.root)
self.new_obj=DashboardClass(self.new_win, email)
self.root.withdraw()
def BookingFunc(self,email):
# email=self.var_email.get()
self.new_win=Toplevel(self.root)
self.new_obj=bookTripClass(self.new_win, email)
def driverDahsboard(self,email):
self.new_win=Toplevel(self.root)
self.new_obj=DriverDashboardClass(self.new_win, email)
def forgotPassword(self):
# self.root.destroy()
self.new_win=Toplevel(self.root)
self.new_obj=forgotPasswordClass(self.new_win)
def slider_func(self):
self.x-=1
if self.x==0:
self.x=1100
time.sleep(1)
#====swap====
self.newimg=self.image1
self.image1=self.image2
self.image2=self.newimg
self.lblimg1.config(image=self.image1)
self.lblimg2.config(image=self.image2)
self.lblimg2.place(x=self.x,y=0)
self.lblimg2.after(1,self.slider_func)
#=============Functions=============
def reg(self):
self.new_win=Toplevel(self.root)
self.new_obj=customerRegClass(self.new_win)
#=====================================DatabaseConnectionForLogin====================================
# def getemail(self):
# var_email.get()
def LogIn(self):
email = self.var_email.get()
password = self.var_password.get()
# Establish Connection
databaseConnection
# Find user If there is any take proper action
try:
if self.var_utype.get()=="Select UserType":
messagebox.showwarning("Error","User Type must be requird!")
elif self.var_utype.get()=="Employee":
find_emp = ('SELECT * FROM registration WHERE email = ? and password = ? and userType = "Employee"')
databaseConnection.cur.execute(find_emp, [email, password])
resultEmp = databaseConnection.cur.fetchall()
elif self.var_utype.get()=="Driver":
find_driver = ('SELECT * FROM registration WHERE email = ? and password = ? and userType = "Driver"')
databaseConnection.cur.execute(find_driver, [email, password])
resultDriv = databaseConnection.cur.fetchall()
elif self.var_utype.get()=="Customer":
find_cus = ('SELECT * FROM customer WHERE email = ? and password = ?')
databaseConnection.cur.execute(find_cus, [email, password])
resultCus = databaseConnection.cur.fetchall()
except Exception as ex:
messagebox.showerror(
"Error", f"Error due to : {str(ex)}", parent=self.root)
try:
if self.var_email.get() == "" or self.var_password.get()=="":
messagebox.showerror("Error", "Email,Password Must be required", parent=self.root)
elif self.var_utype.get()=="Employee" and resultEmp:
print(email, "user logged in")
messagebox.showinfo("Success", "Login Successfully")
self.var_utype.set("Select UserType")
# self.var_email.set("")
self.var_password.set("")
self.DashboardFunc(email)
elif self.var_utype.get()=="Driver" and resultDriv:
print(email, "user logged in")
messagebox.showinfo("Success", "Login Successfully")
self.var_utype.set("Select UserType")
# self.var_email.set("")
self.var_password.set("")
self.driverDahsboard(email)
elif self.var_utype.get()=="Customer" and resultCus:
# print(email, "user logged in")
messagebox.showinfo("Success", "Login Successfully")
self.var_utype.set("Select UserType")
# self.var_email.set("")
self.var_password.set("")
self.BookingFunc(email)
else:
messagebox.showerror("Error", "Invalid email and password")
except Exception as ex:
messagebox.showerror(
"Error", f"Error due to : {str(ex)}", parent=self.root)
if __name__=="__main__":
obj=CBS()
mainloop()