示例#1
0
        internal List <EvaluacionCorralInfo> ObtenerEvaluaciones(EvaluacionCorralInfo filtro)
        {
            List <EvaluacionCorralInfo> lista = null;

            try
            {
                Dictionary <string, object> parameters = AuxEvaluacionCorralDAL.ObtenerParametrosObtenerEvaluaciones(filtro);
                DataSet ds = Retrieve("EvaluacionPartida_ObtenerEvaluaciones", parameters);
                if (ValidateDataSet(ds))
                {
                    ResultadoInfo <EvaluacionCorralInfo> resultado = MapEvaluacionCorralDAL.ObtenerPorPagina(ds);
                    if (resultado != null && resultado.Lista != null)
                    {
                        lista = (List <EvaluacionCorralInfo>)resultado.Lista;
                    }
                }
            }
            catch (SqlException ex)
            {
                Logger.Error(ex);
                throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
            }
            catch (DataException ex)
            {
                Logger.Error(ex);
                throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(lista);
        }
        /// <summary>
        /// Metodo que obtiene los parametros para guardar una entrada
        /// </summary>
        /// <param name="evaluacionCorral"></param>
        /// <param name="tipoFolio"></param>
        /// <returns></returns>
        internal static Dictionary <string, object> ObtenerParametrosGuardado(EvaluacionCorralInfo evaluacionCorral, int tipoFolio)
        {
            Dictionary <string, object> parametros;

            try
            {
                Logger.Info();
                parametros = new Dictionary <string, object>
                {
                    { "@OrganizacionID", evaluacionCorral.Organizacion.OrganizacionID },
                    { "@CorralID", evaluacionCorral.Corral.CorralID },
                    { "@LoteID", evaluacionCorral.Lote.LoteID },
                    { "@Cabezas", evaluacionCorral.Cabezas },
                    { "@EsMetafilaxia", evaluacionCorral.EsMetafilaxia },
                    { "@OperadorID", evaluacionCorral.Operador.OperadorID },
                    { "@NivelGarrapata", evaluacionCorral.NivelGarrapata },
                    { "@Autorizado", evaluacionCorral.MetafilaxiaAutorizada },
                    { "@Justificacion", evaluacionCorral.Justificacion },
                    { "@UsuarioCreacion", evaluacionCorral.UsuarioCreacionID },
                    { "@TipoFolio", tipoFolio }
                };
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(parametros);
        }
示例#3
0
 /// <summary>
 /// Valida que los campos de Tipo Cadena Contengan valor no Nulo
 /// </summary>
 /// <param name="evaluacionCorralInfo"></param>
 internal void ValidaCamposEntradaGanado(EvaluacionCorralInfo evaluacionCorralInfo)
 {
     if (String.IsNullOrWhiteSpace(evaluacionCorralInfo.Justificacion))
     {
         evaluacionCorralInfo.Justificacion = String.Empty;
     }
 }
示例#4
0
        /// <summary>
        ///     Metodo que crear una evaluacion de Riesgos de Partida
        /// </summary>
        /// <param name="evaluacionCorral"></param>
        /// <param name="tipoFolio"></param>

        internal int GuardarEvaluacionCorral(EvaluacionCorralInfo evaluacionCorral, int tipoFolio)
        {
            int evaluacionCorralID;

            try
            {
                Logger.Info();
                Dictionary <string, object> parametros = AuxEvaluacionCorralDAL.ObtenerParametrosGuardado(evaluacionCorral, tipoFolio);
                evaluacionCorralID = Create("EvaluacionCorral_Crear", parametros);
            }
            catch (SqlException ex)
            {
                Logger.Error(ex);
                throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
            }
            catch (DataException ex)
            {
                Logger.Error(ex);
                throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(evaluacionCorralID);
        }
示例#5
0
        public static List <EvaluacionCorralInfo> TraerCorralesEvaluados(string filtroEvaluacion)
        {
            List <EvaluacionCorralInfo> corrales = null;

            try
            {
                var seguridad       = (SeguridadInfo)ObtenerSeguridad();
                var evaluacionPL    = new EvaluacionCorralPL();
                var filtros         = new EvaluacionCorralInfo();
                var fechaEvaluacion = DateTime.Parse(filtroEvaluacion);

                filtros = new EvaluacionCorralInfo
                {
                    FechaEvaluacion = fechaEvaluacion,
                    Organizacion    = new OrganizacionInfo()
                    {
                        OrganizacionID = seguridad.Usuario.Organizacion.OrganizacionID
                    },
                };

                corrales = evaluacionPL.ObtenerEvaluaciones(filtros);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(corrales);
        }
示例#6
0
 /// <summary>
 ///     Metodo que crea una evaluacion corral
 /// </summary>
 /// <param name="evaluacionCorral"></param>
 /// <param name="tipoFolio"></param>
 public int GuardarEvaluacionCorral(EvaluacionCorralInfo evaluacionCorral, int tipoFolio)
 {
     try
     {
         Logger.Info();
         var evaluacionCorralBL = new EvaluacionCorralBL();
         return(evaluacionCorralBL.GuardarEvaluacionCorral(evaluacionCorral, tipoFolio));
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
示例#7
0
 public void ImprimirEvaluacionPartida(EvaluacionCorralInfo evaluacionCorralInfoSelecionado, bool webForm)
 {
     try
     {
         Logger.Info();
         var evaluacionBL = new EvaluacionCorralBL();
         evaluacionBL.ImprimirEvaluacionPartida(evaluacionCorralInfoSelecionado, webForm);
     }
     catch (ExcepcionGenerica ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
示例#8
0
 public List <EvaluacionCorralInfo> ObtenerEvaluaciones(EvaluacionCorralInfo filtros)
 {
     try
     {
         Logger.Info();
         var evaluacionBL = new EvaluacionCorralBL();
         List <EvaluacionCorralInfo> result = evaluacionBL.ObtenerEvaluaciones(filtros);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
        /// <summary>
        /// Obtiene la lista para mostrar en el grid
        /// </summary>
        private void ObtenerListaEvaluacion(int inicio, int limite)
        {
            try
            {
                var evaluacionPL             = new EvaluacionCorralPL();
                EvaluacionCorralInfo filtros = ObtenerFiltros();
                var pagina = new PaginacionInfo {
                    Inicio = inicio, Limite = limite
                };
                ResultadoInfo <EvaluacionCorralInfo> resultadoInfo = evaluacionPL.ObtenerPorPagina(pagina, filtros);
                if (resultadoInfo != null && resultadoInfo.Lista != null &&
                    resultadoInfo.Lista.Count > 0)
                {
                    gridDatos.ItemsSource       = resultadoInfo.Lista;
                    ucPaginacion.TotalRegistros = resultadoInfo.TotalRegistros;
                }
                else
                {
                    ucPaginacion.TotalRegistros = 0;
                    ucPaginacion.AsignarValoresIniciales();
                    gridDatos.ItemsSource = new List <EvaluacionCorralInfo>();

                    string mensaje = Properties.Resources.EvaluacionPartida_MsgNoHayRegistros;

                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    dtpFecha.Focus();
                }
            }
            catch (ExcepcionGenerica ex)
            {
                Logger.Error(ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
示例#10
0
        /// <summary>
        ///     Metodo que crear una evaluacion de riesgo de partida
        /// </summary>
        /// <param name="evaluacionCorral"></param>
        /// <param name="tipoFolio"></param>
        internal int GuardarEvaluacionCorral(EvaluacionCorralInfo evaluacionCorral, int tipoFolio)
        {
            try
            {
                Logger.Info();
                var evaluacionCorralDAL = new EvaluacionCorralDAL();

                ValidaCamposEntradaGanado(evaluacionCorral);

                using (var transaccion = new TransactionScope())
                {
                    int evaluacionID = 0;
                    evaluacionID = evaluacionCorralDAL.GuardarEvaluacionCorral(evaluacionCorral, tipoFolio);
                    if (evaluacionID > 0)
                    {
                        evaluacionCorralDAL.GuardarEvaluacionCorralDetalle(evaluacionCorral.PreguntasEvaluacionCorral, evaluacionID);
                    }
                    else
                    {
                        throw new ExcepcionDesconocida("NO SE PUEDE GUARDAR LA EVALUACION DEL CORRAL");
                    }

                    transaccion.Complete();
                    return(evaluacionID);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
        /// <summary>
        /// Obtiene los filtros de la consulta
        /// </summary>
        /// <returns></returns>
        private EvaluacionCorralInfo ObtenerFiltros()
        {
            EvaluacionCorralInfo filtro = null;

            try
            {
                DateTime fechaEvaluacion = Convert.ToDateTime(dtpFecha.SelectedDate);
                filtro = new EvaluacionCorralInfo
                {
                    FechaEvaluacion = fechaEvaluacion,
                    Organizacion    = new OrganizacionInfo()
                    {
                        OrganizacionID = organizacionID
                    },
                    /*Activo = (bool)EstatusEnum.Activo*/
                };
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                //throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(filtro);
        }
示例#12
0
 public static Response <EvaluacionCorralInfo> ImprimirCorralesEvaluados(EvaluacionCorralInfo evaluacionCorralInfo)
 {
     try
     {
         if (evaluacionCorralInfo != null)
         {
             var evaluacionCorralPL = new EvaluacionCorralPL();
             evaluacionCorralPL.ImprimirEvaluacionPartida(evaluacionCorralInfo, true);
         }
     }
     catch (ExcepcionDesconocida ex)
     {
         Logger.Error(ex);
         return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(false,
                                                                                           (ex.InnerException == null ? ex.Message : ex.InnerException.Message)));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(false,
                                                                                           (ex.InnerException == null ? ex.Message : ex.InnerException.Message)));
     }
     return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(true, "OK"));
 }
        public static Dictionary <string, object> ObtenerParametrosPorPagina(PaginacionInfo pagina, EvaluacionCorralInfo filtro)
        {
            Dictionary <string, object> parametros;

            try
            {
                Logger.Info();

                parametros = new Dictionary <string, object>
                {
                    { "@OrganizacionID", filtro.Organizacion.OrganizacionID },
                    { "@FechaEvaluacion", filtro.FechaEvaluacion },
                    { "@Inicio", pagina.Inicio },
                    { "@Limite", pagina.Limite }
                };
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(parametros);
        }
示例#14
0
        internal ResultadoInfo <EvaluacionCorralInfo> ObtenerPorPagina(PaginacionInfo pagina, EvaluacionCorralInfo filtro)
        {
            ResultadoInfo <EvaluacionCorralInfo> result;

            try
            {
                Logger.Info();
                var evaluacionDAL = new EvaluacionCorralDAL();
                result = evaluacionDAL.ObtenerPorPagina(pagina, filtro);
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(result);
        }
示例#15
0
        internal void ImprimirEvaluacionPartida(EvaluacionCorralInfo evaluacionCorralInfoSelecionado, bool webForm)
        {
            var reporte      = new Document(PageSize.A4, 10, 10, 35, 75);
            var preguntaPl   = new PreguntaBL();
            var evaluacionBL = new EvaluacionCorralBL();

            try
            {
                string nombreArchivo = "EvaluacionPartida.pdf";

                nombreArchivo = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, nombreArchivo);

                if (File.Exists(nombreArchivo))
                {
                    try
                    {
                        File.Delete(nombreArchivo);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex);
                        throw new ExcepcionDesconocida(ResourceServices.ConfigurarFormula_ArchivoEnUso);
                    }
                }

                PdfWriter.GetInstance(reporte, new FileStream(nombreArchivo, FileMode.OpenOrCreate));
                reporte.Open();
                var dirLogo = "";

                if (webForm)
                {
                    dirLogo = AppDomain.CurrentDomain.BaseDirectory + "Images\\skLogo.png";
                }
                else
                {
                    dirLogo = AppDomain.CurrentDomain.BaseDirectory + "Imagenes\\skLogo.png";
                }

                var fuenteDatos = new Font {
                    Size = 8, Color = Color.BLACK
                };

                var imgSuperior = Image.GetInstance(dirLogo);
                imgSuperior.ScaleAbsolute(90f, 25f);

                //float[] medidaCeldas = { 0.75f, 1.20f, 0.75f, 0.75f, 0.75f, 1.20f, 1.0f, 2.25f, 0.85f, 0.85f, 0.85f };
                var table = new PdfPTable(3);
                //table.SetWidths(medidaCeldas);
                //

                //////TITULO
                var cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_CodigoISO, fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = 0
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_RevisionISO, fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border = 0
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_FechaISO, fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border = 0
                };
                table.AddCell(cell);
                //Estapacio en blanco
                cell = new PdfPCell(new Phrase(" ", fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = 0,
                    Colspan = 3
                };
                table.AddCell(cell);

                cell = new PdfPCell(imgSuperior)
                {
                    Padding = 2, Border = 0
                };
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                cell.Border          = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER;
                cell.BorderWidth     = 1.2f;
                cell.BackgroundColor = Color.RED;// new Color(0xC0, 0xC0, 0xC0);
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_TituloImpresion, FontFactory.GetFont(FontFactory.HELVETICA, 14, Font.BOLD)));
                // the first cell spans 10 columns
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                cell.Colspan             = 10;
                cell.Border          = Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER;
                cell.BorderWidth     = 1.2f;
                cell.BackgroundColor = Color.RED;// new Color(0xC0, 0xC0, 0xC0);
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("", fuenteDatos))
                {
                    Border = 0
                };
                table.AddCell(cell);
                reporte.Add(table);


                //////////////Datos generales
                table = new PdfPTable(8);
                //BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
                //Font fuenteDatosCursiva = new Font(bfTimes, 9, Font.ITALIC, Color.RED);

                var fuenteDatosCursiva = new Font {
                    Size = 9, Color = Color.BLACK,
                };

                cell = new PdfPCell(new Phrase(" ", fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.RIGHT_BORDER | Rectangle.LEFT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_Corral, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.LEFT_BORDER
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.Corral.Codigo.Trim(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border = 0
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_SubTituloImpresion, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.RIGHT_BORDER,
                    Colspan = 6
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_Cbz, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.LEFT_BORDER,
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.Cabezas.ToString(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border = 0
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.RIGHT_BORDER,
                    Colspan = 6
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_NumPartida, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border  = Rectangle.LEFT_BORDER,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.PartidasAgrupadas, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border = Rectangle.BOTTOM_BORDER,
                    //BorderWidth = 1.0f,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_FechaLlegada, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border  = 0,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.FechaRecepcion.ToShortDateString(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_ProcedenciaAnimales, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border  = Rectangle.LEFT_BORDER,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.OrganizacionOrigenAgrupadas, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.BOTTOM_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_FechaEvaluacion, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border  = 0,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.FechaEvaluacion.ToShortDateString(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border = Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);


                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_InventarioInicial, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border  = Rectangle.LEFT_BORDER,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.Cabezas.ToString(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border  = 0,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_Evaluador, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    VerticalAlignment   = Element.ALIGN_BOTTOM,
                    Border  = Rectangle.NO_BORDER,
                    Colspan = 2
                };
                table.AddCell(cell);

                var operadorBL = new OperadorBL();
                evaluacionCorralInfoSelecionado.Operador = operadorBL.ObtenerPorID(evaluacionCorralInfoSelecionado.Operador.OperadorID);
                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.Operador.NombreCompleto, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);

                ResultadoInfo <PreguntaInfo> resultadoPreguntasEnfermeria =
                    preguntaPl.ObtenerPorFormularioID((int)TipoPreguntas.DatosEnfermeria);
                var animalesGrado3 = 0;
                foreach (string respuesta in
                         from pregunta in resultadoPreguntasEnfermeria.Lista
                         where pregunta.Descripcion.Contains("Grado 3")
                         select evaluacionBL.ObtenerRespuestaAPreguntaEvaluacion(
                             pregunta.PreguntaID,
                             evaluacionCorralInfoSelecionado.EvaluacionID
                             )
                         )
                {
                    animalesGrado3 = int.Parse(respuesta);
                }

                //Se calcula el inventario final (Inventario Inicial - Grado 3)
                var inventarioFinal = evaluacionCorralInfoSelecionado.Cabezas;

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_InventarioFinal, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border  = Rectangle.LEFT_BORDER,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase((inventarioFinal - animalesGrado3).ToString(), fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = 0,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_HoraEvaluacion, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border  = 0,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.HoraEvaluacion, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border = Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                /////////////////Preguntas seccion 1

                ResultadoInfo <PreguntaInfo> resultadoPreguntas = preguntaPl.ObtenerPorFormularioID((int)TipoPreguntas.EvaluacionRiesgo);
                var total = 0;
                if (resultadoPreguntas != null && resultadoPreguntas.Lista != null && resultadoPreguntas.Lista.Count > 0)
                {
                    foreach (var pregunta in resultadoPreguntas.Lista)
                    {
                        string respuesta = evaluacionBL.ObtenerRespuestaAPreguntaEvaluacion(
                            pregunta.PreguntaID,
                            evaluacionCorralInfoSelecionado.EvaluacionID
                            );
                        string[] preguntasValor = pregunta.Descripcion.Split('.');
                        cell = new PdfPCell(new Phrase(preguntasValor[0], fuenteDatosCursiva))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT,
                            Border  = Rectangle.LEFT_BORDER,
                            Colspan = 6
                        };
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase(respuesta, fuenteDatosCursiva))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT,
                            Border = Rectangle.RECTANGLE | Rectangle.TOP_BORDER,
                            //BorderWidth = 1.2f,
                            Colspan = 2
                        };
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase(preguntasValor[1], fuenteDatosCursiva))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT,
                            Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                            Colspan = 8
                        };
                        table.AddCell(cell);

                        if (respuesta == "1")
                        {
                            preguntasValor[1] = Regex.Replace(preguntasValor[1], "[^0-9]+", "");
                            total            += int.Parse(preguntasValor[1]);
                        }
                    }
                }
                /////////////Total

                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_Total, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border  = Rectangle.LEFT_BORDER,
                    Colspan = 6
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(total.ToString(), fuenteDatosCursiva))
                {
                    BackgroundColor     = new Color(169, 245, 242),
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    Border = Rectangle.RECTANGLE | Rectangle.TOP_BORDER,
                    //BorderWidth = 1.2f,
                    Colspan = 2
                };
                table.AddCell(cell);


                /////////////////Preguntas Nota
                cell = new PdfPCell(new Phrase(" ", fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_Nota, fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);



                /////////////////Preguntas seccion Enfermeria
                cell = new PdfPCell(new Phrase(" ", fuenteDatosCursiva))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                var fuenteDatosEnfermeria = new Font {
                    Size = 8, Color = Color.BLACK
                };
                string[] textosPartidasGarrapatas = new[] { "PARTIDA CON GARRAPATA", "LEVE ≤ 5 cbz", "MODERADO > 5 cbz", "GRAVE ≥ 15 cbz" };

                if (resultadoPreguntasEnfermeria != null && resultadoPreguntasEnfermeria.Lista != null && resultadoPreguntasEnfermeria.Lista.Count > 0)
                {
                    var indice = 0;
                    foreach (var pregunta in resultadoPreguntasEnfermeria.Lista)
                    {
                        string respuesta = evaluacionBL.ObtenerRespuestaAPreguntaEvaluacion(
                            pregunta.PreguntaID,
                            evaluacionCorralInfoSelecionado.EvaluacionID
                            );
                        cell = new PdfPCell(new Phrase(pregunta.Descripcion, fuenteDatosEnfermeria))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT,
                            Border  = Rectangle.LEFT_BORDER,
                            Colspan = 3
                        };
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase(respuesta, fuenteDatosEnfermeria))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT,
                            VerticalAlignment   = Element.ALIGN_BOTTOM,
                            Border = Rectangle.BOTTOM_BORDER,
                            //BorderWidth = 1.2f,
                            Colspan = 1
                        };
                        table.AddCell(cell);

                        if (indice < 4)
                        {
                            if (indice == 0)
                            {
                                var texto = String.Format("{0}", textosPartidasGarrapatas[indice]);
                                cell = new PdfPCell(new Phrase(texto, fuenteDatosEnfermeria))
                                {
                                    HorizontalAlignment = Element.ALIGN_CENTER,
                                    Border  = Rectangle.NO_BORDER,
                                    Colspan = 3
                                };
                                table.AddCell(cell);
                            }
                            else
                            {
                                var texto = "";
                                texto = String.Format("{0}    {1}", textosPartidasGarrapatas[indice],
                                                      textosPartidasGarrapatas[indice].Contains(
                                                          evaluacionCorralInfoSelecionado.NivelGarrapata.ToString().ToUpper()) ? "(X)" : "(   )");

                                cell = new PdfPCell(new Phrase(texto, fuenteDatosEnfermeria))
                                {
                                    HorizontalAlignment = Element.ALIGN_RIGHT,
                                    Border  = Rectangle.NO_BORDER,
                                    Colspan = 2
                                };
                                table.AddCell(cell);

                                cell = new PdfPCell(new Phrase("", fuenteDatosEnfermeria))
                                {
                                    HorizontalAlignment = Element.ALIGN_CENTER,
                                    Border = Rectangle.NO_BORDER
                                };
                                table.AddCell(cell);
                            }

                            cell = new PdfPCell(new Phrase("", fuenteDatosEnfermeria))
                            {
                                HorizontalAlignment = Element.ALIGN_CENTER,
                                Border = Rectangle.RIGHT_BORDER
                            };
                            table.AddCell(cell);
                        }
                        else
                        {
                            cell = new PdfPCell(new Phrase(" ", fuenteDatosEnfermeria))
                            {
                                HorizontalAlignment = Element.ALIGN_CENTER,
                                Border  = Rectangle.RIGHT_BORDER,
                                Colspan = 4
                            };
                            table.AddCell(cell);
                        }

                        indice++;
                    }
                }

                ///////////Partida con garrapata
                //////////Aseguir con metafilaxia

                cell = new PdfPCell(new Phrase(" ", fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                if (evaluacionCorralInfoSelecionado.EsMetafilaxia ||
                    evaluacionCorralInfoSelecionado.MetafilaxiaAutorizada)
                {
                    cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_AccionASeguirMetafilaxia, fuenteDatosEnfermeria))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT,
                        Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                        Colspan = 8
                    };
                    table.AddCell(cell);

                    /* Metafilaxia Autorizada */
                    if (evaluacionCorralInfoSelecionado.MetafilaxiaAutorizada)
                    {
                        cell =
                            new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_AccionASeguirMetafilaxiaJustificacion,
                                                    fuenteDatosEnfermeria))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT,
                            Border  = Rectangle.LEFT_BORDER,
                            Colspan = 1
                        };
                        table.AddCell(cell);

                        cell =
                            new PdfPCell(new Phrase(evaluacionCorralInfoSelecionado.Justificacion,
                                                    fuenteDatosEnfermeria))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT,
                            Border  = Rectangle.RIGHT_BORDER,
                            Colspan = 7
                        };
                        table.AddCell(cell);
                    }
                }
                else
                {
                    cell = new PdfPCell(new Phrase(ResourceServices.EvaluacionPartida_AccionASeguirNormal, fuenteDatosEnfermeria))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT,
                        Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER,
                        Colspan = 8
                    };
                    table.AddCell(cell);
                }

                cell = new PdfPCell(new Phrase(" ", fuenteDatos))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    Border  = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.BOTTOM_BORDER,
                    Colspan = 8
                };
                table.AddCell(cell);

                reporte.Add(table);

                reporte.Close();

                if (!webForm)
                {
                    SendToPrinter(nombreArchivo);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (DocumentException ex)
            {
                Logger.Error(ex);
                reporte.Close();
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            catch (IOException ex)
            {
                Logger.Error(ex);
                reporte.Close();
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                reporte.Close();
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
 public static Response <EvaluacionCorralInfo> GuardarEvaluacion(EvaluacionCorralInfo evaluacionCorralInfo)
 {
     try
     {
         var usuario        = HttpContext.Current.Session["Seguridad"] as SeguridadInfo;
         int organizacionID = 0;
         int usuarioID      = 0;
         if (usuario != null)
         {
             organizacionID = usuario.Usuario.Organizacion.OrganizacionID;
             usuarioID      = usuario.Usuario.UsuarioID;
         }
         var guardarPl = new EvaluacionCorralPL();
         var listaGuardarEvaluacion = new EvaluacionCorralInfo
         {
             Organizacion =
                 new OrganizacionInfo {
                 OrganizacionID = organizacionID
             },
             Corral =
                 new CorralInfo
             {
                 CorralID = evaluacionCorralInfo.Corral.CorralID
             },
             Lote = new LoteInfo {
                 LoteID = evaluacionCorralInfo.Lote.LoteID
             },
             Cabezas               = evaluacionCorralInfo.Cabezas,
             EsMetafilaxia         = evaluacionCorralInfo.EsMetafilaxia,
             MetafilaxiaAutorizada = evaluacionCorralInfo.MetafilaxiaAutorizada,
             Operador              =
                 new OperadorInfo
             {
                 OperadorID = usuario.Usuario.Operador.OperadorID
             },
             NivelGarrapata            = evaluacionCorralInfo.NivelGarrapata,
             Justificacion             = evaluacionCorralInfo.Justificacion,
             UsuarioCreacionID         = usuarioID,
             UsuarioModificacionID     = usuarioID,
             PreguntasEvaluacionCorral =
                 evaluacionCorralInfo.PreguntasEvaluacionCorral
         };
         listaGuardarEvaluacion.PreguntasEvaluacionCorral.ToList().ForEach(clave =>
         {
             clave.UsuarioCreacion =
                 usuarioID;
             clave.UsuarioModificacion =
                 usuarioID;
         });
         int respuestaMetodo = guardarPl.GuardarEvaluacionCorral(listaGuardarEvaluacion, (int)TipoFolio.EvaluacionPartida);
         if (respuestaMetodo != 0)
         {
             return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(true,
                                                                                               "GuardadoExito"));
         }
         return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(false,
                                                                                           "ErrorGuardar"));
     }
     catch (Exception ex)
     {
         return(Response <EvaluacionCorralInfo> .CrearResponseVacio <EvaluacionCorralInfo>(false, ex.InnerException.Message));
     }
 }