Advertisement
Guest User

TRABAJO FINAL AVANCE

a guest
Jun 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.49 KB | None | 0 0
  1. import xlwt
  2. import xlrd
  3. import random
  4. from xlutils.copy import copy
  5. def Datos_dic_dic(f1):
  6.     for i in range(f1):
  7.         Datos[str(int(sheet.cell_value(i+1, 0)))] = {}
  8.         #Para DNI
  9.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 1))] = str(int(sheet.cell_value(i+1, 1)))
  10.         #Para APELLIDOS
  11.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 2))] = str(sheet.cell_value(i+1, 2))
  12.         #Para NOMBRES
  13.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 3))] = str(sheet.cell_value(i+1, 3))
  14.         #Para SALDO
  15.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 4))] = str(int(sheet.cell_value(i+1, 4)))
  16.         #Para ESTADO
  17.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 5))] = str(sheet.cell_value(i+1, 5))
  18.         #Para CONTRASEÑA
  19.         Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 6))] = str(int(sheet.cell_value(i+1, 6)))
  20.     print(Datos)
  21.     return Datos
  22. def Cuentas_mov_dic_dic(g1):
  23.     for i in range(g1//3):
  24.         Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))] = {}
  25.         for j in range(len(movimientos.col_values(0))-1): #PONER LA WBD CON UN IF COMO EL PRIMERO PARA COGER CADA UNO
  26.             Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['CUENTA DESTINO'] = movimientos.col_values(0) #['', 1.0, 1.0, 1.0, 1.0, 2.0]
  27.             Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['MONTO DEPOSITADO'] = movimientos.col_values(1) #['', 1.0, 1.0, 1.0, 1.0, 2.0]
  28.         for k in range(len(movimientos.col_values(2))-1):
  29.             Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['RETIRO'] = movimientos.col_values(2) ##['cuenta', 1.0, 1.0, 1.0, 1.0, 2.0]
  30.     print(Cuentas_mov)
  31.         #COLOCAR UN IF SI EL ELEMENTO DE LA LISTA ESTA VACIO, O SEA SI ES '' SI ES ASÍ ELIMINARLA DE LA LISTA CON REMOVE. etc
  32. def Aperturar_cuenta():
  33.     cuentaran = str(random.randrange(999999))
  34.     print('Por favor ingrese los datos solicitados...')
  35.     print('Su nuevo número de cuenta es: ', cuentaran, end = '')
  36.     print()
  37.     dni = input('DNI: ')
  38.     apellidos = input('Apellidos: ')
  39.     nombres = input('Nombres: ')
  40.     saldo = input('Saldo que abonará a su cuenta: ')
  41.     estado = input('Estado de su cuenta (Bloqueada(B) o Activa(A)): ')
  42.     if estado == 'B':
  43.         estado = 'BLOQUEADA'
  44.     else:
  45.         estado = 'ACTIVA'
  46.     contra = input('Ingrese su nueva contraseña (4 dígitos): ')
  47.     Datos[cuentaran] = {}
  48.     wb_sheet.write(f1+1, 0, cuentaran)
  49.     Datos[cuentaran]['DNI'] = str(dni)
  50.     wb_sheet.write(f1+1, 1, dni)
  51.     Datos[cuentaran]['APELLIDOS'] = str(apellidos)
  52.     wb_sheet.write(f1+1, 2, apellidos)
  53.     Datos[cuentaran]['NOMBRES'] = str(nombres)
  54.     wb_sheet.write(f1+1, 3, nombres)
  55.     Datos[cuentaran]['SALDO'] = str(saldo)
  56.     wb_sheet.write(f1+1, 4, saldo)
  57.     Datos[cuentaran]['ESTADO'] = str(estado)
  58.     wb_sheet.write(f1+1, 5, estado)
  59.     Datos[cuentaran]['CONTRASENA'] = str(contra)
  60.     wb_sheet.write(f1+1, 6, contra)
  61.     wb.save('BaseDatos.xls')
  62.     modificar_variable_global()
  63.     Inicio()
  64. def modificar_variable_global():
  65.     global f1
  66.     f1 = f1+1
  67. def Inicio():
  68.     bienvenida1 = 'BIENVENIDO AL BANCO BRICHE'
  69.     print(bienvenida1.center(58, '~'))
  70.     print('''
  71.       1) Ya tengo una cuenta      2) Aperturar una cuenta
  72.       ''')
  73.     print('Inserte una opción:  ', end= '')
  74.     inicio = int(input())
  75.     print()
  76.     if inicio == 2:
  77.         Aperturar_cuenta()
  78.     else:
  79.         Verificar_datos()
  80. def Menu(numeroveri):
  81.     print('''
  82.       1) Realizar depósito      2) Realizar retiro      3) Bloquear/Desbloquear cuenta
  83.       4) Cerrar cuenta          5) Consultar saldo      6) Movimientos
  84.       ''')
  85.     print('Inserte un número: ', end= '')
  86.     inicio = int(input())
  87.     print()
  88.     if inicio == 1:
  89.         Realizardeposito(numeroveri)
  90. def Verificar_datos():
  91.     print()
  92.     numeroveri = str(input('Inserte su número de cuenta:    '))
  93.     print()
  94.     dniveri = str(input('Inserte DNI:   '))
  95.     if numeroveri in Datos and Datos[numeroveri]['DNI'] == dniveri:
  96.             print('Datos correctos')
  97.             nombre_bienvenida = Datos[numeroveri]['NOMBRES']
  98.             apellido_bienvenida = Datos[numeroveri]['APELLIDOS']
  99.             print(f'Bienvenido {nombre_bienvenida} {apellido_bienvenida}')
  100.             Menu(numeroveri)
  101.     else:
  102.         print('Datos incorrectos')
  103.         regres = input('¿Desea continuar? (SI O NO): ')
  104.         if regres == 'SI':
  105.             Verificar_datos()
  106.         if regres == 'NO':
  107.             print()
  108.             print()
  109.             Inicio()
  110.         while regres != 'SI' or regres != 'NO':
  111.             regres = input('Coloque solamente SI O NO:  ')
  112.             if regres == 'SI':
  113.                 Verificar_datos()
  114.             if regres == 'NO':
  115.                 Inicio()
  116. #def Relizardeposito(numeroveri):
  117.  
  118. file_loc = 'BaseDatos.xls'
  119. Datos = {}
  120. #En este dic esta tod0 lo que es movimientos
  121. # {cuenta1 : {cuenta destino : [], monto depositado : [], retiros hechos : []},
  122. #  cuenta2 : {cuenta destino : [], monto depositado : [], retiros hechos : []}}
  123. Cuentas_mov = {}
  124. workbook = xlrd.open_workbook(file_loc)
  125. sheet = workbook.sheet_by_index(0)
  126. #PARA HOJA MOVIMIENTO MODIFICAR
  127. movimientos = workbook.sheet_by_index(1)
  128. f1 = sheet.nrows - 1
  129. wb = copy(workbook)
  130. g1 = movimientos.ncols
  131. wb_sheet = wb.get_sheet(0)
  132. #PARA HOJA MOVIMIENTOS MODIFICAR
  133. wb_movimientos = wb.get_sheet(1)
  134. Datos_dic_dic(f1)
  135. Cuentas_mov_dic_dic(g1)
  136. Inicio()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement