Example #1
0
        private void botonCalcular_Click(object sender, EventArgs e)
        {
            bool esNuevo;
            bool validarPrecioBase;
            bool validarTamanio;


            if (radioNuevo.Checked) //Si el inmueble es nuevo
            {
                esNuevo = true;
            }
            else
            {
                esNuevo = false;
            }

            //Validando atributos del objeto
            validarPrecioBase = validar(inputPrecioBase.Text, "float");
            validarTamanio    = validar(inputTamanio.Text, "float");

            if (radioPiso.Checked)  //Si es un piso
            {
                #region CREAR Y OBTENER EL PRECIO DEL PISO

                bool validarNroPiso = validar(inputPiso.Text, "int");

                if (validarNroPiso && validarPrecioBase && validarTamanio)
                {
                    //Creando objeto de tipo Piso
                    Piso piso1 = new Piso(Convert.ToInt32(inputPiso.Text), inputDireccion.Text, Convert.ToInt32(inputTamanio.Text), esNuevo, Convert.ToSingle(inputPrecioBase.Text));
                    MessageBox.Show("El valor total del inmueble es: $" + piso1.calcularPrecioTotal(), "Precio calculado");
                    //Limpiando los textbox
                    inputPiso.Text = "";
                    limpiarTextBoxGenerales();
                    //Pintando de blanco el color del textbox
                    inputPiso.BackColor       = System.Drawing.Color.White;
                    inputPrecioBase.BackColor = System.Drawing.Color.White;
                    inputTamanio.BackColor    = System.Drawing.Color.White;
                }
                else
                {
                    #region PINTAR DE NARANJA LOS CAMPOS INVALIDOS, Y DE BLANCO LOS VALIDOS
                    //Pintar campo numero de piso
                    if (!validarNroPiso)
                    {
                        inputPiso.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputPiso.BackColor = System.Drawing.Color.White;
                    }

                    //Pintar campo precio base
                    if (!validarPrecioBase)
                    {
                        inputPrecioBase.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputPrecioBase.BackColor = System.Drawing.Color.White;
                    }

                    //Pintar campo tamaño
                    if (!validarTamanio)
                    {
                        inputTamanio.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputTamanio.BackColor = System.Drawing.Color.White;
                    }

                    #endregion
                }

                #endregion
            }
            else    //Si es un local
            {
                #region CREAR Y OBTENER EL PRECIO DEL LOCAL

                bool validarVentanales = validar(inputVentanales.Text, "int");

                if (validarVentanales && validarPrecioBase && validarTamanio)  //Si se valida el numero de vantanas
                {
                    //Creando objeto de tipo Local
                    Local inmueble = new Local(Convert.ToInt32(inputVentanales.Text), inputDireccion.Text, Convert.ToInt32(inputTamanio.Text), esNuevo, Convert.ToSingle(inputPrecioBase.Text));
                    MessageBox.Show("El valor total del inmueble es: $" + inmueble.calcularPrecioTotal(), "Precio calculado");
                    //Limpiando los textbox
                    inputVentanales.Text = "";
                    limpiarTextBoxGenerales();
                    //Pintando de blanco el color del textbox
                    inputVentanales.BackColor = System.Drawing.Color.White;
                    inputPrecioBase.BackColor = System.Drawing.Color.White;
                    inputTamanio.BackColor    = System.Drawing.Color.White;
                }
                else
                {
                    #region PINTAR DE NARANJA LOS CAMPOS INVALIDOS, Y DE BLANCO LOS VALIDOS

                    //Pintando campo ventanales
                    if (!validarVentanales)
                    {
                        inputVentanales.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputVentanales.BackColor = System.Drawing.Color.White;
                    }

                    //Pintando campo precio base
                    if (!validarPrecioBase)
                    {
                        inputPrecioBase.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputPrecioBase.BackColor = System.Drawing.Color.White;
                    }

                    //PPintando campo tamaño
                    if (!validarTamanio)
                    {
                        inputTamanio.BackColor = System.Drawing.Color.Orange;
                    }
                    else
                    {
                        inputTamanio.BackColor = System.Drawing.Color.White;
                    }

                    #endregion
                }

                #endregion
            }
        }
Example #2
0
        private void btnPiso_Click(object sender, EventArgs e)
        {
            Piso Departamento = new Piso();

            validarcampo = Utiles.validarCampo(txtPrecio.Text, "float");
            if (validarcampo)
            {
                validarcampo = Utiles.validarCampo(txtMetros.Text, "int");
                if (validarcampo)
                {
                    if (comboBoxAÑOS.SelectedIndex > -1)
                    {
                        if (comboBoxAÑOS.SelectedIndex == 0)
                        {
                            años = 14;
                        }
                        if (comboBoxAÑOS.SelectedIndex == 1)
                        {
                            años = 16;
                        }

                        precio = Convert.ToInt32(txtPrecio.Text);

                        if (comboBoxPISO.SelectedIndex > -1)
                        {
                            if (comboBoxPISO.SelectedIndex == 0)
                            {
                                nropiso = 1;
                            }
                            else
                            {
                                if (comboBoxPISO.SelectedIndex == 1)
                                {
                                    nropiso = 4;
                                }
                            }
                            precio = Convert.ToInt32(txtPrecio.Text);

                            if (radiobtnventana1.Checked == true)
                            {
                                ventanas = 1;
                                MessageBox.Show("Precio Final: $" + Departamento.Calcular(precio, años, nropiso, metroscuadrados) + "\nDirección: " + txtDirec.Text + "\nMetros Cuadrados: " + txtMetros.Text + "\nNúmero de Piso: " + comboBoxPISO.SelectedItem + "\nAños de Antiguedad: " + comboBoxAÑOS.SelectedItem + "\nEstado: " + comboBoxUSADO.SelectedItem + "\nCantidad de ventanas: " + radiobtnventana1.Text, "CÁLCULO DE PISO");
                            }
                            if (radioButton2.Checked == true)
                            {
                                ventanas = 3;
                                MessageBox.Show("Precio Final: $" + Departamento.Calcular(precio, años, nropiso, metroscuadrados) + "\nDirección: " + txtDirec.Text + "\nMetros Cuadrados: " + txtMetros.Text + "\nNúmero de Piso: " + comboBoxPISO.SelectedItem + "\nAños de Antiguedad: " + comboBoxAÑOS.SelectedItem + "\nEstado: " + comboBoxUSADO.SelectedItem + "\nCantidad de ventanas: " + radioButton2.Text, "CÁLCULO DE PISO");
                            }
                            if (radioButton3.Checked == true)
                            {
                                ventanas = 5;
                                MessageBox.Show("Precio Final: $" + Departamento.Calcular(precio, años, nropiso, metroscuadrados) + "\nDirección: " + txtDirec.Text + "\nMetros Cuadrados: " + txtMetros.Text + "\nNúmero de Piso: " + comboBoxPISO.SelectedItem + "\nAños de Antiguedad: " + comboBoxAÑOS.SelectedItem + "\nEstado: " + comboBoxUSADO.SelectedItem + "\nCantidad de ventanas: " + radioButton3.Text, "CÁLCULO DE PISO");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Debe seleccionar una opcion de PISO, por favor corrija.", "ERROR");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar una opción de AÑOS DE ANTIGUEDAD, por favor corrija.", "ERROR");
                    }
                }
                else
                {
                    MessageBox.Show("Ingreso un valor erróneo en el campo METROS CUADRADOS, por favor corrija.", "ERROR");
                }
            }
            else
            {
                MessageBox.Show("Ingreso un valor erróneo en el campo PRECIO, por favor corrija.", "ERROR");
            }
        }