Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var jsonObj = Pizzeria_RO.LoadJSON();

            totalIngredientes = jsonObj.ingredientes.Where(x => x.carta).OrderBy(x => x.nombre).ToList(); //only menu ingredients

            aTimer.Elapsed += ATimer_Elapsed;
            aTimer.Interval = 1000;

            btnAyuda.IsEnabled = false;

            respuestasIngredientes = new List <RespuestasIngredientes>();
            respTemp = new RespuestasIngredientes();
        }
Пример #2
0
        private void btnAceptar_Click(object sender, RoutedEventArgs e)
        {
            gbUltimaRespuesta.IsEnabled = true;
            int    valorSmall = 0, valorBig = 0;
            string strSmall = txbValorIndividual.Text.Replace(",", "").Replace("$", "").Replace(".", "").TrimStart('0');
            string strBig   = txbValorGrande.Text.Replace(",", "").Replace("$", "").Replace(".", "").TrimStart('0');

            if (strSmall.Length == 0)
            {
                strSmall = "0";
            }
            if (strBig.Length == 0)
            {
                strBig = "0";
            }

            if (!int.TryParse(strSmall, out valorSmall) || !int.TryParse(strBig, out valorBig))
            {
                MessageBox.Show("Hubo un error al ingresar los valor. Favor corregir e intentar nuevamente.",
                                "Error al ingresar valores",
                                MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
                return; //why are you like this dude, pls no :(
            }

            respTemp.NumeroRespuesta = numPreg;
            respTemp.nombre          = preguntasIngredientes[numPreg].nombre;
            respTemp.id                   = preguntasIngredientes[numPreg].id;
            respTemp.precio_big           = preguntasIngredientes[numPreg].precio_big;
            respTemp.precio_small         = preguntasIngredientes[numPreg].precio_small;
            respTemp.carta                = preguntasIngredientes[numPreg].carta;
            respTemp.precio_small_usuario = valorSmall;
            respTemp.precio_big_usuario   = valorBig;
            respTemp.EsRespuestaCorrecta  = (respTemp.precio_big == respTemp.precio_big_usuario) && (respTemp.precio_small == respTemp.precio_small_usuario); //both values

            respuestasIngredientes.Add(respTemp);

            CalcularTotales();

            txbValorGrande.Text     = "0";
            txbValorIndividual.Text = "0";

            lblUltimoIngrediente.Content       = preguntasIngredientes[numPreg].nombre;
            lblValorGrandeCorrecto.Content     = preguntasIngredientes[numPreg].precio_big.ToString("C0");
            lblValorIndividualCorrecto.Content = preguntasIngredientes[numPreg].precio_small.ToString("C0");
            lblValorGrandeUsuario.Content      = respuestasIngredientes[numPreg].precio_big_usuario.ToString("C0");
            lblValorIndividualUsuario.Content  = respuestasIngredientes[numPreg].precio_small_usuario.ToString("C0");

            var numMensajeRandom = new Random().Next(0, BaseLabels.ValidacionOK.Length);

            if (respuestasIngredientes[numPreg].EsRespuestaCorrecta)
            {
                var textoOk = BaseLabels.ValidacionOK[numMensajeRandom];
                imageRespuestaCorrecta.Source   = (numMensajeRandom > 0) ? imagenOk : imagenPepega;
                imageRespuestaIncorrecta.Source = null;
                tbSubtituloValidacion.Text      = textoOk;
            }
            else
            {
                imageRespuestaIncorrecta.Source = (numMensajeRandom > 0) ? imagenError : imagenLULW;
                imageRespuestaCorrecta.Source   = null;
                tbSubtituloValidacion.Text      = BaseLabels.ValidacionError[numMensajeRandom];
            }

            numPreg++;
            respTemp = new RespuestasIngredientes();

            if (numPreg < preguntasIngredientes.Count)
            {
                lblPregunta.Text = string.Format(BaseLabels.Questions[1], preguntasIngredientes[numPreg].nombre); //nueva pregunta
            }
            else
            {
                btnFinalizar_Click(sender, e);
            }
        }