Ejemplo n.º 1
0
 public Vivienda(string referencia, Enums.Poblacion poblacion, double precioBase, int numeroDeHabitaciones, Boolean alquilado = false)
 {
     this.referencia           = referencia;
     this.poblacion            = poblacion;
     this.precioBase           = precioBase;
     this.numeroDeHabitaciones = numeroDeHabitaciones;
     this.alquilado            = alquilado;
 }
Ejemplo n.º 2
0
 public LocalComercial(string referencia, Enums.Poblacion poblacion, double precioBase, Boolean reformado, int tamano, Boolean alquilado = false)
 {
     this.referencia = referencia;
     this.poblacion  = poblacion;
     this.precioBase = precioBase;
     this.reformado  = reformado;
     this.tamano     = tamano;
     this.alquilado  = alquilado;
 }
Ejemplo n.º 3
0
        public static List <string> mostrarInmuebles()
        {
            arrayTxt.Clear();

            foreach (Object dato in datos)
            {
                if (dato is Inmueble)
                {
                    if (dato is LocalComercial)
                    {
                        LocalComercial lc = new LocalComercial();
                        lc = dato as LocalComercial;
                        string          referencia  = lc.referencia;
                        Enums.Poblacion poblacion   = lc.poblacion;
                        double          pb          = lc.precioBase;
                        int             tamano      = lc.tamano;
                        Boolean         reformado   = lc.reformado;
                        string          rf          = reformado == false ? "N" : "S";
                        Boolean         alquilado   = lc.alquilado;
                        string          alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string          precioTotal = lc.calcularPrecio().ToString();
                        string          texto       = "L " + referencia + " Poblacion: " + poblacion.ToString().ToUpper() + " PB: " + pb.ToString() + " Superficie: " + tamano + " " + rf + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                    else if (dato is Vivienda)
                    {
                        Vivienda vi = new Vivienda();
                        vi = dato as Vivienda;
                        string          referencia  = vi.referencia;
                        Enums.Poblacion poblacion   = vi.poblacion;
                        double          pb          = vi.precioBase;
                        int             numHab      = vi.numeroDeHabitaciones;
                        Boolean         alquilado   = vi.alquilado;
                        string          alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string          precioTotal = vi.calcularPrecio().ToString();
                        string          texto       = "V " + referencia + " Poblacion: " + poblacion.ToString().ToUpper() + " PB: " + pb.ToString() + " " + numHab + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                }
            }

            return(arrayTxt);
        }
Ejemplo n.º 4
0
        public static List <string> mostrarTodos()
        {
            arrayTxt.Clear();

            foreach (Object dato in datos)
            {
                if (dato is Inmueble)
                {
                    if (dato is LocalComercial)
                    {
                        LocalComercial lc = new LocalComercial();
                        lc = dato as LocalComercial;
                        string          referencia  = lc.referencia;
                        Enums.Poblacion poblacion   = lc.poblacion;
                        double          pb          = lc.precioBase;
                        int             tamano      = lc.tamano;
                        Boolean         reformado   = lc.reformado;
                        string          rf          = reformado == false ? "N" : "S";
                        Boolean         alquilado   = lc.alquilado;
                        string          alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string          precioTotal = lc.calcularPrecio().ToString();
                        string          texto       = "L " + referencia + " Poblacion: " + poblacion.ToString().ToUpper() + " PB: " + pb.ToString() + " Superficie: " + tamano + " " + rf + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                    else if (dato is Vivienda)
                    {
                        Vivienda vi = new Vivienda();
                        vi = dato as Vivienda;
                        string          referencia  = vi.referencia;
                        Enums.Poblacion poblacion   = vi.poblacion;
                        double          pb          = vi.precioBase;
                        int             numHab      = vi.numeroDeHabitaciones;
                        Boolean         alquilado   = vi.alquilado;
                        string          alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string          precioTotal = vi.calcularPrecio().ToString();
                        string          texto       = "V " + referencia + " Poblacion: " + poblacion.ToString().ToUpper() + " PB: " + pb.ToString() + " " + numHab + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                }

                if (dato is Vehiculo)
                {
                    if (dato is Coche)
                    {
                        Coche ch = new Coche();
                        ch = dato as Coche;
                        string             matricula = ch.matricula;
                        Enums.Marca        marca     = ch.marca;
                        Enums.TipoVehiculo tipo      = ch.tipo;
                        int     numPlazas            = ch.numeroDePlazas;
                        Boolean alquilado            = ch.alquilado;
                        string  alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string  precioTotal = ch.calcularPrecio().ToString();
                        string  texto       = "C " + matricula + " Marca: " + marca.ToString().ToUpper() + " Tipo: " + tipo.ToString().ToUpper() + " Plazas: " + numPlazas + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                    else if (dato is Furgoneta)
                    {
                        Furgoneta fg = new Furgoneta();
                        fg = dato as Furgoneta;
                        string             matricula = fg.matricula;
                        Enums.Marca        marca     = fg.marca;
                        Enums.TipoVehiculo tipo      = fg.tipo;
                        int     carga       = fg.cargaMaxima;
                        Boolean alquilado   = fg.alquilado;
                        string  alq         = alquilado == false ? "DISPONIBLE" : "ALQUILADO";
                        string  precioTotal = fg.calcularPrecio().ToString();
                        string  texto       = "F " + matricula + " Marca: " + marca.ToString().ToUpper() + " Tipo: " + tipo.ToString().ToUpper() + " Carga max: " + carga + " " + alq + " " + precioTotal;
                        arrayTxt.Add(texto);
                    }
                }
            }

            return(arrayTxt);
        }
Ejemplo n.º 5
0
        private void click_crearInmueble(object sender, RoutedEventArgs e)
        {
            Inmueble nuevoInmueble;

            if (cbTipoinmueble.SelectedIndex == 0)
            {
                nuevoInmueble = new LocalComercial();
            }
            else
            {
                nuevoInmueble = new Vivienda();
            }


            // LocalComercial lc = i as LocalComercial;
            //i is LocalComercial
            ComboBoxItem item   = (ComboBoxItem)cbPoblacion.SelectedItem;
            Boolean      existe = false;
            Boolean      valida = false;

            if (cbTipoinmueble.SelectedIndex == 0)
            {
                if (txtReferencia.Text.Length > 0 && txtPrecioBase.Text.Length > 0 && item != null && txtTamano.Text.Length > 0 && cbReformado.Text != "")
                {
                    string          referencia = txtReferencia.Text;
                    Enums.Poblacion poblacion  = (Enums.Poblacion)item.Tag;
                    double          precio     = double.Parse(txtPrecioBase.Text);
                    int             tamano     = Int32.Parse(txtTamano.Text);
                    Boolean         reformado  = cbReformado.Text == "no" ? false : true;
                    nuevoInmueble = new LocalComercial(referencia, poblacion, precio, reformado, tamano);
                }
                else
                {
                    lblError.Content = "Datos no validos";
                }
            }
            else
            {
                if (txtReferencia.Text.Length > 0 && txtPrecioBase.Text.Length > 0 && item != null && txtNumHab.Text.Length > 0)
                {
                    string          referencia = txtReferencia.Text;
                    Enums.Poblacion poblacion  = (Enums.Poblacion)item.Tag;
                    double          precio     = double.Parse(txtPrecioBase.Text);
                    int             numHab     = Int32.Parse(txtNumHab.Text);
                    nuevoInmueble = new Vivienda(referencia, poblacion, precio, numHab);
                }
                else
                {
                    lblError.Content = "Datos no validos";
                }
            }



            //compruebo si solo hay letras y numeros en la referencia
            if (!nuevoInmueble.comprobarRef())
            {
                lblError.Content = "Referencia, caracteres no validos";
                valida           = true;
            }
            else
            {
                //compruebo si ya existe la referencia
                foreach (Object dato in Principal.datos)
                {
                    if (dato is Inmueble)
                    {
                        if (nuevoInmueble.esIgual(dato as Inmueble))
                        {
                            existe = true;
                        }
                    }
                }
            }
            //error si existe la referencia
            if (existe)
            {
                lblError.Content = "Ya existe en la bbdd!";
            }
            //si todo va bien inserto
            if (!existe && !valida)
            {
                if (Principal.NuevoInmueble(nuevoInmueble))
                {
                    txtReferencia.Clear();
                    txtTamano.Clear();
                    txtPrecioBase.Clear();
                    cbPoblacion.SelectedIndex    = -1;
                    cbTipoinmueble.SelectedIndex = -1;
                    txtNumHab.Clear();
                    lblError.Content = "";
                }
            }
        }