Exemple #1
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            progressBar.Value             = 0;
            lblPorcClientePerdido.Visible = false;
            dgvSimulacion.Rows.Clear();
            dgvSimulacion.Enabled = false;
            btnGenerar.Visible    = false;
            progressBar.Visible   = true;

            Condiciones cIniciales = ObtenerCondiciones();

            if (Validar(cIniciales))
            {
                MessageBox.Show("Condiciones Erroneas");
                btnGenerar.Visible = true;
                return;
            }
            sim = new Simulacion(cIniciales);
            AgregarFila(sim.estadoAnterior);

            int i = 0;
            EstadoSimulacion s = sim.estadoAnterior;

            while (i <= Convert.ToInt32(txtCantSim.Text))
            {
                s = sim.GenerarSimulacion();
                if (s.numeroEvento >= Convert.ToInt32(txtSimApartir.Text) && s.numeroEvento <= Convert.ToInt32(txtSimApartir.Text) + 50)
                {
                    AgregarFila(s);
                }
                else if (s.numeroEvento % Convert.ToInt32(txtMostrarCada.Text) == 0)
                {
                    AgregarFila(s);
                }

                if (i == Convert.ToInt32(txtCantSim.Text) / 10)
                {
                    progressBar.Value = 10;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 2)
                {
                    progressBar.Value = 20;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 3)
                {
                    progressBar.Value = 30;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 4)
                {
                    progressBar.Value = 40;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 5)
                {
                    progressBar.Value = 50;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 60)
                {
                    progressBar.Value = 60;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 7)
                {
                    progressBar.Value = 70;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 8)
                {
                    progressBar.Value = 80;
                }
                if (i == Convert.ToInt32(txtCantSim.Text) / 10 * 9)
                {
                    progressBar.Value = 90;
                }
                if (i == Convert.ToInt32(txtCantSim.Text))
                {
                    progressBar.Value = 100;
                }
                i++;
            }
            lblPorcClientePerdido.Visible = true;
            lblPorcClientePerdido.Text    = StringifyCifra((double)(s.clientesPerdidos / (double)s.numeroCliente) * 100) + "%";
            progressBar.Visible           = false;
            btnGenerar.Visible            = true;
            dgvSimulacion.Enabled         = true;
        }
Exemple #2
0
        private void btnSimular_Click(object sender, EventArgs e)
        {
            dvgSim.Rows.Clear();
            LimpiarLabels();

            if (Validar())
            {
                MessageBox.Show("Los parámetros ingresados tienen que ser mayo a cero, y los maximos deben ser mayor que los minimos");
            }
            else
            {
                Condiciones      condiciones = ObtenerCondiciones();
                Simulacion       simulacion  = new Simulacion();
                EstadoSimulacion estado;
                bool             condicion;
                progresBar.Visible        = true;
                simulacion.estadoAnterior = new EstadoSimulacion(condiciones);
                AgregarFila(simulacion.estadoAnterior);
                do
                {
                    estado = simulacion.GenerarSimulacion(condiciones);

                    bool CambioHora = Math.Floor(((double)estado.tiempoProximoEvento / 3600)) > Math.Floor(((double)estado.tiempo / 3600));
                    if (CambioHora)
                    {
                        if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10)
                        {
                            progresBar.Value = 10;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 2)
                        {
                            progresBar.Value = 20;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 3)
                        {
                            progresBar.Value = 30;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 4)
                        {
                            progresBar.Value = 40;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 5)
                        {
                            progresBar.Value = 50;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 6)
                        {
                            progresBar.Value = 60;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 7)
                        {
                            progresBar.Value = 70;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 8)
                        {
                            progresBar.Value = 80;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 9)
                        {
                            progresBar.Value = 90;
                        }
                        else if (Math.Floor((double)(estado.tiempo / 3600)) < condiciones.HorasSimulacion / 10 * 10)
                        {
                            progresBar.Value = 100;
                        }
                    }
                    AgregarFila(estado);

                    bool condicion1 = !estado.equipo1.Libre || !estado.equipo2.Libre || !estado.equipo3.Libre || !estado.equipo4.Libre || !estado.equipo5.Libre;
                    bool condicion2 = estado.colaAlumnos.Count > 0;
                    bool condicion4 = estado.eventoActual != Evento.Final;

                    condicion = condicion1 || condicion2 || condicion4;
                }while (condicion);

                double porcentajeAbandono = (double)estado.AlumnosAbandono / (double)estado.numeroAlumno * 100;
                estado.PromedioInscripcionesSistema = estado.PromedioInscripciones1 + estado.PromedioInscripciones2 + estado.PromedioInscripciones3 + estado.PromedioInscripciones4 + estado.PromedioInscripciones5;
                // lblPorcentajeAbandono.Text = porcentajeAbandono.ToString() + "%";
                lblPorcentajeAbandono.Text = StringifyCifra(Math.Round(porcentajeAbandono, 2)) + " %";
                lblPromedio1.Text          = StringifyCifra(Math.Round(estado.PromedioInscripciones1, 2));
                lblPromedio2.Text          = StringifyCifra(Math.Round(estado.PromedioInscripciones2, 2));
                lblPromedio3.Text          = StringifyCifra(Math.Round(estado.PromedioInscripciones3, 2));
                lblPromedio4.Text          = StringifyCifra(Math.Round(estado.PromedioInscripciones4, 2));
                lblPromedio5.Text          = StringifyCifra(Math.Round(estado.PromedioInscripciones5, 2));
                lblPromedioSistema.Text    = StringifyCifra(Math.Round(estado.PromedioInscripcionesSistema, 2));

                progresBar.Visible = false;
            }
        }