class CrearCuentaUsuario(wx.Frame): def __init__(self, *args, **kw): super(CrearCuentaUsuario, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/crear_cuenta_usuario.xml') self.frame = self.xml.LoadFrame(None, 'CrearCuenta_Frame') self.panel = xrc.XRCCTRL(self.frame, 'CrearCuenta_Panel') self.nombre = xrc.XRCCTRL(self.panel, 'Textctrl_Nombre') self.apellido = xrc.XRCCTRL(self.panel, 'Textctrl_Apellido') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.password = xrc.XRCCTRL(self.panel, 'Textctrl_Password') self.foto = xrc.XRCCTRL(self.panel, 'Filepicker_Foto') self.button_crear = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.crear_usuario, self.button_crear) self.frame.Bind(wx.EVT_BUTTON, self.cerrar_frame, self.button_cancelar) self.user_controller = UserController() self.frame.Show() def crear_usuario(self, evt): nombre = self.nombre.GetValue() apellido = self.apellido.GetValue() username = self.username.GetValue() password = self.password.GetValue() foto = self.foto.GetPath() if foto == "": foto = None if nombre and apellido and username and password: if self.user_controller.buscar_usuario(username) == False: if self.user_controller.create_user(nombre, apellido, username, password, foto): wx.MessageBox('El usuario se creo con exito', 'Information', wx.OK | wx.ICON_INFORMATION) self.limpiar_campos() else: msg = "El nombre de usuario %s" % username + " ya existe ingrese otro diferente" wx.MessageBox(msg, 'Error', wx.OK | wx.ICON_ERROR) self.limpiar_usuario() else: wx.MessageBox( 'Todos los campos excepto la foto deben ser completados', 'Error', wx.OK | wx.ICON_ERROR) def limpiar_usuario(self): self.username.Clear() def limpiar_campos(self): self.nombre.Clear() self.apellido.Clear() self.username.Clear() self.password.Clear() def cerrar_frame(self, evt): self.frame.Close()
class ModificarUsuario(wx.Frame): def __init__(self, frame_father, id_user): super(ModificarUsuario, self).__init__() self.xml = xrc.XmlResource('../View/modificar_cuenta_usuario.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Modificar_Cuenta_Usuario') self.panel = xrc.XRCCTRL(self.frame, 'ModificarCuenta_Panel') self.nombre = xrc.XRCCTRL(self.panel, 'Textctrl_Nombre') self.apellido = xrc.XRCCTRL(self.panel, 'Textctrl_Apellido') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.foto = xrc.XRCCTRL(self.panel, 'Filepicker_Foto') self.id_user = id_user self.frame_father = frame_father self.user_controller = UserController() self.button_modificar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.modificar_usuario, self.button_modificar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_usuario() self.frame.Show() def cargar_datos_usuario(self): usuario = self.user_controller.get_user(self.id_user) self.nombre.SetValue(usuario.nombre) self.apellido.SetValue(usuario.apellido) self.username.SetValue(usuario.nombre_usuario) self.password = usuario.contrasena def modificar_usuario(self, evt): nombre = self.nombre.GetValue() apellido = self.apellido.GetValue() username = self.username.GetValue() foto = self.foto.GetPath() if nombre and apellido and username: data = { 'nombre': nombre, 'apellido': apellido, 'username': username, 'password': self.password, "imagen": foto } if self.user_controller.edit_user(self.id_user, data): wx.MessageBox('El Usuario se modifico exitosamente', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame_father.load_data_listctrl_user() self.cargar_datos_usuario() else: wx.MessageBox('Todos los campos son obligatorios', 'Error', wx.OK | wx.ICON_ERROR) def cancelar(self, evt): self.frame.Close()
def __init__(self): super(LoginFrame, self).__init__() self.res = xrc.XmlResource('../view/login.xrc') self.user_controller = UserController() self.main_menu = None self.inicio_user = None self.frame = self.res.LoadFrame(None, 'LoginFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.username = xrc.XRCCTRL(self.frame, 'text_user') self.password = xrc.XRCCTRL(self.frame, 'text_pass') self.button = xrc.XRCCTRL(self.panel, 'sign_in') self.frame.Bind(wx.EVT_BUTTON, self.validate_user, self.button) self.open = xrc.XRCCTRL(self.panel, 'account') self.frame.Bind(wx.EVT_BUTTON, self.open_register, self.open) self.frame.Show()
def __init__(self, *args, **kw): super(LoginFrame, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/Login.xml') self.frame = self.xml.LoadFrame(None, 'Login_Frame') self.panel = xrc.XRCCTRL(self.frame, 'Login_Panel') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Usuario') self.password = xrc.XRCCTRL(self.panel, 'Textctrl_Contrasena') self.button_ingresar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_ccuenta = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.validate_user, self.button_ingresar) self.frame.Bind(wx.EVT_BUTTON, self.crear_cuenta, self.button_ccuenta) self.user_controller = UserController() self.admin_controller = AdminController() self.frame.Show()
def __init__(self, *args, **kw): super(CrearCuentaUsuario, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/crear_cuenta_usuario.xml') self.frame = self.xml.LoadFrame(None, 'CrearCuenta_Frame') self.panel = xrc.XRCCTRL(self.frame, 'CrearCuenta_Panel') self.nombre = xrc.XRCCTRL(self.panel, 'Textctrl_Nombre') self.apellido = xrc.XRCCTRL(self.panel, 'Textctrl_Apellido') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.password = xrc.XRCCTRL(self.panel, 'Textctrl_Password') self.foto = xrc.XRCCTRL(self.panel, 'Filepicker_Foto') self.button_crear = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.crear_usuario, self.button_crear) self.frame.Bind(wx.EVT_BUTTON, self.cerrar_frame, self.button_cancelar) self.user_controller = UserController() self.frame.Show()
def __init__(self, frame_father): super(AnadirReservaJuego, self).__init__() self.xml = xrc.XmlResource('../View/anadir_reserva_juego.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Anadir_Reserva_Juego') self.panel = xrc.XRCCTRL(self.frame, 'AnadirReserva_Panel') self.id_cliente = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Cliente') self.id_juego = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Juego') self.button_anadir = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame_father = frame_father self.frame.Bind(wx.EVT_BUTTON, self.anadir_reserva, self.button_anadir) self.frame.Bind(wx.EVT_BUTTON, self.cerrar_frame, self.button_cancelar) self.reserva_juego_controller = ReservaJuegoController() self.user_controller = UserController() self.game_controller = GameController() self.frame.Show()
class LoginFrame(wx.Frame): def __init__(self): super(LoginFrame, self).__init__() self.res = xrc.XmlResource('../view/login.xrc') self.user_controller = UserController() self.main_menu = None self.inicio_user = None self.frame = self.res.LoadFrame(None, 'LoginFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.username = xrc.XRCCTRL(self.frame, 'text_user') self.password = xrc.XRCCTRL(self.frame, 'text_pass') self.button = xrc.XRCCTRL(self.panel, 'sign_in') self.frame.Bind(wx.EVT_BUTTON, self.validate_user, self.button) self.open = xrc.XRCCTRL(self.panel, 'account') self.frame.Bind(wx.EVT_BUTTON, self.open_register, self.open) self.frame.Show() def open_register(self, evt): self.register = RegistroFrame() def validate_user(self, evt): username = self.username.GetValue() password = self.password.GetValue() if username and password: if self.user_controller.search_user(username, password): if username == '@gustavo15' and password == 'gustavo12345': self.frame.Close() self.main_menu = InicioFrame() else: self.frame.Close() user = self.user_controller.search_username(username) if user is not False: self.inicio_user = InicioUser(user=user, frame_father=self) else: wx.MessageBox('User is not valid', 'Error', wx.OK | wx.ICON_INFORMATION) else: wx.MessageBox('User does not exist', 'Error', wx.OK | wx.ICON_ERROR) else: wx.MessageBox('Fields not entered', 'Error', wx.OK | wx.ICON_ERROR)
class AnadirReservaJuego(wx.Frame): def __init__(self, frame_father): super(AnadirReservaJuego, self).__init__() self.xml = xrc.XmlResource('../View/anadir_reserva_juego.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Anadir_Reserva_Juego') self.panel = xrc.XRCCTRL(self.frame, 'AnadirReserva_Panel') self.id_cliente = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Cliente') self.id_juego = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Juego') self.button_anadir = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame_father = frame_father self.frame.Bind(wx.EVT_BUTTON, self.anadir_reserva, self.button_anadir) self.frame.Bind(wx.EVT_BUTTON, self.cerrar_frame, self.button_cancelar) self.reserva_juego_controller = ReservaJuegoController() self.user_controller = UserController() self.game_controller = GameController() self.frame.Show() def anadir_reserva(self, evt): id_cliente = self.id_cliente.GetValue() id_juego = self.id_juego.GetValue() if id_cliente and id_juego: if self.user_controller.get_user( id_cliente) != None and self.game_controller.get_game( id_juego) != None: if self.reserva_juego_controller.search_booking( id_cliente, id_juego) == False: if self.reserva_juego_controller.create_booking( id_cliente, id_juego): wx.MessageBox('La reserva se creo con exito', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame_father.load_data_listctrl_juego() self.frame.Close() else: wx.MessageBox( 'Ya existe una reserva con los mismos datos ', 'Error', wx.OK | wx.ICON_ERROR) self.limpiar_campos() else: wx.MessageBox( 'El usuario o el juego no existe en el sistema intente nuevamente', 'Error', wx.OK | wx.ICON_ERROR) else: wx.MessageBox('Todos los campos son obligatorios', 'Error', wx.OK | wx.ICON_ERROR) def limpiar_campos(self): self.id_cliente.Clear() self.id_juego.Clear() def cerrar_frame(self, evt): self.frame.Close()
def __init__(self, *args, **kw): super(ListaUsuario, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/lista_usuarios.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Usuarios') self.panel = xrc.XRCCTRL(self.frame, 'Panel_Usuarios') self.button_anadir_user = xrc.XRCCTRL(self.panel, 'Button_Anadir_Usuario') self.listctrl_usuario = xrc.XRCCTRL(self.panel, 'Listctrl_Usuarios') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.list_users = [] self.user_list = [] self.user_controller = UserController() self.load_columns_listctrl_user() self.load_data_listctrl_user() self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_usuario) self.frame.Bind(wx.EVT_BUTTON, self.anadir_usuario, self.button_anadir_user) self.frame.Show()
def __init__(self, frame_father, id_user): super(EliminarUsuario, self).__init__() self.xml = xrc.XmlResource('../View/eliminar_usuario.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Eliminar_Usuario') self.panel = xrc.XRCCTRL(self.frame, 'Panel_Eliminar_Usuario') self.nombre = xrc.XRCCTRL(self.panel, 'Textctrl_Nombre') self.apellido = xrc.XRCCTRL(self.panel, 'Textctr_Apellido') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.id_user = id_user self.frame_father = frame_father self.user_controller = UserController() self.button_eliminar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.eliminar_usuario, self.button_eliminar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_usuario() self.frame.Show()
def __init__(self, frame_father, id_reserva): super(EliminarReservaSerie, self).__init__() self.xml = xrc.XmlResource('../View/eliminar_reserva_serie.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Eliminar_Reserva') self.panel = xrc.XRCCTRL(self.frame, 'EliminarReserva_Panel') self.id_reserva = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Reserva') self.id_cliente = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Cliente') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.id_serie = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Serie') self.titulo = xrc.XRCCTRL(self.panel, 'Textctrl_titulo_serie') self.id_booking = id_reserva self.frame_father = frame_father self.reserva_serie_controller = ReservaSerieController() self.user_controller = UserController() self.serie_controller = SerieController() self.button_eliminar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.eliminar_reserva, self.button_eliminar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_reserva() self.frame.Show()
def __init__(self, frame_father=None, id_user=None): super(ModificFrame, self).__init__() self.res = xrc.XmlResource('../view/modific.xrc') self.frame = self.res.LoadFrame(None, 'ModificFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioModific') self.user_controller = UserController() self.id_user = id_user self.first_name = xrc.XRCCTRL(self.panel, 'textModFirstName') self.last_name = xrc.XRCCTRL(self.panel, 'textModLastName') self.username = xrc.XRCCTRL(self.panel, 'textModUsername') self.password = xrc.XRCCTRL(self.panel, 'textModPassword') self.button_save = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancel = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.update_user, self.button_save) self.frame.Show() if frame_father is not None: self.frame_father = frame_father if self.id_user is not None: self.load_data_user()
class EliminarUsuario(wx.Frame): def __init__(self, frame_father, id_user): super(EliminarUsuario, self).__init__() self.xml = xrc.XmlResource('../View/eliminar_usuario.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Eliminar_Usuario') self.panel = xrc.XRCCTRL(self.frame, 'Panel_Eliminar_Usuario') self.nombre = xrc.XRCCTRL(self.panel, 'Textctrl_Nombre') self.apellido = xrc.XRCCTRL(self.panel, 'Textctr_Apellido') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.id_user = id_user self.frame_father = frame_father self.user_controller = UserController() self.button_eliminar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.eliminar_usuario, self.button_eliminar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_usuario() self.frame.Show() def cargar_datos_usuario(self): usuario = self.user_controller.get_user(self.id_user) self.nombre.SetValue(usuario.nombre) self.apellido.SetValue(usuario.apellido) self.username.SetValue(usuario.nombre_usuario) def eliminar_usuario(self, evt): if self.user_controller.delete_user(self.id_user): wx.MessageBox('El Usuario se elimino exitosamente', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame_father.load_data_listctrl_user() self.frame.Close() def cancelar(self, evt): self.frame.Close()
class EliminarReservaSerie(wx.Frame): def __init__(self, frame_father, id_reserva): super(EliminarReservaSerie, self).__init__() self.xml = xrc.XmlResource('../View/eliminar_reserva_serie.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Eliminar_Reserva') self.panel = xrc.XRCCTRL(self.frame, 'EliminarReserva_Panel') self.id_reserva = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Reserva') self.id_cliente = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Cliente') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.id_serie = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Serie') self.titulo = xrc.XRCCTRL(self.panel, 'Textctrl_titulo_serie') self.id_booking = id_reserva self.frame_father = frame_father self.reserva_serie_controller = ReservaSerieController() self.user_controller = UserController() self.serie_controller = SerieController() self.button_eliminar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.eliminar_reserva, self.button_eliminar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_reserva() self.frame.Show() def cargar_datos_reserva(self): reserva = self.reserva_serie_controller.get_booking(self.id_booking) serie = self.serie_controller.get_serie(reserva.serie_id) user = self.user_controller.get_user(reserva.usuario_id) self.id_reserva.SetValue(str(reserva.id)) self.id_cliente.SetValue(str(user.id)) self.username.SetValue(user.nombre_usuario) self.id_serie.SetValue(str(serie.id)) self.titulo.SetValue(serie.titulo) def eliminar_reserva(self, evt): if self.reserva_serie_controller.delete_booking(self.id_booking): wx.MessageBox('La reserva se eliminó correctamente', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame_father.load_data_listctrl_juego() self.frame.Close() def cancelar(self, evt): self.frame.Close()
class LoginFrame(wx.Frame): def __init__(self, *args, **kw): super(LoginFrame, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/Login.xml') self.frame = self.xml.LoadFrame(None, 'Login_Frame') self.panel = xrc.XRCCTRL(self.frame, 'Login_Panel') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Usuario') self.password = xrc.XRCCTRL(self.panel, 'Textctrl_Contrasena') self.button_ingresar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_ccuenta = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.validate_user, self.button_ingresar) self.frame.Bind(wx.EVT_BUTTON, self.crear_cuenta, self.button_ccuenta) self.user_controller = UserController() self.admin_controller = AdminController() self.frame.Show() def validate_user(self, evt): username = self.username.GetValue() password = self.password.GetValue() if username and password: if self.user_controller.search_user(username, password): self.frame.Close() wx.MessageBox('Eres un Usuario', 'Error', wx.OK | wx.ICON_ERROR) elif self.admin_controller.search_admin(username, password): self.frame.Close() self.menu_admin = MenuPrincipalAdministrador(username) else: wx.MessageBox('Datos incorrectos o usuario no registrado', 'Error', wx.OK | wx.ICON_ERROR) else: wx.MessageBox('Todos Los Campos Son Obligatorios', 'Error', wx.OK | wx.ICON_ERROR) def crear_cuenta(self, evt): self.crear_cuenta = CrearCuentaUsuario()
class ListaUsuario(wx.Frame): def __init__(self, *args, **kw): super(ListaUsuario, self).__init__(*args, **kw) self.xml = xrc.XmlResource('../View/lista_usuarios.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Usuarios') self.panel = xrc.XRCCTRL(self.frame, 'Panel_Usuarios') self.button_anadir_user = xrc.XRCCTRL(self.panel, 'Button_Anadir_Usuario') self.listctrl_usuario = xrc.XRCCTRL(self.panel, 'Listctrl_Usuarios') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.list_users = [] self.user_list = [] self.user_controller = UserController() self.load_columns_listctrl_user() self.load_data_listctrl_user() self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_usuario) self.frame.Bind(wx.EVT_BUTTON, self.anadir_usuario, self.button_anadir_user) self.frame.Show() def load_columns_listctrl_user(self): self.listctrl_usuario.InsertColumn(0, "ID", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_usuario.InsertColumn(1, "Nombre", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_usuario.InsertColumn(2, "Apellido", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_usuario.InsertColumn(3, "UserName", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_usuario.InsertColumn(4, "Url_Foto", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) def load_data_listctrl_user(self): self.admin_list = self.user_controller.get_all_users() self.listctrl_usuario.DeleteAllItems() for user in self.admin_list: self.listctrl_usuario.Append([ user.id, user.nombre, user.apellido, user.nombre_usuario, user.imagen ]) def list_user_selected(self, evt): current_item = evt.GetIndex() self.list_users = self.user_controller.get_all_users() self.user_selected = self.list_users[current_item] menu = wx.Menu() id_item_menu_update = wx.NewId() id_item_menu_delete = wx.NewId() menu.Append(id_item_menu_update, ACTUALIZAR_USER) menu.Append(id_item_menu_delete, ELIMINAR_USER) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected_user, id=id_item_menu_update) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected_user, id=id_item_menu_delete) self.frame.PopupMenu(menu) menu.Destroy() def popup_item_selected_user(self, evt): id_item = evt.GetId() menu = evt.GetEventObject() menu_item = menu.FindItemById(id_item) if menu_item.GetLabel() == ACTUALIZAR_USER: self.actualizar_usuario = ModificarUsuario(self, self.user_selected.id) elif menu_item.GetLabel() == ELIMINAR_USER: self.eliminar_usuario = EliminarUsuario(self, self.user_selected.id) def anadir_usuario(self, evt): self.anadir_admin = CrearCuentaUsuario(self)
class ModificFrame(wx.Frame): def __init__(self, frame_father=None, id_user=None): super(ModificFrame, self).__init__() self.res = xrc.XmlResource('../view/modific.xrc') self.frame = self.res.LoadFrame(None, 'ModificFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioModific') self.user_controller = UserController() self.id_user = id_user self.first_name = xrc.XRCCTRL(self.panel, 'textModFirstName') self.last_name = xrc.XRCCTRL(self.panel, 'textModLastName') self.username = xrc.XRCCTRL(self.panel, 'textModUsername') self.password = xrc.XRCCTRL(self.panel, 'textModPassword') self.button_save = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancel = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.update_user, self.button_save) self.frame.Show() if frame_father is not None: self.frame_father = frame_father if self.id_user is not None: self.load_data_user() def update_user(self, evt): first_name = self.first_name.GetValue() last_name = self.last_name.GetValue() username = self.username.GetValue() password = self.password.GetValue() if first_name and last_name and username and password: if self.id_user is not None: data = { 'first_name': first_name, 'last_name': last_name, 'username': username, 'password': password } self.user_controller.edit_user(self.id_user, data) wx.MessageBox('The user has been update successfully', 'Information', wx.OK | wx.ICON_INFORMATION) self.load_data_user() else: self.user_controller.create_user(first_name, last_name, username, password) self.frame_father.load_data_listctrl_user() else: wx.MessageBox('Fields not entered', 'Error', wx.OK | wx.ICON_ERROR) self.frame_father.load_data_listctrl_user() def close_frame(self, evt): self.frame.Close() def load_data_user(self): user = self.user_controller.get_user(self.id_user) self.first_name.SetValue(user.first_name) self.last_name.SetValue(user.last_name) self.username.SetValue(user.username) self.password.SetValue(user.password)
class InicioFrame(wx.Frame): def __init__(self): super(InicioFrame, self).__init__() self.res = xrc.XmlResource('../view/inicio.xrc') self.user_controller = UserController() self.conect = Conection() self.series = Series() self.games = VideoGame() self.grid_sizer = None self.add_user_frame = None self.update_users = None self.user_selected = None self.add_series = None self.add_games = None self.list_user = [] self.list_serie = [] self.frame = self.res.LoadFrame(None, 'InicioFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.listbook_menu = xrc.XRCCTRL(self.panel, 'listbook') self.panel_users = xrc.XRCCTRL(self.listbook_menu, 'panel2') self.listctrl_users = xrc.XRCCTRL(self.panel_users, 'listControl') self.button_add_user = xrc.XRCCTRL(self.panel_users, 'addUser') self.load_columns_listcrtl_user() self.load_data_listctrl_user() #Users self.frame.Bind(wx.EVT_BUTTON, self.create_user, self.button_add_user) self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_users) self.text_search = xrc.XRCCTRL(self.panel_users, 'textCtrlSearch') self.button_search = xrc.XRCCTRL(self.panel_users, 'search') self.frame.Bind(wx.EVT_BUTTON, self.search_user, self.button_search) # Exit Buttons self.button_exit = xrc.XRCCTRL(self.panel_users, 'logOut') self.frame.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit) #Series self.panel_serie = xrc.XRCCTRL(self.listbook_menu, 'panelSeries') self.grid_serie = xrc.XRCCTRL(self.panel_serie, 'scrolledWindowserie') self.grid_sizer_series() self.text_search_serie = xrc.XRCCTRL(self.panel_serie, 'textCtrlSerie') self.button_search_serie = xrc.XRCCTRL(self.panel_serie, 'searchSerie') self.frame.Bind(wx.EVT_BUTTON, self.search_serie, self.button_search_serie) self.button_exit_series = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_series) # Button Add series self.button_add_serie = xrc.XRCCTRL(self.panel_serie, 'addSerie') self.frame.Bind(wx.EVT_BUTTON, self.open_add_serie, self.button_add_serie) #Games self.panel_game = xrc.XRCCTRL(self.listbook_menu, 'panelGames') self.grid_game = xrc.XRCCTRL(self.panel_game, 'scrolledWindowGame') self.grid_sizer_games() self.text_search_game = xrc.XRCCTRL(self.panel_game, 'textCtrlGame') self.button_search_game = xrc.XRCCTRL(self.panel_game, 'searchGame') self.frame.Bind(wx.EVT_BUTTON, self.search_game, self.button_search_game) self.button_exit_games = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_games) #Button Add Games self.button_add_game = xrc.XRCCTRL(self.panel_game, 'addGame') self.frame.Bind(wx.EVT_BUTTON, self.open_add_game, self.button_add_game) self.frame.Show() # Se puede mejorar la funcion de buscar series de manera que retorne el boton de la serie mas no un mensaje solamente. def search_serie(self, evt): text_serie = str(self.text_search_serie.GetValue()) session = self.conect.connect_database() try: serie = session.query(Serie).filter_by( titulo_serie=text_serie).all() if text_serie != "": if serie: wx.MessageBox('The serie exist in this aplication.') else: wx.MessageBox( 'The serie does not exist in this aplication.') else: wx.MessageBox('Fields no entered.') session.close() except MultipleResultsFound: session.close() return False # Se puede mejorar la funcion de buscar juegos de manera que retorne el boton del juego mas no un mensaje solamente. def search_game(self, evt): text_game = str(self.text_search_game.GetValue()) session = self.conect.connect_database() try: game = session.query(Videojuego).filter_by( titulo_videojuego=text_game).all() if text_game != "": if game: wx.MessageBox('The videogame exist in this aplication.') else: wx.MessageBox( 'The videogame does not exist in this aplication.') else: wx.MessageBox('Fields no entered') session.close() except MultipleResultsFound: session.close() return False def grid_sizer_games(self): cols = 2 images_games = self.games.get_all_images_games() cantidad = len(images_games) filas = cantidad // cols if cantidad % cols != 0: filas += 1 grid_sizer = wx.GridSizer(filas, cols, 5, 5) indicador = 0 for i in range(grid_sizer.GetRows()): for j in range(grid_sizer.GetCols()): if indicador < len(images_games): button = wx.BitmapButton( self.grid_game, name=str(images_games[indicador].id), bitmap=wx.Bitmap(images_games[indicador].imagen_url)) grid_sizer.Add(button, 0, wx.EXPAND) self.grid_game.Bind(wx.EVT_BUTTON, self.click_images_game, button) self.grid_game.SetSizer(grid_sizer) indicador += 1 def grid_sizer_series(self): cols = 2 images_series = self.series.get_all_images() cantidad = len(images_series) filas = cantidad // cols if cantidad % cols != 0: filas += 1 grid_sizer = wx.GridSizer(filas, cols, 5, 5) indicador = 0 for i in range(grid_sizer.GetRows()): for j in range(grid_sizer.GetCols()): if indicador < len(images_series): button = wx.BitmapButton( self.grid_serie, name=str(images_series[indicador].id), bitmap=wx.Bitmap(images_series[indicador].imagen_url)) grid_sizer.Add(button, 0, wx.EXPAND) self.grid_serie.Bind(wx.EVT_BUTTON, self.click_images_serie, button) self.grid_serie.SetSizer(grid_sizer) indicador += 1 def click_images_serie(self, evt): id_serie = evt.GetEventObject().GetName() VistaSerie(id_serie=id_serie) def click_images_game(self, evt): id_game = evt.GetEventObject().GetName() vistaGame(id_game=id_game) def open_add_serie(self, evt): self.add_series = RegistroSerie(self) def open_add_game(self, evt): self.add_games = RegistroGame(self) def search_user(self, evt): text = str(self.text_search.GetValue()) session = self.conect.connect_database() try: user = session.query(User).filter_by(first_name=text).all() if text != "": if user: self.load_data_listctrl_name(text) return True else: wx.MessageBox('User does not exist in the database') return self.load_data_listctrl_user() else: wx.MessageBox('Fields no entered') self.load_data_listctrl_user() session.close() except MultipleResultsFound: session.close() return False def close_frames(self, evt): self.frame.Destroy() def load_columns_listcrtl_user(self): self.listctrl_users.InsertColumn(0, "Id", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(1, "First Name", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(2, "Last Name", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(3, "UserName", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(4, "Password", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) def load_data_listctrl_user(self): self.list_user = self.user_controller.get_all_users() self.listctrl_users.DeleteAllItems() for user in self.list_user: if len(self.list_user) > 1: self.listctrl_users.Append([ user.id, user.first_name, user.last_name, user.username, user.password ]) def load_data_listctrl_name(self, name): user = self.user_controller.get_first_name(name) self.listctrl_users.DeleteAllItems() for item in user: self.listctrl_users.Append([ item.id, item.first_name, item.last_name, item.username, item.password ]) def create_user(self, evt): self.add_user_frame = RegistroFrame(self) def list_user_selected(self, evt): current_item = evt.GetIndex() self.user_selected = self.list_user[current_item] menu = wx.Menu() id_item_menu_update = wx.NewId() id_item_menu_delete = wx.NewId() menu.Append(id_item_menu_update, UPDATE_USER) menu.Append(id_item_menu_delete, DELETE_USER) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected, id=id_item_menu_update) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected, id=id_item_menu_delete) self.frame.PopupMenu(menu) menu.Destroy() def popup_item_selected(self, evt): id_item = evt.GetId() menu = evt.GetEventObject() menu_item = menu.FindItemById(id_item) if menu_item.GetLabel() == UPDATE_USER: self.add_user_frame = ModificFrame(self, self.user_selected.id) elif menu_item.GetLabel() == DELETE_USER: msg = "Is you sure to delete the User %s %s?" % ( self.user_selected.first_name, self.user_selected.last_name) result = wx.MessageBox(msg, "Delete User", wx.YES_NO | wx.ICON_EXCLAMATION) if result == wx.YES: self.user_controller.delete_user(self.user_selected.id) self.load_data_listctrl_user()
def __init__(self): super(InicioFrame, self).__init__() self.res = xrc.XmlResource('../view/inicio.xrc') self.user_controller = UserController() self.conect = Conection() self.series = Series() self.games = VideoGame() self.grid_sizer = None self.add_user_frame = None self.update_users = None self.user_selected = None self.add_series = None self.add_games = None self.list_user = [] self.list_serie = [] self.frame = self.res.LoadFrame(None, 'InicioFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.listbook_menu = xrc.XRCCTRL(self.panel, 'listbook') self.panel_users = xrc.XRCCTRL(self.listbook_menu, 'panel2') self.listctrl_users = xrc.XRCCTRL(self.panel_users, 'listControl') self.button_add_user = xrc.XRCCTRL(self.panel_users, 'addUser') self.load_columns_listcrtl_user() self.load_data_listctrl_user() #Users self.frame.Bind(wx.EVT_BUTTON, self.create_user, self.button_add_user) self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_users) self.text_search = xrc.XRCCTRL(self.panel_users, 'textCtrlSearch') self.button_search = xrc.XRCCTRL(self.panel_users, 'search') self.frame.Bind(wx.EVT_BUTTON, self.search_user, self.button_search) # Exit Buttons self.button_exit = xrc.XRCCTRL(self.panel_users, 'logOut') self.frame.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit) #Series self.panel_serie = xrc.XRCCTRL(self.listbook_menu, 'panelSeries') self.grid_serie = xrc.XRCCTRL(self.panel_serie, 'scrolledWindowserie') self.grid_sizer_series() self.text_search_serie = xrc.XRCCTRL(self.panel_serie, 'textCtrlSerie') self.button_search_serie = xrc.XRCCTRL(self.panel_serie, 'searchSerie') self.frame.Bind(wx.EVT_BUTTON, self.search_serie, self.button_search_serie) self.button_exit_series = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_series) # Button Add series self.button_add_serie = xrc.XRCCTRL(self.panel_serie, 'addSerie') self.frame.Bind(wx.EVT_BUTTON, self.open_add_serie, self.button_add_serie) #Games self.panel_game = xrc.XRCCTRL(self.listbook_menu, 'panelGames') self.grid_game = xrc.XRCCTRL(self.panel_game, 'scrolledWindowGame') self.grid_sizer_games() self.text_search_game = xrc.XRCCTRL(self.panel_game, 'textCtrlGame') self.button_search_game = xrc.XRCCTRL(self.panel_game, 'searchGame') self.frame.Bind(wx.EVT_BUTTON, self.search_game, self.button_search_game) self.button_exit_games = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_games) #Button Add Games self.button_add_game = xrc.XRCCTRL(self.panel_game, 'addGame') self.frame.Bind(wx.EVT_BUTTON, self.open_add_game, self.button_add_game) self.frame.Show()
class RegistroFrame(wx.Frame): def __init__(self, frame_father=None, id_user=None): super(RegistroFrame, self).__init__() self.res = xrc.XmlResource('../view/registro.xrc') self.user_controller = UserController() self.id_user = id_user self.frame = self.res.LoadFrame(None, 'RegistroFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioRegistro') self.first_name = xrc.XRCCTRL(self.panel, 'textCtrlFirstName') self.last_name = xrc.XRCCTRL(self.panel, 'textCtrlLastname') self.username = xrc.XRCCTRL(self.panel, 'textCtrlUsername') self.password = xrc.XRCCTRL(self.panel, 'textCtrlPassword') self.button_save = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancel = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.create_user, self.button_save) self.frame_father = frame_father if self.id_user is not None: self.load_data_user() self.frame.Show() def close_frame(self, evt): self.frame.Close() def create_user(self, evt): first_name = self.first_name.GetValue() last_name = self.last_name.GetValue() username = self.username.GetValue() password = self.password.GetValue() search_data = self.user_controller.search_username(username) if first_name and last_name and username and password: if self.id_user is not None: data = { 'first_name': first_name, 'last_name': last_name, 'username': username, 'password': password } self.user_controller.edit_user(self.id_user, data) self.load_data_user() else: if search_data is None: self.user_controller.create_user(first_name, last_name, username, password) wx.MessageBox('The user has been created successfully', 'Information', wx.OK | wx.ICON_INFORMATION) self.clear_fields() else: wx.MessageBox( 'The username already exist in the database.', 'Error', wx.OK | wx.ICON_ERROR) if not self.frame_father is None: self.frame_father.load_data_listctrl_user() else: wx.MessageBox('Fields not entered', 'Error', wx.OK | wx.ICON_ERROR) def clear_fields(self): self.first_name.Clear() self.last_name.Clear() self.username.Clear() self.password.Clear() def load_data_user(self): user = self.user_controller.get_user(self.id_user) self.first_name.SetValue(user.first_name) self.last_name.SetValue(user.last_name) self.username.SetValue(user.username) self.password.SetValue(user.password)
class ModificarReservaSerie(wx.Frame): def __init__(self, frame_father, id_reserva): super(ModificarReservaSerie, self).__init__() self.xml = xrc.XmlResource('../View/modificar_reserva_serie.xml') self.frame = self.xml.LoadFrame(None, 'Frame_Modificar_Reserva') self.panel = xrc.XRCCTRL(self.frame, 'ModificarReserva_Panel') self.id_reserva = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Reserva') self.id_cliente = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Cliente') self.username = xrc.XRCCTRL(self.panel, 'Textctrl_Username') self.id_serie = xrc.XRCCTRL(self.panel, 'Textctrl_ID_Serie') self.titulo = xrc.XRCCTRL(self.panel, 'Textctrl_titulo_serie') self.id_booking = id_reserva self.frame_father = frame_father self.reserva_serie_controller = ReservaSerieController() self.serie_controller = SerieController() self.user_controller = UserController() self.button_modificar = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancelar = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.SetIcon(wx.Icon("../view/System_Images/icon.png")) self.frame.Bind(wx.EVT_BUTTON, self.modificar_serie, self.button_modificar) self.frame.Bind(wx.EVT_BUTTON, self.cancelar, self.button_cancelar) self.cargar_datos_reserva() self.frame.Show() def cargar_datos_reserva(self): reserva = self.reserva_serie_controller.get_booking(self.id_booking) serie = self.serie_controller.get_serie(reserva.serie_id) user = self.user_controller.get_user(reserva.usuario_id) self.id_reserva.SetValue(str(reserva.id)) self.id_cliente.SetValue(str(user.id)) self.username.SetValue(user.nombre_usuario) self.id_serie.SetValue(str(serie.id)) self.titulo.SetValue(serie.titulo) def modificar_serie(self, evt): id_cliente = self.id_cliente.GetValue() id_serie = self.id_serie.GetValue() if id_cliente and id_serie: if self.user_controller.get_user( id_cliente) != None and self.serie_controller.get_serie( id_serie) != None: data = {"usuario_id": id_cliente, "serie_id": id_serie} if self.reserva_serie_controller.edit_booking( self.id_booking, data): wx.MessageBox('La reserva se modificó con exito', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame_father.load_data_listctrl_serie() self.frame.Close() else: wx.MessageBox( 'El usuario o la serie no existe en el sistema intente nuevamente', 'Error', wx.OK | wx.ICON_ERROR) else: wx.MessageBox('Todos los campos son obligatorios', 'Error', wx.OK | wx.ICON_ERROR) def cancelar(self, evt): self.frame.Close()