Advertisement
Mushi

principal.py

Dec 6th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. import sys
  2.  
  3. def validaMenuPrincipal(pergunta, inicio, fim):
  4.      while True:
  5.          try:
  6.                valor = int(input(pergunta))
  7.                if inicio <= valor <= fim:
  8.                    return(valor)
  9.          except ValueError:
  10.                print("Valor inválido, favor digitar entre %d e %d" % (inicio, fim))
  11.  
  12. def menu():
  13.      print("""
  14.    Bem-vindo ao Sistema de Vendas
  15. ------------------------------------
  16.    # Cadastro
  17.       01 - Cliente
  18.       02 - Funcionário
  19.       03 - Fornecedor
  20. ------------------------------------
  21.    # Controle de estoque
  22.       04 - Categorias
  23.       05 - Produto
  24. ------------------------------------
  25.    # Relatório de Vendas
  26.       06 - Por Cliente
  27.       07 - Por Vendedor
  28. ------------------------------------
  29.       08 - Aviso de Estoque Baixo
  30.       09 - Controle de Usuários e Acesso
  31. ------------------------------------
  32.   10 - Logoff
  33.   0 - Sair
  34. ------------------------------------
  35.    """)
  36.      return validaMenuPrincipal("Escolha uma opção: ",0,5)
  37.  
  38. def login():
  39.     user = input("Usuário: ")
  40.     password = input("Senha: ")
  41.     if user == "paulo" and password == "123":
  42.         return True
  43.     else:
  44.         print("Usuário inválido!")
  45.  
  46. def logoff():
  47.     return False
  48.  
  49. while True:
  50.     status = login()
  51.     while status == True:
  52.         opcao = menu()
  53.         if opcao == 0:
  54.             sys.exit()
  55.         elif opcao == 1:
  56.             import cliente
  57.             menu_cliente()
  58.             break
  59.         elif opcao == 2:
  60.             import funcionario
  61.             menuFuncionario()
  62.             break
  63.         elif opcao == 3:
  64.             import fornecedor
  65.             menuFornecedor()
  66.             break
  67.         elif opcao == 4:
  68.             import controleEstoque
  69.             menuEstoque()
  70.             break
  71.         elif opcao == 10:
  72.             status = logoff()
  73.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement