Skip to content

Instantly share code, notes, and snippets.

@soyHouston256
Last active November 10, 2020 15:41
Show Gist options
  • Select an option

  • Save soyHouston256/aecc1d84b52d77adc964bbac65b9e658 to your computer and use it in GitHub Desktop.

Select an option

Save soyHouston256/aecc1d84b52d77adc964bbac65b9e658 to your computer and use it in GitHub Desktop.

Revisions

  1. Max Houston Ramirez Martel revised this gist Nov 10, 2020. 1 changed file with 68 additions and 6 deletions.
    74 changes: 68 additions & 6 deletions crud.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    import sys
    clients = ''

    def add_client(client_name):
    @@ -10,6 +11,35 @@ def add_client(client_name):
    print("The client already exist!!")


    def update_client(client_name,name_update):
    global clients

    if client_name.upper() in clients.upper():
    clients = clients.replace(client_name,name_update)
    else:
    print("The client not exist!!")


    def search_client(client_name):
    global clients

    client_list = clients.split(',')
    for client in client_list:
    if client != client_name:
    continue
    else:
    return True


    def delete_client(client_name):
    global clients

    if client_name.upper() in clients.upper():
    clients = clients.replace(client_name+',','')
    else:
    print("The client not exist!!")


    def _add_coma():
    global clients
    clients += ','
    @@ -18,6 +48,18 @@ def list_client():
    global clients
    print(clients)

    def _get_client_name():
    client_name = None
    while not client_name:
    client_name = input("What's client Name? ")
    if client_name == 'exit':
    client_name == None
    break
    if not client_name:
    sys.exit()
    return client_name



    def _print_welcome():
    mesaje ="""
    @@ -27,24 +69,44 @@ def _print_welcome():
    [C] Create Client
    [L] List Client
    [D] Delete Client
    [S] Salir
    [U] Update Client
    [S] Search Client
    [E] Salir
    : """
    option = input(mesaje)
    return option

    if __name__ == "__main__":

    active = True

    while active:

    option = _print_welcome()
    if option == 'L' or option == 'l':
    list_client()

    elif option == 'C' or option == 'c':
    nombre = input("what's his name?: ")
    add_client(nombre)
    name = _get_client_name()
    add_client(name)
    list_client()

    elif option == 'S' or option == 's':
    active = False

    name = _get_client_name()
    found = search_client(name)
    if found:
    print('The client is in the client\'s list')
    else:
    print('The client: {} is not in our client\'s list'.format(name))

    elif option == 'U' or option == 'u':
    name = _get_client_name()
    name_update = input("What's name to update? ")
    update_client(name,name_update)
    list_client()
    elif option == 'D' or option == 'd':
    name = _get_client_name()
    delete_client(name)
    list_client()

    elif option == 'E' or option == 'e':
    active = False
  2. Max Houston Ramirez Martel created this gist Nov 2, 2020.
    50 changes: 50 additions & 0 deletions crud.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    clients = ''

    def add_client(client_name):
    global clients

    if client_name.upper() not in clients.upper():
    clients += client_name
    _add_coma()
    else:
    print("The client already exist!!")


    def _add_coma():
    global clients
    clients += ','

    def list_client():
    global clients
    print(clients)


    def _print_welcome():
    mesaje ="""
    WELCOME TO PLATZI VENTAS
    '*'*50
    What would you lke to do today?
    [C] Create Client
    [L] List Client
    [D] Delete Client
    [S] Salir
    : """
    option = input(mesaje)
    return option

    if __name__ == "__main__":

    active = True
    while active:
    option = _print_welcome()
    if option == 'L' or option == 'l':
    list_client()

    elif option == 'C' or option == 'c':
    nombre = input("what's his name?: ")
    add_client(nombre)
    list_client()

    elif option == 'S' or option == 's':
    active = False