-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (51 loc) · 1.54 KB
/
Copy pathmain.py
File metadata and controls
56 lines (51 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from BD.conexion import DAO
import VISTA.funciones
dao=DAO()
def menuPrincipal():
while True:
print("*** MENU PRINCIPAL ***")
print("1. Listar personas")
print("2. Agregar personas")
print("3. Actualizar personas")
print("4. Eliminar personas")
print("5. Finalizar")
opc=int(input("Ingrese una opción (1-5): "))
if opc<1 or opc>5:
print("Opción inválida")
elif opc==5:
print("Hasta la vista")
dao.cerrarConexion()
break
else:
ejecutarOpcionMenu(opc)
def ejecutarOpcionMenu(opc):
if opc==1:
try:
personas=dao.listarPersonas()
if len(personas) > 0:
VISTA.funciones.listarPersonas(personas)
else:
print("La tabla no tiene personas")
except:
print("Error.... ")
elif opc==2:
persona=VISTA.funciones.leerDatosPersona()
try:
dao.crearPersona(persona)
except:
print("Error.... ")
elif opc == 3:
id = VISTA.funciones.leerIdPersona()
persona=dao.buscarPersona(id)
if persona!= None:
persona=VISTA.funciones.leerDatosNuevosPersona(persona)
dao.actualizarPersona(persona)
else:
print("Persona no Existe")
elif opc==4:
id = VISTA.funciones.leerIdPersona()
if dao.buscarPersona(id)!=None:
dao.eliminarPersona(id)
else:
print("Persona no Existe")
menuPrincipal()