def saleByEmployeeParticularDay(self): cur = self._cur cur.execute("select empid from employees") res = cur.fetchall() loempid = [] for i in res: loempid.append(str(i[0])) while (True): print("ENTER DATE OF SALES AS dd/mm/yyyy : ") dat = input() if len(dat.split("/")) != 3: print("INVALID DATE FORMAT ! PLEASE TRY AGAIN !!") else: chk = valid.validDate(dat) if chk: empid = input("ENTER EMPLOYEE ID : ") chk2 = valid.validNumber(empid) if chk2: if empid in loempid: print("\n\n") view.viewSaleDayEmployee(dat, empid, cur) else: print( "EMPLOYEE ID DOES NOT EXIST ! PLEASE TRY AGAIN !!" ) else: print("INVALID EMPLOYEE ID ! PLEASE TRY AGAIN !!") else: print("INVALID DATE FORMAT ! PLEASE TRY AGAIN !!") while (True): msg = """ EMPLOYEE SALES ON A PARTICULAR DAY press : r =======> RETRY q =======> GO BACK m =======> GO TO MAIN MENU """ opt = input(msg) opt = opt.lower() if opt in ['q', 'm']: return opt elif opt == 'r': print("RETRY....") break else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def verify(self): chk = valid.validNumber(self.employeeid.get()) if chk: self.cur.execute("select empid from employees") res = self.cur.fetchall() chk2 = False for i in res: if self.employeeid.get() == str(i[0]): chk2 = True break if chk2: self.displayEmployee() else: tk.messagebox.showerror(title = "INVALID EMPLOYEE ID", message = "EMPLOYEE ID DOES NOT EXIST !") else: tk.messagebox.showerror(title = "INVALID INPUT", message = "NOT A VALID EMPLOYEE ID ! SHOULD BE ONLY NUMERIC !!")
def viewParticularEmployee(self): #WILL BE OVERRIDEN self._cur.execute("select empid,designation from employees ") res = self._cur.fetchall() while (True): print("ENTER EMPLOYEE ID : ") id = input() chk = valid.validNumber(id) if chk: val1 = False des = '' for i in res: if str(i[0]) == id: val1 = True des = i[1] break if val1: if des in ['ADMIN', 'MANAGER']: print("YOU ARE NOT AUTHORIZED TO VIEW ", des, " ACCOUNT !") else: view.viewDetailsEmployee(id, self._cur) else: print("NO SUCH EMPLOYEE EXISTS ! PLEASE TRY AGAIN !!") else: print("INVALID ID! PLEASE TRY AGAIN !!") while (True): msg = """ PARTICULAR EMPLOYEE press : r =======> RETRY q =======> GO BACK m =======> GO TO MAIN MENU """ opt = input(msg) opt = opt.lower() if opt in ['q', 'm']: return opt elif opt == 'r': print("RETRY....") break else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def changeEmployeeDetails(self): #OVERRIDEN cur = self._cur cur.execute("select empid from employees") res = cur.fetchall() while (True): empid = input("ENTER EMPLOYEE ID : ") chk = valid.validNumber(empid) if chk: val = False for i in res: if str(i[0]) == empid: val = True break if val: x = change.changeEmployeeDetailsByAdmin(empid, cur) if x == 'm': return x else: print("EMPLOYEE ID DOES NOT EXIST ! PLEASE TRY AGAIN !!") else: print("INVALID EMPLOYEE ID ! PLEASE TRY AGAIN !!") while (True): msg = """ CHANGE EMPLOYEE DETAILS press : r =======> RETRY q =======> GO BACK m =======> GO TO MAIN MENU """ opt = input(msg) opt = opt.lower() if opt in ['q', 'm']: return opt elif opt == 'r': print("RETRY....") break else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def generate(self): self.but7.configure(state=DISABLED) self.cur.execute('select prid,name,shortcut from menu') res = self.cur.fetchall() lotup = [] #LOTUP TO CHECK FOR NAME INPRID,SHORTCUT,NAME for tup in res: a, b, c = tup[0], tup[1], tup[2] lotup.append((str(a), str(b).upper(), str(c).upper())) name = self.orderid.get() prid = 0 chk = False name = name.upper() for i in lotup: if name in i: chk = True name = i[1] prid = i[0] if chk: chkquant = valid.validNumber(self.quant.get()) if chkquant: size = self.size.get() size = size[0].lower() tup = (name, size, int(self.quant.get())) orders.append(tup) txt = tup[0] + " " + tup[1].upper() + " " + str( tup[2]) + " ADDED" self.disp.configure(state=NORMAL) self.disp.delete("1.0", tk.END) self.disp.insert("1.0", txt) self.disp.configure(state=DISABLED) else: tk.messagebox.showerror( title="INVALID INPUT", message="INVALID QUANTITY! SHOULD BE NUMERIC !!") else: tk.messagebox.showerror( title="INVALID INPUT", message="NO SUCH ID/NAME/SHORTCUT EXISTS !")
def create(self): name = self.name.get() mobile = self.mobile.get() dob = self.dob.get() doj = self.doj.get() gender = self.gender.get() address = self.address.get() sal = self.salary.get() chk_sal = valid.validNumber(sal) passd = self.password.get() chk_pass = valid.validPassword(passd) chk_name = valid.validName(name) chk_dob = valid.validDate(dob) chk_doj = valid.validDate(doj) chk_mobile = valid.validMobile(mobile) empty_name = False empty_add = False empty_salary = False if len(name) == 0: empty_name = True if len(address) == 0: empty_add = True if len(sal) == 0: empty_salary = True if empty_name: tk.messagebox.showerror(title="INVALID NAME", message="NAME CANNOT BE EMPTY !") else: if empty_add: tk.messagebox.showerror(title="INVALID ADDRESS", message="ADDRESS CANNOT BE EMPTY !") else: if empty_salary: tk.messagebox.showerror(title="INVALID SALARY", message="SALARY CANNOT BE EMPTY !") else: if chk_name: if chk_dob and chk_doj: mon = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] a, b, c = dob.split('/') dob = a + "-" + mon[int(b)] + "-" + c a, b, c = doj.split('/') doj = a + "-" + mon[int(b)] + "-" + c if chk_mobile: chk2 = False self.cur.execute( "select mobile from employees") res = self.cur.fetchall() for i in res: if str(i[0]) == mobile: chk2 = False break chk2 = True if chk2: if chk_sal: if chk_pass: self.cur.execute( "select max(empid) from employees" ) res = self.cur.fetchall() employeeid = res[0][0] + 1 self.cur.execute( "insert into employees(mobile,address,gender,dob,doj,name,password,salary,designation,empid,status) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)", (int(mobile), address, gender, dob, doj, name, passd, int(sal), self.designation.get(), employeeid, "ACTIVE")) self.cur.execute("commit") st = "EMPLOYEE CREATED!\n ID : " + str( employeeid ) + " \nPASWORD : " + passd tk.messagebox.showinfo( title="SUCCESS", message=st) else: tk.messagebox.showerror( title="INVALID PASSWORD", message= "PASSSWORD MUST BE OF ATLEAST 8 CHARACTERS !\n MUST CONTAIN ATLEAST 1 DIGIT!! \n MUST CONTAIN ATLEAST 1 SPECIAL CHARACTER!!! \n MUST CONTAIN ATLEAST 1 ALPHABET!!!! \n" ) else: tk.messagebox.showerror( title="INVALID SALARY", message= "SALARY SHOULD BE NUMERIC ONLY !") else: tk.messagebox.showerror( title="INVALID MOBILE", message="MOBILE NUMBER ALREADY EXISTS !" ) else: tk.messagebox.showerror( title="INVALID MOBILE", message= "MOBILE SHOULD BE NUMERIC AND OF 10 DIGITS ONLY !" ) else: tk.messagebox.showerror( title="INVALID DATE", message= "DATE SHOULD BE VALID AND FORMAT - dd/mm/yyyy !" ) else: tk.messagebox.showerror( title="INVALID NAME", message="NAME SHOULD BE ONLY OF CHARACTERS !")
def update(self): self.cur.execute("select max(prid) from menu") res = self.cur.fetchall() prid = res[0][0] + 1 self.cur.execute("select name,shortcut from menu") res = self.cur.fetchall() lonm = [] loshrt = [] for i in res: lonm.append(i[0].upper()) loshrt.append(i[1].upper()) name = self.name.get() name = name.upper() prices = self.price_s.get() pricem = self.price_m.get() pricel = self.price_l.get() shortcut = self.shortcut.get() shortcut = shortcut.upper() type = self.type.get() details = self.disp.get("1.0", "end-1c") chk_name = valid.validPizzaNameandDetails(name) if chk_name: chk_name = False for i in lonm: if name == i: chk_name = False break chk_name = True if chk_name: if len(name) < 25: chk_prices = valid.validNumber(prices) chk_pricem = valid.validNumber(pricem) chk_pricel = valid.validNumber(pricel) if chk_prices and chk_pricem and chk_pricel: chk_shrt = False for i in loshrt: if shortcut == i: chk_shrt = False break chk_shrt = True if chk_shrt: if len(shortcut) < 9: self.cur.execute( "insert into menu(name,price_s,price_m,price_l,type,shortcut,details,prid) values(:1,:2,:3,:4,:5,:6,:7,:8)", (name, prices, pricem, pricel, self.type.get(), shortcut.upper(), details, prid)) self.cur.execute("commit") tk.messagebox.showinfo( title="SUCCESSFULLY CREATED", message="PIZZA CREATED SUCCESSFULLY !") else: tk.messagebox.showerror( title="SHORTCUT TOO LONG", message= "SHORTCUT SHOULD BE LESS THAN 9 CHARATCERS !" ) else: tk.messagebox.showerror( title="INVALID SHORTCUT", message="SHORTCUT ALREADY EXISTS !") else: tk.messagebox.showerror( title="INVALID INPUT", message="PRICE SHOULD BE NUMERIC ONLY !") else: tk.messagebox.showerror( title="TOO LONG NAME", message="NAME SHOULD BE OF LESS THAN 25 CHARACTERS !") else: tk.messagebox.showerror(title="INVALID NAME", message="NAME ALREADY EXISTS !") else: tk.messagebox.showerror(title="INVALID NAME", message="NAME SHOULD BE ONLY CHARACTERS !")
def loginEmployee(self): cur = self.cur empid = self.empid.get() pwd = self.pwd.get() chk = valid.validNumber(empid) if chk: cur.execute( "select status,locks,designation,password,name from employees where empid=:1", (empid, )) res = cur.fetchall() if len(res) == 0: tk.messagebox.showerror( title=" ERROR LOGIN", message="EMPLOYEE ID DOES NOT EXIST !\n PLEASE TRY AGAIN !!" ) else: #IF ID EXISTS res = res[0] if res[0] == 'INACTIVE': tk.messagebox.showerror( title=" ERROR LOGIN", message= "YOU ARE NO LONGER AN EMPLOYEE ! \n ACCESS DENIED !!") else: if res[1] == 'LOCKED': if res[2] == 'CASHIER': tk.messagebox.showerror( title=" ERROR LOGIN", message= "YOUR ACCOUNT IS LOCKED! \n PLEASE CONTACT YOUR MANAGER OR ADMIN !! ACCESS DENIED!!!" ) else: tk.messagebox.showerror( title=" ERROR LOGIN", message= "YOUR ACCOUNT IS LOCKED! \n PLEASE CONTACT YOUR ADMIN !! ACCESS DENIED!!!" ) else: if pwd == res[3]: self.destroy() if res[2] == "CASHIER": cashier.startCashier(int(empid), cur) elif res[2] == "MANAGER": manager.startManager(int(empid), cur) else: admin.startAdmin(int(empid), cur) else: tk.messagebox.showerror( title=" ERROR LOGIN", message= "INCORRECT ID OR PASSWORD ! PLEASE TRY AGAIN !!" ) self.chance = self.chance - 1 if res[2] in ['CASHIER', 'MANAGER']: if self.chance <= 0: changes.changeEmployeeLockLogin(empid, cur) tk.messagebox.showerror( title="ACCOUNT LOCKED ", message= "DUE TO 3 CONSECUTIVE FAILED LOGIN ATTEMPT ! \nYOUR ACCOUNT HAS BEEN LOCKED !!" ) else: show = "YOU HAVE ONLY " + str( self.chance) + " LEFT !!" tk.messagebox.showwarning( title="ERROR LOGIN ", message=show) else: if self.chance <= 0: tk.messagebox.showwarning( title="ERROR LOGIN ", message= "YOU HAVE TRIED YOU MAXIMUM LIMIT FOR NOW !PLEASE TRY AFTER SOME TIME ! \n" ) else: tk.messagebox.showerror(title="INVALID INPUT", message="ID SHOULD BE ONLY NUMERIC")
def takeOrder(empid, cur): #TESTED #INTERFACE TO WORK WITH OTHER FUNCTIONS global orders, cust msg = """ ENTER : vm =======> VIEW MENU vo =======> VIEW ORDER create =======> CREATE CUSTOMER ACCOUNT cancel =======> CANCEL ORDER last =======> REMOVE LAST PRODUCT IN OPTION done =======> DONE ORDER print =======> PRINT RECEIPT next =======> NEXT ORDER q =======> GO BACK m =======> MAIN MENU """ print(msg) print( "NOTE : YOU COULD TYPE THESE COMMANDS ANYWHERE/ANYTIME WHILE TAKING ORDER" ) #print("HERE IS THE TODAY'S MENU") #view.viewMenuAll('ALL', cur)needs to be changed id = '' while (True): # GET CUSTOMER ID print("ENTER CUSTOMER ID : ") getCustomers(cur) id = input() id = id.lower() if id not in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'q', 'm' ]: if valid.validMobile(id): if id in cust: break else: print("CUSTOMER DOESN'T EXISTS !") print( "EITHER CREATE ACCOUNT OR RE-ENTER THE CORRECT ID !!") print("\n\n") else: print("NOT A VALID MOBILE NUMBER ! ") print("PLEASE ENTER A VALID MOBILE NUMBER !!") print("\n\n") else: if id == 'vm': showHalfMenu(cur) elif id in ['vo', 'last', 'done', 'print', 'next']: print("NO CURRENT ORDER TO PERFORM ACTION!") print("\n\n") elif id == 'create': create.createCustomerAccount(cur) print("\n\n") elif id == 'cancel': print("ORDER CANCELLED ! PLAESE START AGAIN !!") print("\n\n") return 'cancel' else: return id print("\n\n") print("ENTER ORDER AS : ") print("PRODUCT_ID/NAME/SHORTCUT SIZE(S/M/L) QUANTITY ") cur.execute('select prid,name,shortcut from menu') res = cur.fetchall() lotup = [] #LOTUP TO CHECK FOR NAME INPRID,SHORTCUT,NAME for tup in res: a, b, c = tup[0], tup[1], tup[2] lotup.append((str(a), str(b).upper(), str(c))) print("ENTER 'done' to complete ORDER") while (True): #TAKE ORDERS prod = input() prod = prod.lower() if prod not in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'q', 'm' ]: prod = prod.split() if len(prod) < 3: print("ORDER SHOULD BE ATLEAST 3 PARAMETERS ") else: if len(prod) > 3: namelist = prod[:-2] size = prod[-2] quan = prod[-1] name = ' '.join(namelist) name = name.upper() else: name, size, quan = prod name = name.upper() chk = False pizzaname = '' for i in lotup: #print(i) if name in i: chk = True pizzaname = i[1] break if not chk: print("NO SUCH PRODUCT_ID/NAME/SHORTCUT EXISTS !") print("PLEASE TRY AGAIN !!") print("\n\n") else: if size in ['s', 'm', 'l']: if valid.validNumber(quan): tup = (pizzaname, size, quan) orders.append(tup) else: print("QUANTITY SHOULD BE A NUMBER !") print("PLEASE TRY AGAIN !!") print("\n\n") else: print("NOT A VALID SIZE !") print("PLEASE TRY AGAIN !!") print("\n\n") else: if prod == 'vm': showHalfMenu(cur) print("\n\n") elif prod == 'vo': viewOrder() print("\n\n") elif prod == 'create': print("CUSTOMER CANOT BE CREATED IN BETWEEN ORDER !!") print("\n\n") elif prod == 'last': removeLast() elif prod == 'done': if len(orders) > 0: break else: print("NO ORDER ! TRY AGAIN !!") print() elif prod == 'print': print("FIRST CONFIRM THE ORDER !") print("\n\n") elif prod == 'next': print("EITHER CONFIRM OR CANCEL ORDER TO GO TO NEXT !") print("\n\n") elif prod == 'cancel': print("ORDER CANCELLED ! PLAESE START AGAIN !!") print("\n\n") return prod else: return prod while (True): # FOR ORDER CONFIRMATION print("ORDER IS : ") viewOrder() print("ENTER 'done' to CONFIRM ") print("NOTE : ONCE CONFIRMED ORDER CANNOT BE CANCELLED ") ch = input() ch = ch.lower() if ch in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'q', 'm' ]: if ch == 'vm': showHalfMenu(cur) print("\n\n") elif ch == 'vo': viewOrder() print("\n\n") elif ch == 'create': print("CUSTOMER CANNOT BE CREATED IN BETWEEN ORDER !!") print("\n\n") elif ch == 'last': removeLast() elif ch == 'done': break elif ch == 'print': print("FIRST CONFIRM THE ORDER !") print("\n\n") elif ch == 'next': print("EITHER CONFIRM OR CANCEL ORDER TO GO TO NEXT !") print("\n\n") elif ch == 'cancel': print("ORDER CANCELLED ! PLEASE START AGAIN !!") print("\n\n") return ch else: return ch else: print("INVALID INPUT ! PLEASE TRY AGAIN !!") cur.execute('select points from customers where mobile=:1', (int(id), )) res = cur.fetchall() points = res[0][0] pointsredeem = False if points > 0: while (True): print("CUSTOMER HAVE : ", points, " POINTS") print("ENTER 'done' or 'yes/y' to REDEEM ") print("ENTER 'no/n' to NOT REDEEM") ch = input() ch = ch.lower() if ch in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'yes', 'no', 'y', 'n', 'q', 'm' ]: if ch == 'vm': view.viewMenuAll('ALL', cur) print("\n\n") elif ch == 'vo': viewOrder() print("\n\n") elif ch == 'create': print("CUSTOMER CANNOT BE CREATED IN BETWEEN ORDER !!") print("\n\n") elif ch == 'last': print("CONFIRMED ORDER CANNOT BE CHANGED !!") elif ch in ['done', 'yes', 'y']: pointsredeem = True break elif ch in ['no', 'n']: break elif ch == 'print': print("FIRST COMPLETE THE ORDER !") print("\n\n") elif ch == 'next': print(" FIRST COMPLETE THE ORDER !") print("\n\n") elif ch == 'cancel': print("ORDER CANNOT BE CANCELLED !!") print("\n\n") else: print("YOU CANNOT GO BACK ! UNTIL ORDER IS COMPLETED !!") print("\n\n") else: print("INVALID INPUT ! PLEASE TRY AGAIN !!") bill = generateBillandSave(int(id), empid, pointsredeem, cur) print("BILL IS :") print(bill) print("\n") while (True): #PRINTING ORDER print( "ENTER 'print' to PRINT THE ORDER , 'next'/'done' to COMPLETE THE ORDER" ) ch = input() ch = ch.lower() if ch in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'q', 'm' ]: if ch == 'vm': showHalfMenu(cur) elif ch == 'vo': viewOrder() elif ch == 'create': create.createCustomerAccount(cur) print("\n\n") elif ch == 'last': print("ORDER CONFIRMED ! CANNOT BE CHANGED !!") print("\n\n") elif ch == 'done': break elif ch == 'cancel': print("ORDER COMPLETED SUCCESSFULLY !!") print("ORDER CANNOT BE CANCELLED ! RETURN BACK !!") return ch elif ch == 'next': print("ORDER COMPLETED SUCCESSFULLY !!") return ch elif ch == 'print': printBill(bill) print() break else: return ch else: print("ORDER COMPLETED SUCCESSFULLY !!") print("INVALID INPUT ! PLEASE TRY AGAIN !!") while (True): #GOING NEXT m = """ ENTER : next =======> NEXT ORDER q =======> GO BACK m =======> MAIN MENU """ print(m) ch = input() ch = ch.lower() if ch in [ 'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print', 'next', 'q', 'm' ]: if ch == 'vm': showHalfMenu(cur) elif ch == 'vo': viewOrder() elif ch == 'create': create.createCustomerAccount(cur) print("\n\n") elif ch == 'last': print("ORDER CONFIRMED ! CANNOT BE CHANGED !!") print("\n\n") elif ch == 'done': return 'q' elif ch == 'cancel': return 'q' elif ch == 'next': return ch else: return ch else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def createPizza(cur):#TESTED #CREATES PIZZA BY MANAGER AND ADMIN while(True): name,price_s,price_m,price_l,shortcut,type,details = '','','','','','','' cur.execute('select name,shortcut from menu') res = cur.fetchall() lonm = [] loshrt =[] for tup in res: lonm.append(tup[0].upper()) loshrt.append(tup[1].lower()) while(True): name = input("ENTER PIZZA NAME :") name = name.upper() chk = valid.validPizzaNameandDetails(name) if chk: if len(name)>=30 : print("NAME TOO LARGE ! SHOULD BE UNDER 30 CHARATERS !!") else: if name not in lonm: break else: print("NAME ALREADY EXISTS ! PLEASE TRY AGAIN !!") else: print("INVALID NAME ! SHOULD CONTAINS ONLY LETTER,DIGITS,SPACES,'.','-',',' ") print("PLEASE TRY AGAIN !!") while(True): lis = input("ENTER PRICES FOR SMALL,MEDIUM,LARGE FOLLOWING WITH A SPACE : ") lis = lis.split() if len(lis) !=3: print("SHOULD BE EXACTLY 3 PARAMETERS ! PLEASE TRY AGAIN !!") else: a,b,c = lis if valid.validNumber(a) and valid.validNumber(b) and valid.validNumber(c): price_s, price_m, price_l = int(a), int(b), int(c) break else: print("INVALID NUMBER ! PLEASE TRY AGAIN !!") while(True): shortcut = input("ENTER SHORTCUT : ") shortcut = shortcut.lower() if len(shortcut) > 9: print("SHORTCUT TOO LARGE ! PLEASE TRY AGAIN !!") else: if shortcut not in loshrt: #print(loshrt) break else: print("SHORTCUT ALREADY EXISTS") while(True): type = input("ENTER TYPE AS VEG/NON-VEG OR V/N 0R 1/2") type = type.upper() if type in ["VEG","NON-VEG","N","V","1","2"]: if type == "1" or type == "V": type = "VEG" elif type == '2' or type == 'N': type= "NON-VEG" break else: print("INVALID INPUT ! PLEASE TRY AGAIN !!") while(True): details = input("ENTER DETAILS : ") chk = valid.validPizzaNameandDetails(details) if not chk: print("DETAILS SHOULD BE ONLY CHARACTERS, NUMBERS AND SPACES") print("INVALID DETAIL ! PLEASE TRY AGAIN!!") else: break cur.execute('select max(prid) from menu') res = cur.fetchall() prid = res[0][0] + 1 cur.execute('INSERT INTO MENU(prid,name,price_s,price_m,price_l,shortcut,type,details) VALUES(:1,:2,:3,:4,:5,:6,:7,:8)',(prid,name,price_s,price_m,price_l,shortcut,type, details)) cur.execute('commit') print("PIZZA CREATED SUCCESSFULLY !") msgoption = """ ENTER : r =======> RETRY d =======> DISPLAY q =======> GO BACK m =======> GO TO MAIN MENU """ while(True): ch = input(msgoption) ch = ch.lower() if ch in ['r','d','q','m']: if ch == 'd': view.viewMenu(prid, cur) while(True): msg = """ ENTER : q =======> GO BACK m =======> GO TO MAIN MENU """ c = input(msg) c = c.lower() if c in ['q','m']: return c else: print("INVALID INPUT ! PLEASE TRY AGAIN !!") elif ch == 'r': print("RETRY...") break else: return ch else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def saleByEmployeeParticularMonth(self): cur = self._cur cur.execute("select empid from employees") res = cur.fetchall() loempid = [] months = [ ("1", "JANUARY", "JAN"), ("2", "FEBRUARY", "FEB"), ("3", "MARCH", "MAR"), ("4", "APRIL", "APR"), ("5", "MAY", "MAY"), ("6", "JUNE", "JUN"), ("7", "JULY", "JUL"), ("8", "AUGUST", "AUG"), ("9", "SEPTEMBER", "SEP"), ("10", "OCTOBER", "OCT"), ("11", "NOVEMBER", "NOV"), ("12", "DECEMBER", "DEC"), ] for i in res: loempid.append(str(i[0])) while (True): print("ENTER MONTH NUMBER or MONTH NAME : ") mon = input().upper() chk = False for i in months: if mon in i: chk = True mon = i[0] break if not chk: print("INVALID MONTH ! PLEASE TRY AGAIN !!") else: empid = input("ENTER EMPLOYEE ID : ") chk2 = valid.validNumber(empid) if chk2: if empid in loempid: print("\n\n") view.viewSaleMonthEmployee(mon, empid, cur) else: print( "EMPLOYEE ID DOES NOT EXIST ! PLEASE TRY AGAIN !!") else: print("INVALID EMPLOYEE ID ! PLEASE TRY AGAIN !!") while (True): msg = """ EMPLOYEE SALES ON A PARTICULAR MONTH press : r =======> RETRY q =======> GO BACK m =======> GO TO MAIN MENU """ opt = input(msg) opt = opt.lower() if opt in ['q', 'm']: return opt elif opt == 'r': print("RETRY....") break else: print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def empLogin(cur): global welcome chance = 3 while (True): print(line, "\nWELCOME EMPLOYEE") empid = input("PLEASE ENTER YOUR ID : ") pwd = input("PLEASE ENTER YOUR PASSWORD : \n") chk = valid.validNumber(empid) if chk: cur.execute( "select status,locks,designation,password,name from EMPLOYEES where EMPID='1'", (empid, )) res = cur.fetchall() if len(res) == 0: print("EMPLOYEE ID DOES NOT EXIST ! PLEASE TRY AGAIN !! \n\n") else: res = res[0] if res[0] == 'INACTIVE': print( "YOU ARE NO LONGER AN EMPLOYEE ! \n ACCESS DENIED \n\n!!" ) else: if res[1] == 'LOCKED': print("YOUR ACCOUNT IS LOCKED !") if res[2] == 'CASHIER': print("PLEASE CONTACT YOUR MANAGER OR ADMIN !! ") print("ACCESS DENIED!!!\n\n") else: print("PLEASE CONTACT YOUR ADMIN !") print("ACCESS DENIED!!!\n\n") else: #PASSWORD CHECKING start = '' redirect = '' if pwd == res[3]: print(line, "\n", "WELCOME ", res[4].upper()) if res[2] == 'CASHIER': start = "1" cashier = employee.Cashier(empid, cur) redirect = menu.menuCashier(cashier) elif res[2] == 'MANAGER': start = "2" manager = employee.Manager(empid, cur) redirect = menu.menuManager(manager) else: start = "3" admin = employee.Admin(empid, cur) redirect = menu.menuAdmin(admin) path = "menu_" + start result = '' while (result != 'x'): print("\n", line, "\n") result = getattr(redirect, path)() if result == 'q': path = path[:-1] elif result == 'm': path = "menu_" + start else: path = path + result return result else: print( "INCORRECT ID OR PASSWORD ! PLEASE TRY AGAIN !!\n" ) chance = chance - 1 if res[2] in ['CASHIER', 'MANAGER']: if chance <= 0: change.changeEmployeeLockLogin(empid, cur) print( "DUE TO 3 CONSECUTIVE FAILED LOGIN ATTEMPT ! \nYOUR ACCOUNT HAS BEEN LOCKED !!\n\n" ) else: print("YOU HAVE ONLY ", chance, " LEFT !!\n\n") continue else: if chance <= 0: print( "YOU HAVE TRIED YOU MAXIMUM LIMIT FOR NOW !" ) print("PLEASE TRY AFTER SOME TIME !! \n\n") else: continue else: print("INVALID INPUT ! PLEASE TRY AGAIN !!\n\n") while (True): msg = """ press : r =======> RETRY x =======> EXIT """ ch = input(msg) ch = ch.lower() if ch == 'r': break elif ch == 'x': return ch else: print("INVALID INPUT ! PLEASE TRY AGAIN !!\n")