コード例 #1
0
def userlogIn():
    view.viewLogIn()
    username = input()
    password = input()
    conn = sqlite3.connect('project2.db')
    cur = conn.cursor()
    data = cur.execute("SELECT username FROM USERS WHERE username = ? AND password = ?", (username, password))
    data = cur.fetchone()
    if data is not None:
        successMessage()
        viewMenu()
        input_ = input()
        if input_ == "a":
            searchCompName()
        if input_ == "b":
            retriveMarketData()
        if input_ == "c":
        	buyStock()
        if input_ == "d":
        	sellStock()
        if input_ == "e":
            portfolio()
    else:
        view.errorMessage()
        userlogIn()
コード例 #2
0
def sellStock():
	view.viewSell()
	conn = sqlite3.connect('project2.db', timeout=10)
  	cur = conn.cursor()

  	input_= str(input("Enter company name: "))
  	LastPrice = get_quote(input_)
  	LastPrice = LastPrice[5]
  	print("The current Price is" + str(LastPrice))
   	view.enterUserAgain()
   	username = input()
   	password = input()
   	wallet = cur.execute("SELECT Balance FROM Portfolio")
   	wallet = cur.fetchone()[0]
   	ORDER_TYPE = ("Sell")
   	Total_cost = LastPrice * shares

   	shares = float(input("enter the amount of shares you would like to sell"))
   	print ("Your total cost is" + str(Total_cost))
   	print("you have sold" + str(shares) + "shares of"+str(input_))
   	if wallet > Total_cost:
    		print("Transaction is successful")
    	else:
    		print("Insufficient Funds")
   	params = ("Buy", shares, Total_cost)
	purchase = cur.execute("INSERT INTO Transactions (ORDER_TYPE, QUANTITY, Total_Cost) VALUES (?,?,?)",(params) )
	new_params = (balance, Total_cost)
	new_balance = cur.execute("UPDATE Portfolio Set Balance = ? + ?",(new_params))
	cur.execute("UPDATE Portfolio Set Balance = ?+?",(new_params))
	Balance_=cur.execute("SELECT Balance FROM Portfolio")
	conn.commit()
	print(Balance_)
	cur.close()
	view.viewMenu()
コード例 #3
0
def portfolio():
    	

	    conn = sqlite3.connect('project2.db')
	    cur = conn.cursor()
	    view.enterUserAgain()
	    username = input()
	    password = input()    
	    data = cur.execute("SELECT *  FROM Portfolio ")
	    data = cur.fetchall()
	    while data is not None:
	    	print(data)
	    	data = cur.fetchall()
	    conn.commit()
	    return view.viewPortfolio()
	    conn.close()
	    view.viewMenu()
コード例 #4
0
 def viewPizzaSingle(self):
     cur = self._cur
     cur.execute("select prid,name,shortcut from menu")
     res = cur.fetchall()
     lot = []
     for i in res:
         x = (str(i[0]), i[1].lower(), i[2])
         lot.append(x)
     while (True):
         choice = input("ENTER PIZZA ID, PIZZA NAME OR SHORTCUT")
         ch1 = choice.lower()
         prid = False
         for tup in lot:
             if ch1 in tup:
                 prid = tup[0]
                 break
         if prid == False:
             print("NO SUCH PIZZA DETAILS FOUND ! PLEASE TRY AGAIN !!")
         else:
             view.viewMenu(prid, self._cur)
         msg = """
         SINGLE PIZZA
         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....")
         else:
             print("INVALID INPUT ! PLEASE TRY AGAIN !!")
コード例 #5
0
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 !!")