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()
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()
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 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 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 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()