private void btoModificar(object sender, RoutedEventArgs e)
        {
            int bonus = -1;

            try
            {
                if (string.IsNullOrEmpty(this.NomTxt.Text))
                {
                    throw new Exception("Debe especificar un nombre para la Raza");
                }
                if (string.IsNullOrEmpty(this.DesTxt.Text))
                {
                    throw new Exception("Debe especificar una Descripción para la Raza");
                }
                if (!int.TryParse(this.BonusTxt.Text, out bonus) && bonus > 0 && bonus < 5)
                {
                    throw new Exception("Debe especificar un Valor de Bonus para la Raza entre 1 y 5");
                }
                Raza SelectItem = (Raza)ListRaza.SelectedItem;
                SelectItem.nombre                 = NomTxt.Text;
                SelectItem.Descripcion            = DesTxt.Text;
                SelectItem.Bonus                  = bonus;
                SelectItem.CaracteristicaVariable = Car;
                int modRaza = RazaBL.Modificar(SelectItem);
                if (modRaza > 0)
                {
                    MessageBox.Show("Raza Modificada Correctamente", "Correcto");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Errorr");
            }
            ListRaza.ItemsSource = RazaBL.Listar();
        }
        public ManejadorRaza()
        {
            InitializeComponent();
            ListRaza.ItemsSource = RazaBL.Listar();

            cboCV.ItemsSource       = CaracteristicaVariableBL.Listar();
            cboCV.SelectedValuePath = "Id";
        }
        public AltaPersonaje()
        {
            InitializeComponent();

            CboRaza.ItemsSource       = RazaBL.Listar();
            CboRaza.SelectedValuePath = "Id";

            CboClase.ItemsSource       = ClaseBL.Listar();
            CboClase.SelectedValuePath = "Id";
        }
Beispiel #4
0
 public PersonajeViewModel(TerceraEntrega.Domain.Personaje p)
 {
     this.Id           = p.Id;
     this.Nombre       = p.Nombre;
     this.Nivel        = p.Nivel;
     this.Fuerza       = p.Fuerza;
     this.Destreza     = p.Destreza;
     this.Constitucion = p.Constitucion;
     this.Inteligencia = p.Inteligencia;
     this.Sabiduria    = p.Sabiduria;
     this.Carisma      = p.Carisma;
     this.Imagen       = p.Imagen;
     this.Raza         = RazaBL.obtenerPorPersonaje(p.Id).nombre;
     this.Clase        = ClaseBL.obtenerPorIdPersonaje(p.Id).Nombre;
 }
        public AltaPersonaje(int id, Boolean readOnly)
        {
            InitializeComponent();

            CboRaza.ItemsSource       = RazaBL.Listar();
            CboRaza.SelectedValuePath = "Id";

            CboClase.ItemsSource       = ClaseBL.Listar();
            CboClase.SelectedValuePath = "Id";

            p = PersonajeBL.Obtener(id);
            c = ClaseBL.obtenerPorIdPersonaje(id);
            r = RazaBL.obtenerPorPersonaje(id);

            this.NombreTxt.Text = p.Nombre;
            this.NivelTxt.Text  = p.Nivel.ToString();
            this.FueTxt.Text    = p.Fuerza.ToString();
            this.DesTXT.Text    = p.Destreza.ToString();
            this.ConstTxt.Text  = p.Constitucion.ToString();
            this.InteTxt.Text   = p.Inteligencia.ToString();
            this.SabTxt.Text    = p.Sabiduria.ToString();
            this.CarTxt.Text    = p.Carisma.ToString();
            this.Foto.Source    = LoadImage(p.Imagen);

            this.CboClase.SelectedItem = 1;
            this.CboRaza.SelectedItem  = 1;

            this.Titulo.Content = "Modificar Personaje";
            this.Cargar.Content = "Modificar";

            if (readOnly)
            {
                this.Cargar.Visibility            = Visibility.Hidden;
                this.NombreTxt.IsEnabled          = false;
                this.NivelTxt.IsEnabled           = false;
                this.FueTxt.IsEnabled             = false;
                this.DesTXT.IsEnabled             = false;
                this.ConstTxt.IsEnabled           = false;
                this.InteTxt.IsEnabled            = false;
                this.SabTxt.IsEnabled             = false;
                this.CarTxt.IsEnabled             = false;
                this.CboClase.IsEnabled           = false;
                this.CboRaza.IsEnabled            = false;
                this.ArchivoSelect.Visibility     = Visibility.Hidden;
                this.BotonCargarImagen.Visibility = Visibility.Hidden;
                this.Titulo.Content = "Detalles Personaje";
            }
        }
        private void btoEliminar(object sender, RoutedEventArgs e)
        {
            try
            {
                Raza SelectItem = (Raza)ListRaza.SelectedItem;

                int removeRaza = RazaBL.Eliminar(SelectItem);
                if (removeRaza > 0)
                {
                    MessageBox.Show("Raza Eliminada Correctamente", "Correcto");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Errorr");
            }
            ListRaza.ItemsSource = RazaBL.Listar();
        }
        private void btoCargar(object sender, RoutedEventArgs e)
        {
            int bonus = -1;

            try
            {
                if (string.IsNullOrEmpty(this.NomTxt.Text))
                {
                    throw new Exception("Debe especificar un nombre para la Raza");
                }
                if (string.IsNullOrEmpty(this.DesTxt.Text))
                {
                    throw new Exception("Debe especificar una Descripción para la Raza");
                }
                if (!int.TryParse(this.BonusTxt.Text, out bonus) && bonus > 0 && bonus < 5)
                {
                    throw new Exception("El valor de Bonus especificado no es válido.");
                }
                if (Car == null)
                {
                    throw new Exception("Debe ingresar una Caracteristica Variable");
                }

                laRaza.nombre                 = NomTxt.Text;
                laRaza.Descripcion            = DesTxt.Text;
                laRaza.Bonus                  = bonus;
                laRaza.CaracteristicaVariable = Car;

                int newRaza = RazaBL.Crear(laRaza);
                if (newRaza > 0)
                {
                    MessageBox.Show("Raza Ingresada Correctamente", "Correcto");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Errorr");
            }
            ListRaza.ItemsSource = RazaBL.Listar();
        }