Ejemplo n.º 1
0
 private void Tb_KeyDown(object sender, KeyEventArgs e)
 {
     // Si pulsamos Enter, actuamos, según sea el textbox que ha producido el evento.
     if (e.Key == Key.Enter)
     {
         TextBox tb = (TextBox)sender;
         if (tb == TbNumero)
         {
             if (ChDeducirTurno.IsChecked == true)
             {
                 TbValoracion.Focus();
             }
             else
             {
                 TbTurno.Focus();
             }
             e.Handled = true;
         }
         else if (tb == TbTurno)
         {
             TbValoracion.Focus();
             e.Handled = true;
         }
         else if (tb == TbValoracion)
         {
             TbInicio.Focus();
             e.Handled = true;
         }
         else if (tb == TbInicio)
         {
             TbFinal.Focus();
             e.Handled = true;
         }
         else if (tb == TbFinal)
         {
             if (TbInicioPartido.IsVisible)
             {
                 TbInicioPartido.Focus();
                 e.Handled = true;
             }
         }
         else if (tb == TbInicioPartido)
         {
             TbFinalPartido.Focus();
             e.Handled = true;
         }
     }
 }
Ejemplo n.º 2
0
        public async Task <int> agregaTurnoJsonAsync(Turno turno)
        {
            int resultado;

            try
            {
                var itemTurno = new TbTurno
                {
                    IdUsuario         = turno.IdUsuario,
                    FechaHoraApertura = Convert.ToDateTime(turno.FechaHoraApertura),
                    FechaHoraCierre   = Convert.ToDateTime(turno.FechaHoraCierre),
                    FondoFijo         = Convert.ToDecimal(turno.FondoFijo),
                    FondoVenta        = Convert.ToDecimal(turno.FondoVenta),
                    TotalCierre       = Convert.ToDecimal(turno.TotalCierre),
                    EntregaCompleta   = turno.EntregaCompleta
                };
                context.TbTurno.Add(itemTurno);
                resultado = await context.SaveChangesAsync();

                foreach (Fondo fondo in turno.ItemsFondo)
                {
                    var itemFondo = new TbFondo
                    {
                        FKIdDenominacion   = fondo.IdDenominacion,
                        FKIdTipoMovimiento = fondo.IdTipoMovimiento,
                        FKIdTurno          = itemTurno.PKIdTurno,
                        Cantidad           = fondo.Cantidad
                    };
                    context.TbFondo.Add(itemFondo);
                    var res = await context.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                var message = $"Ocurrio un error al registrar el turno con Id de Usuario : {turno.IdUsuario}";
                throw new IOException(message, e);
            }
            return(resultado);
        }