def crear_usuario(self):

        name = (self.nombre.get())
        surname = (self.apellido.get())
        user = (self.usuario.get())
        role = (self.role.get())
        cargo = (self.cargo.get())
        passwd = (self.password.get())

        user_find = Usuario().find_by_username(user)

        if (user_find == None):
            insert = Usuario().add_usuario(name, surname, user, role, cargo, passwd)
            tkinter.messagebox.showinfo("Terranova gestión de usuarios",
                "El usuario " + user + " añadido correctamente!")

            from interfaces.principalAdmin import PrincipalAdmin
            frame = PrincipalAdmin(self.master)
            self.frame.destroy()
        else:
            tkinter.messagebox.showinfo("Terranova gestión de usuarios",
                "El usuario " + user + " ya existe")

            from interfaces.principalAdmin import PrincipalAdmin
            frame = PrincipalAdmin(self.master)
            self.frame.destroy()
    def modificar_usuario(self):

        name = (self.nombre.get())
        surname = (self.apellido.get())
        user = (self.usuario.get())
        role = (self.role.get())
        cargo = (self.cargo.get())

        if user == self.current:
            if (
                user != "Seleciona usuario" and name != ""
                and surname != "" and cargo != ""
            ):
                insert = Usuario().update_user(name, surname, user, role, cargo)
                tkinter.messagebox.showinfo("Terranova gestión de usuarios",
                    "El usuario " + user + " modificado correctamente!")

                from interfaces.principalAdmin import PrincipalAdmin
                frame = PrincipalAdmin(self.master)
                self.frame.destroy()
            else:
                tkinter.messagebox.showinfo("Terranova gestión de usuarios",
                    "Los campos no pueden estar vacios")
        else:
            tkinter.messagebox.showinfo("Terranova gestión de usuarios",
                "El usuario " + user + " no del que esta modificando datos!")
Beispiel #3
0
 def find_user_by_card(self, card):
     user = Usuario()
     r = self.db.cursor.execute(
         'SELECT COUNT(*) FROM Usuario WHERE UsrBarra = ?', (card, ))
     if (r.fetchone()[0] > 0):
         # instancia o usuario e devolve
         r = self.db.cursor.execute(
             'SELECT * FROM Usuario WHERE UsrBarra = ?', (card, ))
         usrdata = r.fetchone()
         user = Usuario(usrdata[0], usrdata[1], usrdata[2], usrdata[3],
                        usrdata[4])
     else:
         r = self.db.cursor.execute(
             'SELECT COUNT(*) FROM Usuario WHERE UsrProvisorio = ?',
             (card, ))
         if (r.fetchone()[0] > 0):
             # instancia o usuario e devolve
             r = self.db.cursor.execute(
                 'SELECT * FROM Usuario WHERE UsrBarra = ?', (card, ))
             usrdata = r.fetchone()
             user = Usuario(usrdata[0], usrdata[1], usrdata[2], usrdata[3],
                            usrdata[4])
     return user
Beispiel #4
0
    def eliminar_usuario(self):

        user = (self.usuario.get())

        self.eliminar_usuario = tkinter.messagebox.askyesno("Terranova sistema de gestión",
            "De verdad quieres eliminar el usuario" + user)

        if self.eliminar_usuario > 0:
            Usuario().delete_user(user)
            tkinter.messagebox.showinfo("Terranova eliminación de usuarios",
                "El usuario " + user + " eliminado correctamente!")
            from interfaces.principalAdmin import PrincipalAdmin
            frame = PrincipalAdmin(self.master)
            self.frame.destroy()

        else:
            pass
