Example #1
0
    def borrarVehiculo( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
                c = conn.cursor()
                model, iterador = self.tvVehiculos.get_selection().get_selected()
                if iterador == None:
                    Informacion.mensaje( "Debe seleccionar un vehículo para borrar" )
                else:
                    matr = model.get_value( iterador, 0 )
                    marca = model.get_value( iterador, 1 )
                    modelo = model.get_value( iterador, 2 )
                    color = model.get_value( iterador, 4 )

                    dialog = gtk.Dialog( "Confirme borrado", None, 0, ( gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ) )
                    dialog.set_default_size( 500, 300 )
                    label = gtk.Label( "Va a borrar un vehículo:\n\nMatrícula: \t\t" + matr + "\nMarca: \t\t" + marca + "\nModelo: \t\t" + modelo + "\nColor: \t\t" + color + "\n\n¿Está seguro?" )

                    dialog.vbox.pack_start( label, True, True, 0 )
                    dialog.show_all()

                    response = dialog.run()
                    dialog.destroy()
                    if ( response == gtk.RESPONSE_OK ):
                        c.execute( "update vehiculos set estado ='Eliminado' WHERE matricula=?", ( matr, ) )
                        conn.commit()
                        self.listar( widget )
Example #2
0
    def borrarCliente( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
                c = conn.cursor()
                model, iterador = self.tvClientes.get_selection().get_selected()
                if iterador == None:
                    Informacion.mensaje( "Debe seleccionar un cliente para borrar" )
                else:
                    dni = model.get_value( iterador, 0 )
                    nombre = model.get_value( iterador, 1 )
                    apellidos = model.get_value( iterador, 2 )
                    telefono = model.get_value( iterador, 3 )

                    dialog = gtk.Dialog( "Confirme borrado", None, 0, ( gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ) )
                    dialog.set_default_size( 500, 300 )
                    label = gtk.Label( "Va a borrar un cliente:\n\nDNI: \t\t" + dni + "\nNombre: \t" + nombre + "\nApellidos: \t" + apellidos + "\nTeléfono: \t" + telefono + "\n\n¿Esta seguro?" )

                    dialog.vbox.pack_start( label, True, True, 0 )
                    dialog.show_all()

                    response = dialog.run()
                    dialog.destroy()
                    if ( response == gtk.RESPONSE_OK ):
                        c.execute( "UPDATE CLIENTES SET estado = 1 WHERE dni=?", ( dni, ) )
                        conn.commit()
                        self.listar( widget )
Example #3
0
    def ventanaEdit( self, widget ):
        "Edita un proveedores"
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
                c = conn.cursor()
                model, iterador = self.tvProveedores.get_selection().get_selected()
                if iterador == None:
                    Informacion.mensaje( "Debe seleccionar un proveedor para editar" )
                else:
                    cif = model.get_value( iterador, 0 )
                    nombre = model.get_value( iterador, 1 )
                    direccion = model.get_value( iterador, 2 )                    
                    telefono = model.get_value( iterador, 3 )
                    fax = model.get_value( iterador, 4 )                    
                    email = model.get_value( iterador, 5 )
                    contacto = model.get_value(iterador, 6)
                    
                    self.entryProvCIF.set_text( cif )
                    self.entryProvNombre.set_text( nombre )
                    self.entryProvDir.set_text( direccion )
                    self.entryProvTelf.set_text( telefono )
                    self.entryProvFax.set_text( fax )
                    self.entryProvEmail.set_text( email )
                    self.entryProvContacto.set_text( contacto )
                    
                    self.modo = "U"

                    self.ventanaProveedores.show()
Example #4
0
    def borrarProveedor( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
                c = conn.cursor()
                model, iterador = self.tvProveedores.get_selection().get_selected()
                if iterador == None:
                    Informacion.mensaje( "Debe seleccionar un cliente para borrar" )
                else:
                    cif = model.get_value( iterador, 0 )
                    nombre = model.get_value( iterador, 1 )
                    direccion = model.get_value( iterador, 2 )                    

                    dialog = gtk.Dialog( "Confirme borrado", None, 0, ( gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ) )
                    dialog.set_default_size( 500, 300 )
                    label = gtk.Label( "Va a borrar un proveedor:\n\nCIF: \t\t" + cif + "\nNombre: \t" + nombre + "\nDirección: \t" + direccion + "\n\n¿Esta seguro?" )

                    dialog.vbox.pack_start( label, True, True, 0 )
                    dialog.show_all()

                    response = dialog.run()
                    dialog.destroy()
                    if ( response == gtk.RESPONSE_OK ):
                        c.execute( "UPDATE Proveedores SET estado = 1 WHERE cif=?", ( cif, ) )
                        conn.commit()
                        self.listar( widget )
Example #5
0
    def ventanaEdit( self, widget ):
        "Edita un vehiculo"
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
                c = conn.cursor()
                model, iterador = self.tvVehiculos.get_selection().get_selected()
                if iterador == None:
                    Informacion.mensaje( "Debe seleccionar un vehículo para editar" )
                else:
                    matric = model.get_value( iterador, 0 )
                    marca = model.get_value( iterador, 1 )
                    modelo = model.get_value( iterador, 2 )
                    km = model.get_value( iterador, 3 )
                    anno = model.get_value( iterador, 11 )
                    color = model.get_value( iterador, 4 )
                    combus = model.get_value( iterador, 5 )
                    tipo = model.get_value( iterador, 6 )
                    precio = model.get_value( iterador, 7 )

                    self.entryMatric.set_text( matric )
                    self.entryMarca.set_text( marca )
                    self.entryModelo.set_text( modelo )
                    self.ajuste.set_value( float( km ) )
                    self.entryColor.set_text( color )
                    self.comboCombus.set_active( 0 )
                    self.comboTipo.set_active( 0 )
                    self.precioActual.set_text( precio )
                    self.entryYear.set_value( int( anno ) )

                    self.modo = "U"

                    self.ventanaVehiculos.show()
Example #6
0
    def vehiculoCarritoAdd( self, widget ):
        index = self.comboCliente.get_active()
        model = self.comboCliente.get_model()
        self.dniCliente = model[index][0]

        index = self.comboVehiculo.get_active()
        model = self.comboVehiculo.get_model()
        matricula = model[index][0]

        self.tPrecio = float( self.precio.get_text() )
        self.importeFactura += self.tPrecio

        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str
        if ( ( matricula != "" ) | ( self.tPrecio != "" ) ):
            with conn:
                c = conn.cursor()
                sql = "INSERT INTO ventas values(?, ?, ?)"

                c.execute( sql, ( self.numFactura, matricula, self.tPrecio ) )
                conn.commit()

            with conn:
                c = conn.cursor()
                sql2 = "UPDATE vehiculos set estado = 'Vendido' WHERE matricula == ?"
                c.execute( sql2, ( matricula, ) )
                conn.commit()

            with conn:
                c = conn.cursor()
                sql3 = "SELECT * FROM vehiculos WHERE matricula == ?"
                c.execute( sql3, ( matricula, ) )

                for datos in c:
                    self.listaVehiculos.append( [datos[0], datos[1], datos[2], datos[3], datos[4], datos[5], datos[6], self.tPrecio] )

                conn.commit()

            with conn:
                sql = "select matricula, marca, modelo, precioCompra from vistavehiculos where estado = 'Disponible'"
                c.execute( sql )
                self.listaComboVehiculo.clear()
                for datos in c:
                    self.listaComboVehiculo.append( [datos[0], datos[1], datos[2], datos[3]] )
                conn.commit()

            self.precio.set_text( str( 0 ) )
        else:
            Informacion.mensaje( "Todos los campos son obligatorios" )
Example #7
0
    def vigilarPrecioItem( self, widget, data = None ):
        precioIntroducido = float( self.precio.get_text() )
        index = self.comboVehiculo.get_active()
        model = self.comboVehiculo.get_model()
        matricula = model[index][0]

        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        with conn:
            c = conn.cursor()
            sql = "select precioCompra from vistavehiculos where matricula = '" + matricula + "'"
            c.execute( sql )
            for datos in c:
                precioCompra = datos[0]

        if ( precioIntroducido < precioCompra ):
            Informacion.mensaje( "El precio de venta es menor que\nel precio de compra del vehículo\n\n¡¡Se está perdiendo dinero!!\n\nEl precio de compra es: " + str( precioCompra ) )
Example #8
0
    def meterDatosBD( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        try:
            dni = self.entryDNI.get_text()
            nombre = self.entryNombre.get_text()
            apell = self.entryApell.get_text()
            tlf = self.entryTelf.get_text()
            direc = self.entryDirec.get_text()
            mail = self.entryEmail.get_text()

            if( ( dni != "" ) & ( nombre != "" ) & ( apell != "" ) & ( tlf != "" ) & ( direc != "" ) & ( mail != "" ) ):
                with conn:
                    c = conn.cursor()
                    if ( self.modo == "I" ):
                        sql = "INSERT INTO CLIENTES VALUES( ?,?,?,?,?,?,0) "
                        c.execute( sql, ( dni, nombre, apell, tlf, direc, mail ) )
                        conn.commit()
                    else:
                        if( self.modo == "U" ):
                            sql = "UPDATE CLIENTES SET dni = ?, nombre = ?, apellidos = ?, telf = ?, direccion = ?, email = ? WHERE dni = ? "
                            c.execute( sql, ( dni, nombre, apell, tlf, direc, mail, dni ) )
                            conn.commit()
                            self.ventanaClientes.hide()

                    self.listar( widget )
                    self.vaciarCampos()
                    Informacion.mensaje( "Cambios guardados" )


            else:
                Informacion.mensaje( "Todos los datos son obligatorios" )
        except sqlite3.IntegrityError:
            Informacion.mensaje( "El DNI introducido ya esta almacenado" )
Example #9
0
    def comprobarDNI( self, widget, data = None ):

        dni = self.entryDNI.get_text().upper()
        if ( dni != "" and self.modo != 'U' ):
            self.entryDNI.set_text( dni )

            patron = '[0-9]{8}[A-Z]'
            if( re.match( patron, dni ) ):
                numDni = int( dni[0:8] )
                letra = dni[-1]
                nif = 'TRWAGMYFPDXBNJZSQVHLCKE'
                if ( letra == nif[numDni % 23] ):
                    self.imgDNI.set_from_stock( gtk.STOCK_YES, gtk.ICON_SIZE_SMALL_TOOLBAR )
                    conn = sqlite3.connect( 'datos.db' )
                    conn.text_factory = str

                    with conn:
                        c = conn.cursor()
                        sql = "select dni from clientes where dni = ?"
                        c.execute( sql, ( dni, ) )
                        for datos in c:
                            if ( dni == datos[0] ):
                                self.imgDNI.set_from_stock( gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR )
                                Informacion.mensaje( "El DNI introducido ya está almacenado." )
                            else:
                                self.imgDNI.set_from_stock( gtk.STOCK_YES, gtk.ICON_SIZE_SMALL_TOOLBAR )

                else:
                    self.imgDNI.set_from_stock( gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR )
                    Informacion.mensaje( "La letra introducida no se corresponde con el DNI." )
            else:
                self.imgDNI.set_from_stock( gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR )
                Informacion.mensaje( "El DNI introducido no sigue el formato correcto:\n\n12345678A\t(8 cifras y una letra)" )
        else:
            self.imgDNI.clear()
Example #10
0
    def comprobarNIF( self, widget, data = None ):
        nif = self.entryProvCIF.get_text().upper()
        self.entryProvCIF.set_text( nif )
        if ( nif != "" and self.modo != 'U' ):
            imagen = gtk.STOCK_YES

            conn = sqlite3.connect( 'datos.db' )
            conn.text_factory = str
            with conn:
                c = conn.cursor()
                sql = "select cif from proveedores where estado != 1"
                c.execute( sql )
                for datos in c:
                    if ( nif == datos[0] ):
                        imagen = gtk.STOCK_NO

            self.imgNIF.set_from_stock( imagen, gtk.ICON_SIZE_SMALL_TOOLBAR )
            if imagen == gtk.STOCK_NO:
                self.buttonAccionProveedores.set_sensitive( False )
                Informacion.mensaje( "El NIF introducido ya está almacenado." )
            else:
                self.buttonAccionProveedores.set_sensitive( True )
Example #11
0
    def comprobarMatricula( self, widget, data = None ):
        matricula = self.entryMatric.get_text().upper()
        self.entryMatric.set_text( matricula )
        if ( matricula != "" and self.modo != 'U' ):
            imagen = gtk.STOCK_YES

            conn = sqlite3.connect( 'datos.db' )
            conn.text_factory = str
            with conn:
                c = conn.cursor()
                sql = "select matricula from vehiculos where matricula = ?"
                c.execute( sql, ( matricula, ) )
                for datos in c:
                    if ( matricula == datos[0] ):
                        imagen = gtk.STOCK_NO

            self.imgMatric.set_from_stock( imagen, gtk.ICON_SIZE_SMALL_TOOLBAR )
            if imagen == gtk.STOCK_NO:
                self.bInsertar.set_sensitive( False )
                Informacion.mensaje( "La matrícula introducida ya está almacenada." )
            else:
                self.bInsertar.set_sensitive( True )
Example #12
0
    def ventanaEdit( self, widget ):
        "Edita un cliente"
        self.buttonAccionClientes.set_sensitive( True )
        model, iterador = self.tvClientes.get_selection().get_selected()
        if iterador == None:
            Informacion.mensaje( "Debe seleccionar un cliente para editar" )
        else:
            dni = model.get_value( iterador, 0 )
            nombre = model.get_value( iterador, 1 )
            apellidos = model.get_value( iterador, 2 )
            telefono = model.get_value( iterador, 3 )
            direccion = model.get_value( iterador, 4 )
            email = model.get_value( iterador, 5 )

            self.entryDNI.set_text( dni )
            self.entryNombre.set_text( nombre )
            self.entryApell.set_text( apellidos )
            self.entryTelf.set_text( telefono )
            self.entryDirec.set_text( direccion )
            self.entryEmail.set_text( email )

            self.modo = "U"

            self.ventanaClientes.show()
Example #13
0
    def meterDatosBD( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        try:
            matric = self.entryMatric.get_text()
            marca = self.entryMarca.get_text()
            modelo = self.entryModelo.get_text()
            km = self.entryKM.get_value()
            anno = self.entryYear.get_value()
            color = self.entryColor.get_text()
            precio = float( self.precioActual.get_text() )

            index = self.comboCombus.get_active()
            model = self.comboCombus.get_model()
            combus = model[index][0]

            index = self.comboTipo.get_active()
            model = self.comboTipo.get_model()
            tipo = model[index][0]

            if( ( matric != "" ) & ( marca != "" ) & ( modelo != "" ) & ( km != "" ) & ( color != "" ) & ( precio != "" ) ):
                with conn:
                    c = conn.cursor()
                    if ( self.modo == "I" ):
                        sql = "INSERT INTO tempvehiculos VALUES( ?,?,?,?,?,?,?,'Disponible',?, 0, ?) "
                        c.execute( sql, ( matric, marca, modelo, km, color, combus, tipo, precio, anno ) )
                        conn.commit()
                        self.listaVehiculosPedido = self.widgets.get_object( "listCarritoPedido" )
                        self.listaVehiculosPedido.clear()
                        sql = "select * from tempvehiculos"
                        c.execute( sql )
                        for datos in c:
                            self.listaVehiculosPedido.append( [datos[0], datos[1], datos[2], datos[3], datos[4], datos[5], datos[6], datos[8]] )
                    else:
                        if( self.modo == "U" ):
                            sql = "UPDATE VEHICULOS SET matricula = ?, marca = ?, modelo = ?, km = ?, color = ?, combustible = ?, tipo = ?, precio = ?, anno = ? WHERE matricula = ? "
                            c.execute( sql, ( matric, marca, modelo, km, color, combus, tipo, precio, anno, matric ) )
                            conn.commit()
                            self.ventanaVehiculos.hide()
                    self.listar( widget )
                    self.vaciarCampos()
                    Informacion.mensaje( "Cambios guardados" )
            else:
                Informacion.mensaje( "Todos los datos son obligatorios" )
        except sqlite3.IntegrityError:
            Informacion.mensaje( "La matrícula introducida ya esta almacenada" )
Example #14
0
    def meterDatosBD( self, widget ):
        conn = sqlite3.connect( 'datos.db' )
        conn.text_factory = str

        try:
            cif = self.entryProvCIF.get_text()
            nombre = self.entryProvNombre.get_text()
            direccion = self.entryProvDir.get_text()                    
            telefono = self.entryProvTelf.get_text()
            fax = self.entryProvFax.get_text()                    
            email = self.entryProvEmail.get_text()
            contacto = self.entryProvContacto.get_text()
            
            if( ( cif != "" ) & ( nombre != "" ) & ( direccion != "" ) & ( telefono != "" ) & ( fax != "" ) & ( email != "" ) & (contacto != "")):
                with conn:
                    c = conn.cursor()
                    if ( self.modo == "I" ):
                        sql = "INSERT INTO proveedores VALUES( ?,?,?,?,?,?,?,0) "
                        c.execute( sql, ( cif, nombre, direccion, telefono, fax, email, contacto ) )
                        conn.commit()

                    else:
                        if( self.modo == "U" ):
                            sql = "UPDATE proveedores SET cif = ?, nombre = ?, direccion = ?, telefono = ?, fax = ?, email = ?, contacto= ? WHERE cif = ? "
                            c.execute( sql, ( cif, nombre, direccion, telefono, fax, email, contacto, cif ) )
                            conn.commit()
                            self.ventanaProveedores.hide()

                    self.listar( widget )
                    self.vaciarCampos()
                    Informacion.mensaje( "Cambios guardados" )


            else:
                Informacion.mensaje( "Todos los datos son obligatorios" )
        except sqlite3.IntegrityError:
            Informacion.mensaje( "El CIF introducido ya esta almacenado" )