Example #1
0
while True:
    try:
        display_output('MENU')
        x = input('Please input command!')
        if x == '1':
            display_output('Login')
            u_input = input('Input customer username! ')
            for i in data_all:
                if u_input == i[0]:
                    while True:
                        z = Customer(i[1][0], i[1][1],0,0)
                        display_output('Customer Menu')
                        d = input('Please Input command!')
                        if d == '1':
                            print('First Name : ', z.getFirstName())
                            print('Last Name : ', z.getLastName())
                            print('All Account')
                            display_account(u_input,0)
                        elif d == '2':
                            display_output('Add Account')
                            x = input('Account Name: ')
                            print('Your Account Name is : {0}'.format(z.newAccount(x,i[-1])))
                        elif d == '3':
                            display_output('Display All Account')
                            display_account(u_input,1)
                        elif d == '4':
                            a_input = int(input('Which Account to Login?'))
                            while True:
                                display_output('Account Menu')
                                x = input('Please input command!')
                                z = Customer(i[1][0],i[1][1],i[-1][a_input-1][0],i[-1][a_input-1][1])
    if action not in ["add", "del", "show"]:
        print("Invalid input.")
        continue

    elif action == "add":
        firstName = input("Please provide the first name of the customer.\n")
        lastName = input("Please provide the last name of the customer.\n")
        address = input("Please provide the address of the customer.\n")

        customer = Customer(firstName, lastName)
        customer.setAddress(address)

        conn = sqlite3.connect('customers.db')
        c = conn.cursor()
        params = (customer.getFirstName(), customer.getLastName(),
                  customer.getAddress())
        c.execute("INSERT INTO customers VALUES (NULL, ?, ?, ?)", params)

        conn.commit()
        conn.close()

        print("Done.\n")

    elif action == "del":

        count = getRowCount()
        if count == 0:
            print("There are no customers in the list.")
        else:
            print("These are your current customers:")