-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCustomer.py
More file actions
131 lines (123 loc) · 6.03 KB
/
Customer.py
File metadata and controls
131 lines (123 loc) · 6.03 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
# to store login information, account editing, shopping cart
import pandas as pd
import numpy as np
from Cart import Cart
class Customer:
customerList=None
def __init__(self, username):
self.Username = username
self.Password = None
self.FirstName = None
self.LastName = None
self.file = 'customer.csv'
self.ShoppingCart = Cart(username)
self.CardNumber=None
self.CardName = None
self.BillAddress = None
self.BillCity = None
self.BillState = None
self.BillZIP = None
self.StreetNumber=None
self.StreetName= None
self.City = None
self.State = None
self.ZipCode=zip
self.Orders=None
self.customerList = pd.read_csv(self.file)
# takes ISBN number, finds corresponding book in inventory, and adds to shopping cart, adjusts inventory number.
# returns books in shopping cart
def GetCart(self):
return self.ShoppingCart
# takes string or ints for address and zipcode, converts into int for number, string for street, and int for zipcode.
def SetAddress(self, Street, Number, City, State, ZipCode):
self.StreetName=Street
self.StreetNumber= Number
self.Zip = ZipCode
self.customerList.loc[self.customerList['user'] == self.Username, 'StreetName'] = Street
self.customerList.loc[self.customerList['user'] == self.Username, 'StreetNumber'] = Number
self.customerList.loc[self.customerList['user'] == self.Username, 'City'] = City
self.customerList.loc[self.customerList['user'] == self.Username, 'State'] = State
self.customerList.loc[self.customerList['user'] == self.Username, 'Zip'] = ZipCode
self.Save2File()
self.print()
# returns address of customer in string format
def GetAddress(self):
# self.StreetAddress = self.StreetAddress.loc[self.StreetAddress.index[self.StreetAddress['user']
return self.StreetNumber + self.StreetName + self.City + self.State + self.Zip
def SetCardNumber(self,Number):
self.CardNumber = Number
def SetName(self, firstname, lastname):
self.FirstName = firstname
self.LastName = lastname
self.customerList.loc[self.customerList['user'] == self.Username, 'First'] = firstname
self.customerList.loc[self.customerList['user'] == self.Username, 'Last'] = lastname
self.Save2File()
#self.print()
def EditPaymentInfo(self, cardName, cardNum, billAddress, billCity, billState, billZip):
self.CardNumber = cardNum
self.CardName = cardName
self.BillAddress = billAddress
self.BillCity = billCity
self.BillState = billState
self.BillZIP = billZip
self.customerList.loc[self.customerList['user'] == self.Username, 'CardName'] = cardName
self.customerList.loc[self.customerList['user'] == self.Username, 'CardNum'] = cardNum
self.customerList.loc[self.customerList['user'] == self.Username, 'BillingAddress'] = billAddress
self.customerList.loc[self.customerList['user'] == self.Username, 'BillingCity'] = billCity
self.customerList.loc[self.customerList['user'] == self.Username, 'BillingState'] = billState
self.customerList.loc[self.customerList['user'] == self.Username, 'BillingZip'] = billZip
self.Save2File()
self.print()
def GetPaymentinfo(self):
return self.CardNumber + self.CardName + self.BillAddress + self.BillCity + self.BillState + self.BillZIP
# return cardnumber as int
def GetCardNumber(self):
return self.CardNumber
# return user name
def GetUsername(self):
return self.Username
# takes string and sets as new password
def SetPassword(self, pwd):
self.Password = pwd
# return password
def GetPassword(self):
return self.Password
# will remove all orders, inventory of user’s
def DeleteAccount(self, order):
self.customerList = self.customerList.drop(self.customerList[self.customerList['user'] == self.Username].index)
self.Save2File()
exit()
# return void
def Logout(self):
exit()
# check user registered
def IsMember(self):
if self.Username in np.array(self.customerList['user']):
self.SetPassword(np.array(self.customerList.loc[self.customerList[self.customerList['user'] == self.Username].index]['password']))
return False
else:
return True
def addMember(self, username, password):
new_row = pd.Series({"user": username, "password": password})
self.customerList = self.customerList.append(new_row, ignore_index=True)
self.Save2File()
def IsRightPassword(self, password):
if self.Password == password:
return True
else:
return False
def Save2File(self):
self.customerList.to_csv(self.file, encoding='utf-8', index=False)
#user,password,First,Last,StreetName,StreetNumber,City,State,Zip,CardName,CardNum,BillingAddress,BillingCity,BillingState,BillingZip
def printAccount(self):
df = (self.customerList.loc[self.customerList.index[self.customerList['user'] == self.Username]])
print(df[['user', 'password', 'First', 'Last']])
#print(self.customerList.loc[self.customerList.index[self.customerList['user'] == self.Username]])
def printShipping(self):
df = (self.customerList.loc[self.customerList.index[self.customerList['user'] == self.Username]])
print(df[['StreetName', 'StreetNumber', 'City', 'State', 'Zip']])
def printBilling(self):
df = (self.customerList.loc[self.customerList.index[self.customerList['user'] == self.Username]])
print(df[['CardName','CardNum','BillingAddress','BillingCity','BillingState','BillingZip']])
def print(self):
print(self.customerList.loc[self.customerList.index[self.customerList['user'] == self.Username]])