-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession13(a).py
More file actions
158 lines (104 loc) · 3.29 KB
/
session13(a).py
File metadata and controls
158 lines (104 loc) · 3.29 KB
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
from tkinter import *
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
# Use a service account
cred = credentials.Certificate("serviceKey.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
class Customer:
def __init__(self, name, phone, email):
self.name = name
self.phone = phone
self.email = email
def showCustomerDetails(self):
print(">>Name: {} Phone: {} Email: {}".format(self.name, self.phone, self.email))
def onClick():
print("Button CLicked!!")
c1 = Customer(None, None, None)
c1.name = entryName.get()
c1.phone = entryEmail.get()
c1.email = entryEmail.get()
c1.showCustomerDetails()
data = c1.__dict__
print(data)
db.collection("Customer").document().set(data)
print(">> ", c1.name, "Saved in Firebase")
print("Done")
def onClick2():
print("Button Clicked")
c1 = Customer(None, None, None)
c1.id = entryId.get()
c1.name = entryName.get()
c1.phone = entryEmail.get()
c1.email = entryEmail.get()
c1.showCustomerDetails()
data = c1.__dict__
print(data)
db.collection("Customer").document().set(data)
print(">> ", c1.name, "Updated in Firebase")
print("Done")
print("Enter ur choice:")
print("1.Save new Customer:")
print("2.Update the Customer:")
print("3.Delete a Customer:")
print("4.View all Customers:")
choice = int(input())
if choice == 1:
window = Tk()
title = Label(window, text="Add Customer Details>>")
title.pack()
name = Label(window, text="Add Customer Name:")
name.pack()
entryName = Entry(window)
entryName.pack()
phone = Label(window, text="Add Phone Of Customer:")
phone.pack()
entryPhone = Entry(window)
entryPhone.pack()
email = Label(window, text="Add Email Of Customer:")
email.pack()
entryEmail = Entry(window)
entryEmail.pack()
btnAddCustomer = Button(window, text="ADD CUSTOMER", command=onClick)
btnAddCustomer.pack()
window.mainloop()
elif choice == 2:
window = Tk()
id = Label(window, text="Enter the Customer id which is to be updated:")
id.pack()
entryId = Entry(window)
entryId.pack()
title = Label(window, text="Add the new Customer details:")
title.pack()
name = Label(window, text="Add the Customer Name:")
name.pack()
entryName = Entry(window)
entryName.pack()
phone = Label(window, text="Add Phone Of Customer:")
phone.pack()
entryPhone = Entry(window)
entryPhone.pack()
email = Label(window, text="Add Email Of Customer:")
email.pack()
entryEmail = Entry(window)
entryEmail.pack()
btnAddCustomer = Button(window, text="UPDATE CUSTOMER", command=onClick2 )
btnAddCustomer.pack()
window.mainloop()
elif choice == 3:
window = Tk()
id = Label(window, text="Enter Customer ID to be deleted:")
id.pack()
entryId = Entry(window)
entryId.pack()
btnAddCustomer = Button(window, text="DELETE CUSTOMER", command=onClick3)
btnAddCustomer.pack()
window.mainloop()
elif choice == 4:
window = Tk()
title = Label(window, text="LIST OF ALL CUSTOMERS>>>")
title.pack()
btnAddCustomer = Button(window, text="VIEW ALL", command=onClick4)
btnAddCustomer.pack()
window.mainloop()