Beispiel #5
0
    def __init__(self, master):
        self.master = master
        self.master.title("Terranova | Añadir Usuario")
        width_value = self.master.winfo_screenwidth()
        height_value = self.master.winfo_screenheight()
        self.master.geometry("%dx%d+0+0" % (width_value, height_value))
        self.frame = Frame(self.master)
        self.frame.pack()

        self.usuario = StringVar()

        self.LabelTitle = Label(self.frame, text = "Eliminar Usuario",
                                font = ('arial', 50, 'bold'), bd=20)
        self.LabelTitle.grid(row = 0, column = 0, columnspan = 2, pady = 20)

        self.LoginFrame1 = Frame(self.frame, width=1010, height=300, bd = 20,
                                relief='ridge')
        self.LoginFrame1.grid(row=1, column=0)
        self.LoginFrame2 = Frame(self.frame, width=1000, height=100, bd = 20,
                                relief='ridge')
        self.LoginFrame2.grid(row=2, column=0)

        ######################## Delete User ###################################

        self.LblRole = Label(self.LoginFrame1, text = "Usuario",
                                font = ('arial', 20, 'bold'), bd=5)
        self.LblRole.grid(row = 0, column = 0)
        self.comboRole = ttk.Combobox(self.LoginFrame1, font = ('arial', 20, 'bold'),
            textvariable=self.usuario, state = "readonly")
        my_list = Usuario().find_all()
        self.comboRole['values'] = [user['usuario'] for user in my_list]
        self.comboRole.current(0)
        self.comboRole.grid(row = 0, column = 1)

        ######################### BOTONES ######################################

        self.btnCrear = Button(self.LoginFrame2, text = "Eliminar", width = 17,
                        font =('arial', 20, 'bold'), command = self.eliminar_usuario)
        self.btnCrear.grid(row = 0, column = 0)

        self.btnAtras = Button(self.LoginFrame2, text = "Atras", width = 17,
                        font =('arial', 20, 'bold'), command = self.back_system)
        self.btnAtras.grid(row = 0, column = 1)
    def fill_data(self):

        if self.comboRoleUser.get() != "Seleciona usuario":
            self.nombre.set("")
            self.apellido.set("")
            self.role.set("USER_ROLE")
            self.cargo.set("")
            self.current = self.comboRoleUser.get()

            user_data = Usuario().find_by_username(self.comboRoleUser.get())

            self.LblNombre = Label(self.FormFrame1, text = "Nombre",
                                    font = ('arial', 20, 'bold'), bd=5)
            self.LblNombre.grid(row = 1, column = 0)
            self.TxtNombre = Entry(self.FormFrame1, text = "Nombre",
                        font = ('arial', 20, 'bold'), bd=5, textvariable=self.nombre)
            self.TxtNombre.insert(END, user_data.get("nombre"))
            self.TxtNombre.grid(row = 1, column = 1)



            self.LblApellido = Label(self.FormFrame1, text = "Apellido",
                                    font = ('arial', 20, 'bold'), bd=5)
            self.LblApellido.grid(row = 2, column = 0)
            self.TxtApellido = Entry(self.FormFrame1, text = "Apellido",
                        font = ('arial', 20, 'bold'), bd=5, textvariable=self.apellido)
            self.TxtApellido.insert(END, user_data.get("apellido"))
            self.TxtApellido.grid(row = 2, column = 1)


            self.LblRole = Label(self.FormFrame1, text = "Role",
                                    font = ('arial', 20, 'bold'), bd=5)
            self.LblRole.grid(row = 3, column = 0)
            self.comboRole = ttk.Combobox(self.FormFrame1, font = ('arial', 20, 'bold'),
                textvariable=self.role, state = "readonly")
            self.comboRole['values']= ("USER_ROLE", "ADMIN_ROLE")
            self.comboRole.current(0)
            self.comboRole.set(user_data.get("role"))
            self.comboRole.grid(row = 3, column = 1)


            self.LblCargo = Label(self.FormFrame1, text = "Cargo",
                                    font = ('arial', 20, 'bold'), bd=5)
            self.LblCargo.grid(row = 4, column = 0)
            self.TxtCargo = Entry(self.FormFrame1, text = "Cargo",
                        font = ('arial', 20, 'bold'), bd=5, textvariable=self.cargo)
            self.TxtCargo.insert(END, user_data.get("cargo"))
            self.TxtCargo.grid(row = 4, column = 1)
    def __init__(self, master):
        self.master = master
        self.master.title("Terranova | Añadir Usuario")
        width_value = self.master.winfo_screenwidth()
        height_value = self.master.winfo_screenheight()
        self.master.geometry("%dx%d+0+0" % (width_value, height_value))
        self.frame = Frame(self.master)
        self.frame.pack()

        ################# VAR FORM #############################################
        all_users = Usuario().find_all()
        list_users = [user['usuario'] for user in all_users]

        self.usuario = StringVar()
        self.nombre = StringVar()
        self.apellido = StringVar()
        self.role = StringVar()
        self.cargo = StringVar()
        self.current =  StringVar()

        self.LabelTitle = Label(self.frame, text = "Modificar Usuario",
                                font = ('arial', 50, 'bold'), bd=20)
        self.LabelTitle.grid(row = 0, column = 0, columnspan = 2, pady = 20)

        self.FormFrame1 = Frame(self.frame, width=1010, height=300, bd = 20,
                                relief='ridge')
        self.FormFrame1.grid(row=1, column=0)
        self.FormFrame2 = Frame(self.frame, width=1000, height=100, bd = 20,
                                relief='ridge')
        self.FormFrame2.grid(row=2, column=0)

        ######################## TEXT LOGIN ####################################

        self.LblRole = Label(self.FormFrame1, text = "Usuario",
                                font = ('arial', 20, 'bold'), bd=5)
        self.LblRole.grid(row = 0, column = 0)
        self.comboRoleUser = ttk.Combobox(self.FormFrame1, font = ('arial', 20, 'bold'),
            textvariable=self.usuario, state = "readonly")
        self.comboRoleUser['values'] = list_users
        #self.comboRole.current(0)
        #self.comboRole.bind("<<ComboboxSelected>>", self.fill_data(self.comboRole.get()))
        self.comboRoleUser.set("Seleciona usuario")
        self.comboRoleUser.grid(row = 0, column = 1)

        self.btnGetData = ttk.Button(self.FormFrame1,
                text="Ver datos", command = self.fill_data)
        self.btnGetData.grid(row = 0, column = 2)


        ######################### BOTONES ######################################

        self.btnCrear = Button(self.FormFrame2, text = "Modificar", width = 17,
                        font =('arial', 20, 'bold'), command = self.modificar_usuario)
        self.btnCrear.grid(row = 0, column = 0)

        self.btnReset = Button(self.FormFrame2, text = "Reset", width = 17,
                        font =('arial', 20, 'bold'), command = self.reset)
        self.btnReset.grid(row = 0, column = 1)

        self.btnAtras = Button(self.FormFrame2, text = "Atras", width = 17,
                        font =('arial', 20, 'bold'), command = self.back_system)
        self.btnAtras.grid(row = 0, column = 2)
Beispiel #8
0
 def criar_usuario(self, nome, email, senha):
     #TODO validação de nome e email disponiveis
     usuario = Usuario(nome, self.banco.quantidade_usuarios(), email, senha)
     self.banco.armazenar_usuario(usuario)
     self.usuario_logado = usuario
     return True