Beispiel #1
0
 private void TxtCorralLostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(Contexto.CorralInfo.Codigo))
         {
             var lotePL = new LotePL();
             IEnumerable <LoteInfo> lotes =
                 lotePL.ObtenerPorCodigoCorralOrganizacionID(Contexto.OrganizacionId, Contexto.CorralInfo.Codigo);
             bool valido = ValidarCorral(lotes);
             if (valido)
             {
                 var      animalPL = new AnimalPL();
                 LoteInfo lote     = lotes.ToList().FirstOrDefault(activo => activo.Activo == EstatusEnum.Activo);
                 if (lote != null)
                 {
                     List <AnimalInfo> animales =
                         animalPL.ObtenerAnimalesPorLote(Contexto.OrganizacionId, lote.LoteID);
                     Contexto.LoteInfo   = lote;
                     Contexto.CorralInfo = lote.Corral;
                     ObtenerValoresGanado(animales);
                     ObtenerPesos();
                     ObtenerFormula();
                     ObtenerDiasEngorda(animales);
                 }
                 if (!listadoDeTraspaso.Any())
                 {
                     chkTraspasoGanado.IsEnabled   = true;
                     chkSacrificioGanado.IsEnabled = true;
                 }
             }
             else
             {
                 if (Contexto.LoteInfo.Corral == null)
                 {
                     Contexto.LoteInfo.Corral = new CorralInfo();
                 }
                 Contexto.LoteInfo.Corral.Codigo = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                           Properties.Resources.TraspasoGanadoGordo_MensajeErrorConsultarCorral,
                           MessageBoxButton.OK, MessageImage.Error);
     }
 }