Example #1
0
 public void AtualizarInformacoes(IFila fila)
 {
     this.fila = fila;
     Console.WriteLine("Fila possui " + fila.Itens + " itens. pode-se disparar job de requisição e reconhecimento aqui");
 }
 public PessoaRepository(ApplicationDbContext appDBContext, IFila <Pessoa> fila) : base(appDBContext)
 {
     this.fila = fila;
 }
Example #3
0
        private void OnBtnGenerarClick(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txtDiasAGenerar.Text))
                {
                    throw new ArgumentException("Debes ingresar la cantidad de días a generar");
                }

                if (String.IsNullOrEmpty(txtCantDocenas.Text) && !chkDemandaDiaAnterior.Checked)
                {
                    throw new ArgumentException("Debes ingresar la cantidad de docenas a comprar");
                }

                if (String.IsNullOrEmpty(txtDiaDesde.Text))
                {
                    throw new ArgumentException("Debes ingresar el día desde a mostrar en la tabla");
                }

                if (String.IsNullOrEmpty(txtPrecioCompraDocena.Text))
                {
                    throw new ArgumentException("Debes ingresar el precio de compra por docena");
                }

                if (String.IsNullOrEmpty(txtPrecioVentaRosa.Text))
                {
                    throw new ArgumentException("Debes ingresar el precio de venta de rosa");
                }

                Stopwatch watch = new Stopwatch();
                watch.Start();
                gridRosas.Rows.Clear();
                Random random = new Random();

                int.TryParse(txtDiasAGenerar.Text, out int cantidadDiasAGenerar);
                int.TryParse(txtCantDocenas.Text, out int cantidadAComprar);
                int.TryParse(txtDiaDesde.Text, out int diaDesde);
                double.TryParse(txtPrecioCompraDocena.Text, out double precioCompraDocena);
                double.TryParse(txtPrecioVentaRosa.Text, out double precioPorRosa);
                double precioPorDocena  = precioPorRosa * 12;
                double precioCementerio = this.valorVentaCementerioPorUnidad * 12;
                double costoAdicional   = this.costoAdicionalPorUnidad * 12;

                if (cantidadDiasAGenerar <= 0)
                {
                    throw new ArgumentException("La cantidad de días a generar debe ser mayor a 0");
                }

                if (diaDesde <= 0)
                {
                    throw new ArgumentException("El dia desde debe ser mayor a 0");
                }
                if (diaDesde > cantidadDiasAGenerar)
                {
                    throw new ArgumentException("No se puede mostrar iteraciones para días que no han sido simulados");
                }
                if (cantidadAComprar <= 0 && !chkDemandaDiaAnterior.Checked)
                {
                    throw new ArgumentException("La cantidad mínima a comprar debe ser mayor a 0");
                }
                if (precioCompraDocena <= 0)
                {
                    throw new ArgumentException("El precio de compra por docena debe ser mayor a 0");
                }
                if (precioPorRosa <= 0)
                {
                    throw new ArgumentException("El precio por rosa debe ser mayor a 0");
                }


                if (chkDemandaDiaAnterior.Checked)
                {
                    cantidadAComprar = demandaDia0;
                }

                IFila anterior = null;
                IFila actual   = null;

                for (int dia = 1; dia <= cantidadDiasAGenerar; dia++)
                {
                    if (rdbSinCostoAdicional.Checked && rdbDesechar.Checked)
                    {
                        actual = new FilaSinCostoAdicionalDesechar(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena);
                    }
                    else if (rdbSinCostoAdicional.Checked && rdbVenderCementerio.Checked)
                    {
                        actual = new FilaSinCostoAdicionalVenderCementerio(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena, precioCementerio);
                    }
                    else if (rdbConCostoAdicional.Checked && rdbDesechar.Checked)
                    {
                        actual = new FilaConCostoAdicionalDesechar(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena, costoAdicional);
                    }
                    else if (rdbConCostoAdicional.Checked && rdbVenderCementerio.Checked)
                    {
                        actual = new FilaConCostoAdicionalVenderCementerio(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena, costoAdicional, precioCementerio);
                    }
                    else if (rdbCubrirFaltante.Checked && rdbDesechar.Checked)
                    {
                        actual = new FilaCubrirFaltanteDesechar(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena, this.costoCubrirFaltantePorDocena);
                    }
                    else
                    {
                        actual = new FilaCubrirFaltanteVenderCementerio(dia, random, cantidadAComprar, precioCompraDocena, precioPorDocena, this.costoCubrirFaltantePorDocena, precioCementerio);
                    }

                    if (dia == 1)
                    {
                        actual.acumGanancia = actual.gananciaDiariaNeta;
                    }
                    else
                    {
                        actual.acumGanancia += anterior.acumGanancia + actual.gananciaDiariaNeta;
                    }
                    anterior = actual;

                    if ((dia >= diaDesde && dia < diaDesde + 100) || dia == cantidadDiasAGenerar)
                    {
                        DataGridViewRow         fila                  = new DataGridViewRow();
                        DataGridViewTextBoxCell colDia                = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colRNDClima           = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colClima              = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colRNDDemanda         = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colDemanda            = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colCantVenta          = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colCantSobrante       = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colCantFaltante       = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colIngresoDiario      = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colIngresoSobrante    = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colGastoCompra        = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colGastoFaltante      = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colGananciaDiariaNeta = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell colGananciaAcum       = new DataGridViewTextBoxCell();

                        colDia.Value                = dia;
                        colRNDClima.Value           = actual.RNDClima;
                        colClima.Value              = actual.GetClima();
                        colRNDDemanda.Value         = actual.RNDDemanda;
                        colDemanda.Value            = actual.demanda;
                        colCantVenta.Value          = actual.cantVenta;
                        colCantSobrante.Value       = actual.cantSobrante;
                        colCantFaltante.Value       = actual.cantFaltante;
                        colIngresoDiario.Value      = actual.ingresoDiario.ToString("F2") + " $";
                        colIngresoSobrante.Value    = actual.ingresoSobrante.ToString("F2") + " $";
                        colGastoCompra.Value        = actual.costoCompra.ToString("F2") + " $";
                        colGastoFaltante.Value      = actual.costoFaltante.ToString("F2") + " $";
                        colGananciaDiariaNeta.Value = actual.gananciaDiariaNeta.ToString("F2") + " $";
                        colGananciaAcum.Value       = actual.acumGanancia.ToString("F2") + " $";

                        fila.Cells.Add(colDia);
                        fila.Cells.Add(colRNDClima);
                        fila.Cells.Add(colClima);
                        fila.Cells.Add(colRNDDemanda);
                        fila.Cells.Add(colDemanda);
                        fila.Cells.Add(colCantVenta);
                        fila.Cells.Add(colCantSobrante);
                        fila.Cells.Add(colCantFaltante);
                        fila.Cells.Add(colIngresoDiario);
                        fila.Cells.Add(colIngresoSobrante);
                        fila.Cells.Add(colGastoCompra);
                        fila.Cells.Add(colGastoFaltante);
                        fila.Cells.Add(colGananciaDiariaNeta);
                        fila.Cells.Add(colGananciaAcum);

                        gridRosas.Rows.Add(fila);
                    }

                    if (chkDemandaDiaAnterior.Checked)
                    {
                        cantidadAComprar = actual.demanda;
                    }
                }

                this.gridRosas.Rows[this.gridRosas.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Gold;

                watch.Stop();
                lblTimer.Text = String.Format("Tiempo en generar: {0:00}:{1:00}:{2:00}.{3:00}",
                                              watch.Elapsed.Hours, watch.Elapsed.Minutes, watch.Elapsed.Seconds,
                                              watch.Elapsed.Milliseconds / 10);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Hubo un error!", MessageBoxButtons.OK);
            }
        }