def on_btnFileBackup_clicked(self, widget): '''GUARDAMOS ESTADO ACTUAL PARA EVITAR PERDIDAS''' print('Cerrando conexión para crear copia.') try: bdname = 'empresa.sqlite' conexion.Conexion.cerrarbbdd(self) endname = 'copia.zip' destino = './.papelera/' if not os.path.exists(destino): os.system('mkdir ' + destino) os.system('chmod 777 ' + destino) copia = zipfile.ZipFile(endname, 'w') copia.write('empresa.sqlite', compress_type=zipfile.ZIP_DEFLATED) copia.close() finalname = 'archivo-borrado.zip' os.rename(endname, finalname) os.system('mv "' + finalname + '" ' + destino) '''RESTAURAMOS ARCHIVO''' os.system('rm ' + bdname) print('bd borrada') backupfilenametorestore = variables.wselectfile.get_filename() print(backupfilenametorestore) os.system('unzip "' + backupfilenametorestore + '" -d .') print('Copia creada satistactoriamente, volviendo a conectar.') conexion.Conexion.abrirbbdd(self) funcionescli.ponerListadoEnGUI() funcioneshab.ponerListadoEnGUI() except Exception as e: print('Error en la restauración')
def on_btnBajaCli_clicked(self, widget): try: model, iter = variables.treeclientes.get_selection().get_selected() # model es el modelo de la tabla # iter es el numero que identifica la fila que marcamos if iter is not None: sdni = model.get_value(iter, 0) funcionescli.bajaCliente(sdni) funcionescli.ponerListadoEnGUI() except Exception as e: print('Detalles: ', e)
def on_excelImport_activate(self, widget): try: # Excel workbook has to be on the main directory and it will automatically import all rows if no error found document = xlrd.open_workbook( "listadoclientes.xls") # Searches for this filename always. clientes = document.sheet_by_index(0) for i in range(1, clientes.nrows + 1): fila = clientes.row_values(i) funcionescli.insertarCliente( (str(fila[0]), str(fila[1]), str(fila[2]), xlrd.xldate.xldate_as_datetime(int(fila[3]), 0).strftime("%d/%m/%Y"))) funcionescli.ponerListadoEnGUI() except Exception as e: print('Detalles: ', e)
def on_btnAltaCli_clicked(self, widget): try: dni = variables.filacli[0].get_text() apel = variables.filacli[1].get_text() nome = variables.filacli[2].get_text() data = variables.filacli[3].get_text() registro = (dni, apel, nome, data) if dni != '' and apel != '' and nome != '': if funcionescli.validoDNI(dni): funcionescli.insertarCliente(registro) funcionescli.ponerListadoEnGUI() else: print('DNI no válido.') else: print('Algún campo está vacío') except Exception as e: print('Detalles: ', e)
def __init__(self): b = Gtk.Builder() b.add_from_file('glades/hotel.glade') self.wmain = b.get_object('wMain') # Widgets self.entdni = b.get_object('entDni') self.entapel = b.get_object('entApel') self.entnome = b.get_object('entNome') self.entdata = b.get_object('entData') variables.filacli = (self.entdni, self.entapel, self.entnome, self.entdata) variables.listclientes = b.get_object('listClientes') variables.treeclientes = b.get_object('treeClientes') variables.lbldnivalidated = b.get_object('lblDniValidated') variables.lnltitlecliente = b.get_object('lblTitleCliente') variables.wcalendar = b.get_object('wCalendar') variables.caldata = b.get_object('calData') variables.listhab = b.get_object('listHabitaciones') variables.treehab = b.get_object('treeHabitaciones') self.entnumhab = b.get_object('entNumeroHab') self.rdsingle = b.get_object('rdSingle') self.rddouble = b.get_object('rdDouble') self.rdfamily = b.get_object('rdFamily') self.entprezohab = b.get_object('entPrecioHab') variables.filahab = (self.entnumhab, (self.rdsingle, self.rddouble, self.rdfamily), self.entprezohab) variables.notebook = b.get_object('notebook') variables.wabout = b.get_object('wAbout') variables.wselectfile = b.get_object('wSelectFile') variables.lblfileselected = b.get_object('lblRestoreFileName') self.resdni = b.get_object('lblReservaDni') self.resapel = b.get_object('lblReservaApellido') self.reshab = b.get_object('cmbReservaHabitaciones') self.resin = b.get_object('entCheckIn') self.resout = b.get_object('entCheckOut') self.resnoches = b.get_object('lblReservaNoches') variables.filares = (self.resdni, self.resapel, self.reshab, self.resin, self.resout, self.resnoches) variables.treeres = b.get_object('treeReservas') variables.listres = b.get_object('listReservas') variables.listhabnum = b.get_object('listHabNum') variables.btnreserva = b.get_object('btnReserva') variables.preview = b.get_object('facturacion') variables.preview.hide() variables.header_preview = ( b.get_object('nombreCliente'), b.get_object('fechaReserva'), b.get_object('numeroReserva'), b.get_object('habitacionReserva'), ) variables.list_preview = ( (b.get_object('concepto1'), b.get_object('cant1'), b.get_object('precio1'), b.get_object('total1')), (b.get_object('concepto2'), b.get_object('cant2'), b.get_object('precio2'), b.get_object('total2')), (b.get_object('concepto3'), b.get_object('cant3'), b.get_object('precio3'), b.get_object('total3')), (b.get_object('concepto4'), b.get_object('cant4'), b.get_object('precio4'), b.get_object('total4')), (b.get_object('concepto5'), b.get_object('cant5'), b.get_object('precio5'), b.get_object('total5')), (b.get_object('concepto6'), b.get_object('cant6'), b.get_object('precio6'), b.get_object('total6')), (b.get_object('concepto7'), b.get_object('cant7'), b.get_object('precio7'), b.get_object('total7')), (b.get_object('concepto8'), b.get_object('cant8'), b.get_object('precio8'), b.get_object('total8')), (b.get_object('concepto9'), b.get_object('cant9'), b.get_object('precio9'), b.get_object('total9')), (b.get_object('concepto10'), b.get_object('cant10'), b.get_object('precio10'), b.get_object('total10')), (b.get_object('concepto11'), b.get_object('cant11'), b.get_object('precio11'), b.get_object('total11')), (b.get_object('concepto12'), b.get_object('cant12'), b.get_object('precio12'), b.get_object('total12')), (b.get_object('concepto13'), b.get_object('cant13'), b.get_object('precio13'), b.get_object('total13')), (b.get_object('concepto14'), b.get_object('cant14'), b.get_object('precio14'), b.get_object('total14')), ) variables.footer_preview = ( b.get_object('base'), b.get_object('iva'), b.get_object('total'), ) variables.treeser = b.get_object('treeServizos') variables.listser = b.get_object('listServizos') variables.rgservicios = (b.get_object('rdAlojamiento'), b.get_object('rdDesayuno'), b.get_object('rdMediaPension')) variables.entcantpersonas = b.get_object('entPersonas') variables.chkparking = b.get_object('chkParking') variables.serconcepto = b.get_object('entConcepto') variables.serprezo = b.get_object('entPrezoSer') variables.wselectprecios = b.get_object('wSetPrecios') variables.precios = ( b.get_object('entPrecioDesayuno'), b.get_object('entPrecioMediaPension'), b.get_object('entPrecioParking'), ) variables.lbldialog = b.get_object('lblDialog') variables.wdialog = b.get_object('wDialog') b.connect_signals(eventos.Eventos()) self.wmain.show() conexion.Conexion().abrirbbdd() funcionescli.ponerListadoEnGUI() funcioneshab.ponerListadoEnGUI() funcionesres.ponerListadoEnGUI()