Пример #1
0
        private float CalcularCostoTotal(int opcion, int id, int cantPasKm)
        {
            float costo = 0;

            if (opcion == 0)
            {
                Avion a = Aviones.Find(x => x.Numero == id);
                costo = cantPasKm * a.CostoPorPersona + ((a.LowCost) ? 1200 : 2700);
            }
            else if (opcion == 1)
            {
                Auto a = Autos.Find(x => x.Numero == id);
                costo = cantPasKm * a.CostoPorKm;
            }
            else
            {
                Colectivo c = Colectivos.Find(x => x.Numero == id);
                costo = cantPasKm * c.CostoPorPersona + ((c.AlmuerzoCena) ? 100 : 0) + ((c.CocheCama) ? 30 : 0);
            }

            return(costo);
        }
Пример #2
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            bool error = false;
            int  i     = 0;

            if (txtNombre.Text == "")
            {
                error = true;
            }

            if (mskCostoPersona.Text == "")
            {
                error = true;
            }

            if (mskCostoKm.Text == "")
            {
                error = true;
            }

            if (cbxCantidadButacas.SelectedIndex == -1)
            {
                error = true;
            }
            else
            {
                i = Convert.ToInt16(cbxCantidadButacas.Text);
            }

            if ((tipoElegido == 0) || (tipoElegido == 2))
            {
                if (cbxEmbarqueDarsena.SelectedIndex == -1)
                {
                    error = true;
                }

                if ((tipoElegido == 0) && (i < 10))
                {
                    error = true;
                }
                else if ((tipoElegido == 2) && ((i > 50) || (i < 30)))
                {
                    error = true;
                }
            }
            else
            {
                if (txtMarca.Text == "")
                {
                    error = true;
                }

                if (txtModelo.Text == "")
                {
                    error = true;
                }

                if (mskAutonomia.Text == "")
                {
                    error = true;
                }

                if ((i > 5) || (i < 2))
                {
                    error = true;
                }
            }

            // Si hay algún campo inválido.
            if (error)
            {
                MessageBox.Show("Hay campos incorrectos o sin completar.", "Advertencia", MessageBoxButtons.OK);
            }
            // Si todo lo ingresado es válido.
            else
            {
                string nom     = txtNombre.Text;
                int    but     = Convert.ToInt16(cbxCantidadButacas.Text);
                float  costPer = Convert.ToSingle(mskCostoPersona.Text);
                float  costKm  = Convert.ToSingle(mskCostoKm.Text);

                if ((tipoElegido == 0) || (tipoElegido == 2))
                {
                    int  embDar  = Convert.ToInt16(cbxEmbarqueDarsena.Text);
                    bool lowCama = chkLowCostCocheCama.Checked;
                    bool mascAlm = chkPermiteMascotasAlmuerzoCena.Checked;

                    if (tipoElegido == 0)
                    {
                        Avion = new Avion(Avion.Numero, nom, but, costPer, costKm, embDar, lowCama, mascAlm);
                    }
                    else
                    {
                        Colectivo = new Colectivo(Colectivo.Numero, nom, but, costPer, costKm, embDar, lowCama, mascAlm);
                    }
                }
                else
                {
                    int auto = Convert.ToInt16(mskAutonomia.Text);

                    Auto = new Auto(Auto.Numero, nom, but, costPer, costKm, txtMarca.Text, txtModelo.Text, auto);
                }

                estado = true;
                ActiveForm.Close();
            }
        }
Пример #3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            bool error = false;

            if (txtNombre.Text == "")
            {
                error = true;
            }

            if (mskCostoPersona.Text == "")
            {
                error = true;
            }

            if (mskCostoKm.Text == "")
            {
                error = true;
            }

            // Si no se eligió ningún tipo de vehículo.
            if (cbxTipoVehiculo.SelectedIndex == -1)
            {
                error = true;
            }
            // Si se eligió un avión o colectivo como tipo de vehículo.
            else if ((cbxTipoVehiculo.SelectedIndex == 0) || (cbxTipoVehiculo.SelectedIndex == 2))
            {
                // Si no se eligió puerta de embarque o número de dársena.
                if (cbxEmbarqueDarsena.SelectedIndex == -1)
                {
                    error = true;
                }

                // Si no se eligió cantidad de butacas.
                if (cbxCantButacas.SelectedIndex == -1)
                {
                    error = true;
                }
                else
                {
                    int i = Convert.ToInt16(cbxCantButacas.Text);

                    // Si se eligió un colectivo como tipo de vehículo y cantidad de butacas inválida.
                    if ((cbxTipoVehiculo.SelectedIndex == 2) && ((i > 50) || (i < 30)))
                    {
                        error = true;
                    }

                    // Si se eligió un avión como tipo de vehículo y cantidad de butacas inválida.
                    if ((cbxTipoVehiculo.SelectedIndex == 0) && (i < 10))
                    {
                        error = true;
                    }
                }
            }
            // Si se eligió un auto como tipo de vehículo.
            else
            {
                if (txtMarca.Text == "")
                {
                    error = true;
                }

                if (txtModelo.Text == "")
                {
                    error = true;
                }

                if (mskAutonomia.Text == "")
                {
                    error = true;
                }

                // Si no se eligió cantidad de butacas.
                if (cbxCantButacas.SelectedIndex == -1)
                {
                    error = true;
                }
                // Si se eligió una cantidad de butacas inválida.
                else if (Convert.ToInt16(cbxCantButacas.Text) > 5)
                {
                    error = true;
                }
            }

            // Si hay algún campo inválido.
            if (error)
            {
                MessageBox.Show("Hay campos incorrectos o sin completar.", "Advertencia", MessageBoxButtons.OK);
            }
            // Si todo lo ingresado es válido.
            else
            {
                int    num     = AsignarNumeroVehiculo();
                string nom     = txtNombre.Text;
                int    but     = Convert.ToInt16(cbxCantButacas.Text);
                float  costPer = Convert.ToSingle(mskCostoPersona.Text);
                float  costKm  = Convert.ToSingle(mskCostoKm.Text);

                if ((cbxTipoVehiculo.SelectedIndex == 0) || (cbxTipoVehiculo.SelectedIndex == 2))
                {
                    int  embDar  = Convert.ToInt16(cbxEmbarqueDarsena.Text);
                    bool lowCama = chkLowCostCocheCama.Checked;
                    bool mascAlm = chkPermiteMascotasAlmuerzoCena.Checked;

                    if (cbxTipoVehiculo.SelectedIndex == 0)
                    {
                        Avion = new Avion(num, nom, but, costPer, costKm, embDar, lowCama, mascAlm);
                    }
                    else
                    {
                        Colectivo = new Colectivo(num, nom, but, costPer, costKm, embDar, lowCama, mascAlm);
                    }
                }
                else
                {
                    int auto = Convert.ToInt16(mskAutonomia.Text);

                    Auto = new Auto(num, nom, but, costPer, costKm, txtMarca.Text, txtModelo.Text, auto);
                }

                estado = true;
                tipo   = cbxTipoVehiculo.SelectedIndex;
                ActiveForm.Close();
            }
        }