def save_user(self,full_name = None, last_name = None, username = None, password = None, email = None, state = None, phone = None, type_user = None,subsidiary = None,address=None,description=None): """Saves new user to database. returns None on 'user with that username already exists' Parameters: full_name: Name user last_name: Last name user username: username by ces password: key user email: email user state: state of user - ENABLE - DISABLE date_user: date of creation phone: phone user type_user: rol user - ADMIN - GUESS --- Return: True: wheather insert a new User is insert database False: wheather no insert in database """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.get_by_username(username)[0]: raise Exception("El nombre de usuario <b>"+username+"</b> ya existe") self.response= _cnx.no_single_query("INSERT INTO usuarios (nombrecompletousuario,apellidosusuario,usuario,contraseniausuario,correousuario,estadousuario,telefonousuario,roldeusuario,codigosucursal,direccionusuario,descripcionusuario) "+ "VALUES ('"+full_name+"','"+last_name+"','"+username+"','"+password+"','"+email+"','"+state+"','"+phone+"',(select idrol from roles where roles.nombrerol='"+type_user+"' and codigosucursal= '"+subsidiary+"'),'"+subsidiary+"','"+address+"','"+description+"')") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"El usuario <b>"+full_name+"</b>, con nombre de usuario <b>"+username+"</b> ha sido creado" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_order(self,cedulacliente=None, responsable=None, estado=None, entrega=None, observaciones=None, totalapagar=None, formadepago=None, recepcion=None, numeroorden=None, placa=None, numero_importacion=None, marca=None, linea=None, modelo=None, clase_de_vehiculo=None, tipo_carroceria=None, combustible=None, color=None, cilindraje=None, capacidad=None, sucursal=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.seek_NumOrder(numeroorden)[0]: raise Exception("La Orden de Servicio "+numeroorden+"ya existe") self.response= _cnx.no_single_query("INSERT INTO ordendetrabajo("+ "cedulacliente, responsable, estado, observaciones, "+ "totalapagar, formadepago, recepcion, numeroorden, placa, numero_importacion, "+ "marca, linea, modelo, clase_de_vehiculo, tipo_carroceria, combustible, "+ "color, cilindraje, capacidad,codigosucursal)"+ "VALUES ('"+cedulacliente+"', '"+responsable+"', '"+estado+"', '"+observaciones+"', "+ "'"+totalapagar+"', '"+formadepago+"', '"+recepcion+"', '"+numeroorden+"', '"+placa+"', '"+numero_importacion+"', "+ "'"+marca+"', '"+linea+"', '"+modelo+"', '"+clase_de_vehiculo+"', '"+tipo_carroceria+"', '"+combustible+"', "+ "'"+color+"', '"+cilindraje+"', '"+capacidad+"', '"+str(sucursal)+"');") _cnx.commit() if self.debug: print "Insert (OK!)" return True, "La orden <b>'"+numeroorden+"'</b> ha sido <b>Guardada</b> con exito <br/> <b><a href='/setorderservice'>Ver lista</a></b> " except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def update_user(self,identifier=None,full_name = None, last_name = None, username = None, password = None, email = None, state = None, phone = None, type_user = None,address=None,description=None): """Saves new user to database. returns None on 'user with that username already exists' Parameters: full_name: Name user last_name: Last name user username: username by ces password: key user email: email user state: state of user - ENABLE - DISABLE date_user: date of creation phone: phone user type_user: rol user - ADMIN - GUESS --- Return: True: wheather insert a new User is insert database False: wheather no insert in database """ if self.debug: print "Connect to database" _cnx= Connection() try: if not self.get_by_identifier(identifier)[0]: return False,"El nombre de usuario <b>"+username+"</b> no existe no se puede actualizar, comuniquese con el administrador" if password: self.response= _cnx.no_single_query("UPDATE usuarios SET nombrecompletousuario='"+full_name+"',apellidosusuario ='"+last_name+"',usuario='"+username+"',contraseniausuario='"+password+"',correousuario='"+email+"',estadousuario='"+state+"',telefonousuario='"+phone+"',roldeusuario='"+type_user+"',direccionusuario='"+address+"',descripcionusuario='"+description+"' where idusuario= '"+identifier+"' ") else: self.response= _cnx.no_single_query("UPDATE usuarios SET nombrecompletousuario='"+full_name+"',apellidosusuario ='"+last_name+"',usuario='"+username+"',correousuario='"+email+"',estadousuario='"+state+"',telefonousuario='"+phone+"',roldeusuario='"+type_user+"',direccionusuario='"+address+"',descripcionusuario='"+description+"' where idusuario= '"+identifier+"' ") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"El usuario <b>"+full_name+"</b>, con nombre de usuario <b>"+username+"</b> ha sido actualizado <br> <a href='/edituser'>Ver lista</a>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def update_style(self,codigosucursal =None,theme= None, size = None, font=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: self.response= _cnx.no_single_query("UPDATE sucursal set configuracion = '{\"tema\":\""+theme+"\",\"tamanio\":\""+size+"\",\"fuente\":\""+font+"\"}' where codigosucursal = '"+str(codigosucursal)+"' ") _cnx.commit() if self.debug: print "Update (OK!)" return True,"Todo a ido de maravilla, tu pagina se va actulizar para que veas los cambios." except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, " %s" % (exceptionValue)
def delete_inventory(self,codigo_inventario =None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try delete inventory "+str(codigo_inventario)+" " self.response= _cnx.no_single_query("DELETE from inventario where codigo_inventario='"+str(codigo_inventario)+"'") _cnx.commit() if self.debug: print "DELETED (OK!)" return True,"El inventario ha sido actualizado." except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue)
def update_quantity_inventory(self,codigo_inventario = None,cantidad= None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try update inventory "+codigo_inventario+"" print "UPDATE inventario set cantidad = '"+cantidad+"' where codigoinventario = '"+str(codigo_inventario)+"'" self.response= _cnx.no_single_query("UPDATE inventario set cantidad = '"+cantidad+"' where codigoinventario = '"+str(codigo_inventario)+"'") _cnx.commit() if self.debug: print "Update (OK!)" return True,"El inventario ha sido actualizado." except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue)
def delete_role(self,idrol =None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try delete rol: "+str(idrol)+" " self.response= _cnx.no_single_query("DELETE FROM ROLES WHERE idrol='"+str(idrol)+"'") _cnx.commit() if self.debug: print "DELETED (OK!)" return True except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
def delete_vehicle(self,codigo_carro =None,): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try delete car "+str(codigo_carro)+" " self.response= _cnx.no_single_query("DELETE from vehiculo where codigovehiculo='"+str(codigo_carro)+"'") _cnx.commit() if self.debug: print "DELETED (OK!)" return True except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
def delete_subsidiary(self,codigosucursal =None,): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try delete subsidiary "+str(codigosucursal)+" " self.response= _cnx.no_single_query("DELETE from sucursal where codigosucursal='"+str(codigosucursal)+"'") _cnx.commit() if self.debug: print "DELETED (OK!)" return True except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
def assign_order(self,codigoorden=None,numeroorden=None,mecanico=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if not self.seek_NumOrder(numeroorden)[0]: raise Exception("La Orden de Servicio "+numeroorden+" NO existe") self.response= _cnx.no_single_query("UPDATE ordendetrabajo SET responsable = '"+mecanico+"' WHERE codigoorden= '"+codigoorden+"' AND numeroorden = '"+numeroorden+"' ") _cnx.commit() if self.debug: print "Update (OK!)" return True, "Orden Asignada Exitosamente" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, " %s" % (exceptionValue)
def save_offer(self,codigovehiculo=None, codigorepuesto=None, tipooferta=None, descripcionoferta=None, fechaoferta=None, valoroferta=None, fechainicio=None, fechafinal=None, uuid=None,estado=None,sucursal=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.exist_offer(codigovehiculo,codigorepuesto,tipooferta,valoroferta): raise Exception("Esta oferta ya existe") self.response= _cnx.no_single_query("INSERT INTO ofertas(codigovehiculo, codigorepuesto, tipooferta, descripcionoferta,fechaoferta, valoroferta, fechainicio, fechafinal,uuid,estado,codigosucursal) VALUES ('"+codigovehiculo+"','"+codigorepuesto+"','"+tipooferta+"','"+descripcionoferta+"','"+fechaoferta+"','"+valoroferta+"','"+fechainicio+"','"+fechafinal+"','"+uuid+"','"+estado+"','"+sucursal+"')") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"<center>La oferta <b>"+uuid+"</b> se ha creado con <b>éxito</b><br><a href='/listoffers'>Ver en la lista </a></center>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_quotation(self,numerocotizacion=None,fecha=None,articulos=None,valorcotizacion=None,codigosucursal=None,codigocliente=None,imagenqr=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.seek_quotation(numerocotizacion)[0]: raise Exception("This quotation= "+numerocotizacion+" is already") self.response= _cnx.no_single_query("INSERT INTO cotizacion ( numerocotizacion, fecha, articulos,valorcotizacion, codigosucursal, codigocliente, imagenqr ) VALUES ( '"+numerocotizacion+"', '"+fecha+"', '"+articulos+"',"+valorcotizacion+", "+str(codigosucursal)+", "+codigocliente+", '"+imagenqr+"' )") _cnx.commit() if self.debug: print "Insert (OK!)" return True, "Cotizacion <b>Guardada</b> <br/> <a href='/seequotations'>Ver lista</a>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def update_offer(self,codigooferta=None,codigovehiculo=None, codigorepuesto=None, tipooferta=None, descripcionoferta=None,valoroferta=None, fechainicio=None, fechafinal=None,estado=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if not self.exist_offerbyId(codigooferta): raise Exception("Esta oferta no existe, no se puede actualizar") self.response= _cnx.no_single_query("UPDATE ofertas set codigovehiculo='"+codigovehiculo+"',codigorepuesto='"+codigorepuesto+"',tipooferta='"+tipooferta+"',descripcionoferta='"+descripcionoferta+"',valoroferta='"+valoroferta+"',fechainicio='"+fechainicio+"',fechafinal='"+fechafinal+"',estado='"+estado+"' WHERE codigooferta='"+codigooferta+"' ") _cnx.commit() if self.debug: print "update (OK!)" return True,"La oferta ha sido actualizada con éxito." except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def update_order(self,numeroorden=None,codigoorden=None,responsable=None,estado=None,observaciones=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if not self.seek_NumOrder(numeroorden)[0]: return False,"La orden de trabajo que desea actualizar no existe comuniquese con el administrador." self.response= _cnx.no_single_query("UPDATE ordendetrabajo set responsable='"+responsable+"',estado='"+estado+"',observaciones='"+observaciones+"' WHERE codigoorden='"+codigoorden+"' ") _cnx.commit() if self.debug: print "update (OK!)" return True, "La orden <b>'"+numeroorden+"'</b> ha sido <b>Actualizada</b> con exito <br/> <b><a href='/setorderservice'>Ver lista</a></b> " except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_role(self,namerol=None,state=None,subsidiary=None,properties=None,description=None,roleowner=None): """Create a new rol """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.exists(namerol,subsidiary): return False, "El perfil de usuario <b>"+namerol+"</b> que intenta crear ya existe" self.response= _cnx.no_single_query("INSERT INTO ROLES (NOMBREROL,ESTADOROL,CODIGOSUCURSAL,PROPIEDADESROL,DESCRIPCIONROL,PROPIETARIOROL) VALUES ('"+namerol+"','"+state+"',(select codigosucursal from sucursal where sucursal.nombre='"+subsidiary+"'),'"+properties+"','"+description+"','"+roleowner+"')"); _cnx.commit() if self.debug: print "Insert (OK!)" return True, "El perfil de usuario <b>"+namerol+"</b> se guardo con exito" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def state_role(self, identifier,rol_name,rol_state): """Set a state indicating whether the specified role is ENABLED or DISABLED state. """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try update role "+rol_name+" with state "+rol_state+" " self.response= _cnx.no_single_query("UPDATE ROLE SET ESTADOROL = '"+rol_state+"' WHERE IDROL="+str(identifier)+" and NOMBREROL= '"+role_name+"'") _cnx.commit() if self.debug: print "Update (OK!)" return True except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
def update_role(self,idrol=None,namerol=None,subsidiary=None,state=None,properties=None,description=None,roleowner=None): """Create a new rol """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.exists(namerol,subsidiary): self.response= _cnx.no_single_query("UPDATE ROLES SET NOMBREROL='"+namerol+"' ,ESTADOROL= '"+state+"',PROPIEDADESROL='"+properties+"',DESCRIPCIONROL='"+description+"',PROPIETARIOROL='"+roleowner+"' WHERE idrol='"+str(idrol)+"' "); _cnx.commit() if self.debug: print "update (OK!)" return True, "La actualizacion de grupo <b>"+namerol+"</b> se se actualizo con exito<br/> <a href='/editrole'>Ver lista</a>." else: return False, "Este rol no existe, comuniquese con el Administrador." except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, " %s" % (exceptionValue)
def update_vehicle(self,codigo_carro = None,marca = None,linea = None,modelo = None,cilindraje = None, numero_importacion = None,clase_de_vehiculo = None,tipo_carroceria = None,combustible = None, color = None,capacidad = None,precio_base = None,estado = None,descripcion = None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "actualizando vehiculo con id="+str(codigo_carro)+" <b>"+marca+"</b> linea <b>"+linea+"</b> y modelo <b>"+modelo+"</b>" self.response= _cnx.no_single_query("Update vehiculo set marca ='"+marca+"',linea ='"+linea+"',modelo='"+modelo+"' ,cilindraje='"+cilindraje+"',numero_importacion ='"+numero_importacion+"',clase_de_vehiculo='"+clase_de_vehiculo+"',tipo_carroceria ='"+tipo_carroceria+"',combustible ='"+combustible+"',color ='"+color+"',capacidad ='"+capacidad+"',precio_base ='"+precio_base+"',estado ='"+estado+"',descripcion ='"+descripcion+"' where codigovehiculo = '"+str(codigo_carro)+"'") _cnx.commit() if self.debug: print "Update (OK!)" return True,"El vehiculo con marca <b>"+marca+"</b> linea <b>"+linea+"</b> y modelo <b>"+modelo+"</b> se actualizo<br> <b><a href='/editvehicle' >Ver lista</a></b>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_inventory(self,cantidad= None,fecha= None, codigosucursal = None,codigocarro = None,codigorepuesto = None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: # if self.seek_inventory_byId(codigocarro)[0]: # return True,"El articulo <b>NO</b> ha sido agregado ya existe en el inventario actualiza solo la cantidad de este." self.response= _cnx.no_single_query("INSERT INTO inventario (cantidad,fecha,codigosucursal,codigocarro,codigorepuesto)"+ " VALUES ('"+cantidad+"','"+fecha+"','"+codigosucursal+"','"+codigocarro+"','"+codigorepuesto+"')") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"El articulo ha sido agregado al inventario con <b>éxito</b>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue)
def save_message(self,idemisor = None,idreceptor = None,mensaje = None,estado = None,fecha = None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: print "INSERT INTO mensajes(idemisor, idreceptor, mensaje, estado, fecha) VALUES ('"+idemisor+"','"+idreceptor+"','"+mensaje+"','"+estado+"','"+fecha+"')" return self.response= _cnx.no_single_query("INSERT INTO mensajes(idemisor, idreceptor, mensaje, estado, fecha)"+ "VALUES ('"+idemisor+"','"+idreceptor+"','"+mensaje+"','"+estado+"','"+fecha+"')") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"Su mensaje ha sido enviado" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_subsidiary(self,nombre =None,direccion =None, descripcion =None, telefono =None, estado =None, tipo_sucursal =None, contacto =None, coordenadas =None,uuid= None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.exist_subsidiary(nombre): raise Exception("La sucursal "+nombre+" ya existe") self.response= _cnx.no_single_query("INSERT INTO sucursal (nombre,direccion,descripcion,telefono,estado,tiposucursal,contacto,coordenadas,uuid,configuracion)"+ " VALUES ('"+nombre+"','"+direccion+"','"+descripcion+ "','"+telefono+"','"+estado+"','"+tipo_sucursal+"','"+contacto+"','"+coordenadas+"','"+uuid+"','{\"tema\":\"default\"}')") _cnx.commit() if self.debug: print "Insert (OK!)" return True,"La sucursal <b>"+nombre+"</b> se ha creado con exito " except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, " %s" % (exceptionValue)
def update_subsidiary(self,codigosucursal =None,nombre =None,direccion =None, descripcion =None, telefono =None, estado =None, tipo_sucursal =None, contacto =None, coordenadas =None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try update subsidiary "+nombre+" with state "+str(codigosucursal)+" > "+coordenadas+" > "+contacto+" " self.response= _cnx.no_single_query("UPDATE sucursal set nombre = '"+nombre+"',direccion = '"+direccion+ "',descripcion = '"+descripcion+"',telefono = '"+telefono+"',estado = '"+estado+ "',tiposucursal = '"+tipo_sucursal+"',contacto = '"+contacto+"', coordenadas = '"+coordenadas+ "' where codigosucursal = '"+str(codigosucursal)+"'") _cnx.commit() if self.debug: print "Update (OK!)" return True,"La sucursal <b>"+nombre+"</b> se ha actualizado con exito " except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, " %s" % (exceptionValue)
def save_vehicle(self,marca = None,linea = None,modelo = None,cilindraje = None, numero_importacion = None,clase_de_vehiculo = None,tipo_carroceria = None,combustible = None, color = None,capacidad = None,precio_base = None,estado = None,descripcion = None,uuidpath=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.exist_vehicle(marca,linea,modelo): raise Exception("El vehiculo con marca <b>"+marca+"</b> linea <b>"+linea+"</b> y modelo <b>"+modelo+"</b> ya exste") self.response= _cnx.no_single_query("INSERT INTO vehiculo (marca ,linea ,modelo ,cilindraje,numero_importacion ,clase_de_vehiculo ,tipo_carroceria ,combustible ,color ,capacidad ,precio_base ,estado ,descripcion,imagenes) VALUES ('"+marca+"','"+linea+"','"+modelo+"','"+cilindraje+"','"+numero_importacion+"','"+clase_de_vehiculo+"','"+tipo_carroceria+"','"+combustible+"','"+color+"','"+capacidad+"','"+precio_base+"','"+estado+"','"+descripcion+"', '"+uuidpath+"')"); _cnx.commit() if self.debug: print "Insert (OK!)" errorstring= "NEW USER CREATED" return True,"El vehiculo con marca <b>"+marca+"</b> linea <b>"+linea+"</b> y modelo <b>"+modelo+"</b> ha sido creado" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue)
def save_sale(self,numeroventa=None,fecha=None,articulos=None,valorventa=None,codigosucursal=None,codigocliente=None,imagenqr=None,vendedor=None): """ """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.seek_quotation(numeroventa)[0]: raise Exception("This quotation= "+numeroventa+" is already") self.response= _cnx.no_single_query("INSERT INTO venta ( numeroventa, fecha, articulos,valorventa, codigosucursal, codigocliente, imagenqr, vendedor ) VALUES ( '"+numeroventa+"', '"+fecha+"', '"+articulos+"',"+valorventa+", "+str(codigosucursal)+", "+codigocliente+", '"+imagenqr+"', '"+vendedor+"' )") _cnx.commit() if self.debug: print "Insert (OK!)" return True, "La venta se ha realizado con exito <br/> <a href='/sales'>Ver lista</a>" except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "NO Insert Error %s" % (exceptionValue) return False, "%s" % (exceptionValue) # sale=Sales(True) # sale.save_quotation("wqewqew","2016-12-2","{1:aajaja}","{1:10}","1929292","18","3","");
def state_user(self,identifier,username,state): """Change user state, the state is ENABLE- DIABLE Parameters: state: State user Return True: wheather insert a new User is insert database False: wheather no insert in database """ if self.debug: print "Connect to database" _cnx= Connection() try: if self.debug: print "try update usuario "+username+" with state "+state+" " self.response= _cnx.no_single_query("UPDATE usuarios set estado = '"+state+"' where idusuario="+str(identifier)+" and usuario= '"+username+"'") _cnx.commit() if self.debug: print "Update (OK!)" return True except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if self.debug: print "No update %s" % (exceptionValue) return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)