Esempio n. 1
0
        private void GenerarArchivo(CheckListCorralInfo checkList)
        {
            var file = new SaveFileDialog {
                FileName = "CheckList", Filter = @"Archivos PDF|*.pdf", Title = @"Guardar Archivo PDF"
            };
            var result = file.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (file.FileName != "")
                {
                    if (File.Exists(file.FileName))
                    {
                        try
                        {
                            var archivoPDF = new FileStream(file.FileName, FileMode.Open);
                            archivoPDF.Close();
                        }
                        catch (IOException)
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.ImpresionCierreCorral_ArchivoAbierto, MessageBoxButton.OK, MessageImage.Warning);
                            //throw new ExcepcionServicio(Properties.Resources.ExportarExcel_ArchivoAbierto);
                        }
                    }
                    File.WriteAllBytes(file.FileName, checkList.PDF);
                    Process.Start(file.FileName);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Obtiene un registro de CheckListCorral
 /// </summary>
 /// <param name="filtro">identificador del Lote</param>
 /// <returns></returns>
 internal LoteProyeccionInfo GenerarProyeccion(CheckListCorralInfo filtro)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxCheckListCorralDAL.ObtenerParametrosGenerarProyeccion(filtro);
         DataSet            ds     = Retrieve("GenerarProyeccion", parameters);
         LoteProyeccionInfo result = null;
         if (ValidateDataSet(ds))
         {
             result = MapCheckListCorralDAL.GenerarProyeccion(ds);
         }
         return(result);
     }
     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);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Obtiene un registro de CheckListCorral
 /// </summary>
 /// <param name="loteID">identificador del Lote</param>
 /// <param name="organizacionID">identificador de la Organización</param>
 /// <returns></returns>
 internal CheckListCorralInfo ObtenerPorLote(int organizacionID, int loteID)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxCheckListCorralDAL.ObtenerParametrosPorLote(organizacionID, loteID);
         DataSet             ds     = Retrieve("CheckListCorral_ObtenerCheckListPorLote", parameters);
         CheckListCorralInfo result = null;
         if (ValidateDataSet(ds))
         {
             result = MapCheckListCorralDAL.ObtenerPorLote(ds);
         }
         return(result);
     }
     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);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Metodo para Crear un registro de CheckListCorral
 /// </summary>
 /// <param name="info">Valores de la entidad que será creada</param>
 internal int Crear(CheckListCorralInfo info)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxCheckListCorralDAL.ObtenerParametrosCrear(info);
         int result = Create("CheckListCorral_Crear", parameters);
         return(result);
     }
     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);
     }
 }
Esempio n. 5
0
        private void GuardarProyeccion(CheckListCorralInfo checkListCorral, CheckListCorralDAL checkListCorralDAL)
        {
            var loteProyeccion          = checkListCorralDAL.GenerarProyeccion(checkListCorral);
            var loteProyeccionBL        = new LoteProyeccionPL();
            var listaReimplantesGuardar = new List <LoteReimplanteInfo>();

            if (loteProyeccion == null)
            {
                return;
            }
            loteProyeccion.UsuarioCreacionID = checkListCorral.UsuarioCreacionID;
            loteProyeccion.RequiereRevision  = checkListCorral.RequiereRevision;
            var loteProyeccionID = loteProyeccionBL.Guardar(loteProyeccion);

            var primerReimplante = new LoteReimplanteInfo
            {
                LoteProyeccionID  = loteProyeccionID,
                NumeroReimplante  = loteProyeccion.Proyeccion.PrimerReimplante,
                FechaProyectada   = loteProyeccion.Proyeccion.FechaProyectada1,
                PesoProyectado    = loteProyeccion.Proyeccion.PesoProyectado1,
                UsuarioCreacionID = checkListCorral.UsuarioCreacionID
            };

            if (primerReimplante.NumeroReimplante != 0 && primerReimplante.FechaProyectada != DateTime.MinValue && primerReimplante.PesoProyectado != 0)
            {
                listaReimplantesGuardar.Add(primerReimplante);
            }

            var segundoReimplante = new LoteReimplanteInfo
            {
                LoteProyeccionID  = loteProyeccionID,
                NumeroReimplante  = loteProyeccion.Proyeccion.SegundoReimplante,
                FechaProyectada   = loteProyeccion.Proyeccion.FechaProyectada2,
                PesoProyectado    = loteProyeccion.Proyeccion.PesoProyectado2,
                UsuarioCreacionID = checkListCorral.UsuarioCreacionID
            };

            if (segundoReimplante.NumeroReimplante != 0 && segundoReimplante.FechaProyectada != DateTime.MinValue && segundoReimplante.PesoProyectado != 0)
            {
                listaReimplantesGuardar.Add(segundoReimplante);
            }

            var loteReimplanteBL = new LoteReimplanteBL();

            if (listaReimplantesGuardar.Count > 0)
            {
                loteReimplanteBL.GuardarListaReimplantes(listaReimplantesGuardar);
            }

            checkListCorral.FechaSacrificio  = loteProyeccion.FechaSacrificio;
            checkListCorral.Fecha1Reimplante = loteProyeccion.Proyeccion.FechaProyectada1;
            checkListCorral.Fecha2Reimplante = loteProyeccion.Proyeccion.FechaProyectada2;
            checkListCorral.DiasEngorda      = loteProyeccion.DiasEngorda;
        }
Esempio n. 6
0
        private void Buscar()
        {
            try
            {
                var lotePL            = new LotePL();
                var corralPL          = new CorralPL();
                var checkListCorralPL = new CheckListCorralPL();
                int organizacionID    = AuxConfiguracion.ObtenerOrganizacionUsuario();

                var corral = new CorralInfo
                {
                    Codigo       = txtCorral.Text,
                    Organizacion = new OrganizacionInfo
                    {
                        OrganizacionID = organizacionID
                    }
                };

                corral = corralPL.ObtenerPorCodigoGrupo(corral);

                if (corral == null)
                {
                    return;
                }

                LoteInfo lote = lotePL.ObtenerPorCorralCerrado(organizacionID, corral.CorralID);

                if (lote == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ImpresionCierreCorral_SinLoteActivo, MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }
                CheckListCorralInfo checkList = checkListCorralPL.ObtenerPorLote(organizacionID, lote.LoteID);

                if (checkList == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ImpresionCierreCorral_SinCierre, MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }
                GenerarArchivo(checkList);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ImpresionCierreCorral_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Metodo para Guardar/Modificar una entidad CheckListCorral
        /// </summary>
        /// <param name="info"></param>
        /// <param name="xml"></param>
        internal int Guardar(CheckListCorralInfo info, XDocument xml)
        {
            try
            {
                using (var transaction = new TransactionScope())
                {
                    Logger.Info();
                    var checkListCorralDAL = new CheckListCorralDAL();
                    int result             = info.CheckListCorralID;
                    GuardarProyeccion(info, checkListCorralDAL);
                    ArmarXML(info, xml);


                    if (info.CheckListCorralID == 0)
                    {
                        result = checkListCorralDAL.Crear(info);
                    }
                    else
                    {
                        checkListCorralDAL.Actualizar(info);
                    }

                    var loteBL             = new LoteBL();
                    var filtroCierreCorral = new FiltroCierreCorral
                    {
                        FechaSacrificio       = info.FechaSacrificio,
                        FechaCierre           = info.Fecha,
                        LoteID                = info.LoteID,
                        UsuarioModificacionID = info.UsuarioCreacionID
                    };
                    loteBL.ActualizaFechaCerrado(filtroCierreCorral);
                    transaction.Complete();
                    return(result);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Genera la Primera parte del XML "TablaCheckList"
        /// </summary>
        /// <param name="checkListCorral">contenedor donde se encuentra la información del Check List</param>
        /// <param name="xml">Layout del XML</param>
        /// <returns></returns>
        internal static void ArmarNodoTablaCheckList(XDocument xml, CheckListCorralInfo checkListCorral)
        {
            var type       = checkListCorral.GetType();
            var properties = type.GetProperties();

            var elementos = xml.Descendants().Where(x => x.Attribute("Valor") != null).ToList();

            foreach (var property in properties)
            {
                var nodo = elementos.FirstOrDefault(no =>
                {
                    var xAttribute = no.Attribute("Valor");
                    return(xAttribute != null && xAttribute.Value == property.Name);
                });
                if (nodo == null)
                {
                    continue;
                }
                if (property.PropertyType == typeof(DateTime))
                {
                    var fechas = (DateTime)property.GetValue(checkListCorral, null);
                    nodo.Value = fechas != DateTime.MinValue ? fechas.ToString("dd/MM/yyyy") : string.Empty;
                }
                else
                {
                    nodo.Value = property.GetValue(checkListCorral, null) != null
                                     ? property.GetValue(checkListCorral, null).ToString().Trim()
                                     : string.Empty;
                }
                if (property.Name == "DiasEngorda")
                {
                    nodo.Value = string.Format("{0} {1}", nodo.Value, "Días");
                }
                if (property.Name == "Ocupacion")
                {
                    nodo.Value = string.Format("{0}{1}", nodo.Value, "%");
                }
                if (property.Name == "PesoCorte")
                {
                    var pesoCorte = (int)property.GetValue(checkListCorral, null);
                    nodo.Value = pesoCorte.ToString("N0", CultureInfo.CurrentCulture);
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Obtiene una entidad CheckListCorral por su Id
 /// </summary>
 /// <param name="checkListCorralID">Obtiene una entidad CheckListCorral por su Id</param>
 /// <returns></returns>
 internal CheckListCorralInfo ObtenerPorID(int checkListCorralID)
 {
     try
     {
         Logger.Info();
         var checkListCorralDAL     = new CheckListCorralDAL();
         CheckListCorralInfo result = checkListCorralDAL.ObtenerPorID(checkListCorralID);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Metodo para Guardar/Modificar una entidad CheckListCorral
 /// </summary>
 /// <param name="info">Representa la entidad que se va a grabar</param>
 /// <param name="xml">Xml que contiene la estructura para guardar generar el PDF</param>
 public int Guardar(CheckListCorralInfo info, XDocument xml)
 {
     try
     {
         Logger.Info();
         var checkListCorralBL = new CheckListCorralBL();
         int result            = checkListCorralBL.Guardar(info, xml);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Obtiene una entidad por su descripción
 /// </summary>
 /// <param name="descripcion"></param>
 /// <returns></returns>
 public CheckListCorralInfo ObtenerPorDescripcion(string descripcion)
 {
     try
     {
         Logger.Info();
         var checkListCorralBL      = new CheckListCorralBL();
         CheckListCorralInfo result = checkListCorralBL.ObtenerPorDescripcion(descripcion);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Obtiene un registro de CheckListCorral
 /// </summary>
 /// <param name="loteID">identificador del Lote</param>
 /// <param name="organizacionID">identificador de la Organización</param>
 /// <returns></returns>
 public CheckListCorralInfo ObtenerPorLote(int organizacionID, int loteID)
 {
     try
     {
         Logger.Info();
         var checkListCorralBL      = new CheckListCorralBL();
         CheckListCorralInfo result = checkListCorralBL.ObtenerPorLote(organizacionID, loteID);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Obtiene la información del Lote para Check List
        /// </summary>
        /// <returns></returns>
        public CheckListCorralInfo ObtenerCheckListCorralCompleto(FiltroCierreCorral filtroCierreCorral)
        {
            try
            {
                Logger.Info();
                var loteBL = new LoteBL();
                CheckListCorralInfo checkList = loteBL.ObtenerCheckListCorralCompleto(filtroCierreCorral);

                return(checkList);
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Esempio n. 14
0
        public static string Guardar(CheckListCorralInfo checkListCorralInfo)
        {
            try
            {
                var       rutaArchivos = string.Format("{0}{1}", HttpRuntime.AppDomainAppPath, "\\Manejo\\ArchivosCheckList\\XML CheckList.xml");
                XDocument xml          = XDocument.Load(rutaArchivos);
                var       seguridad    = (SeguridadInfo)ObtenerSeguridad();
                checkListCorralInfo.Activo            = EstatusEnum.Activo;
                checkListCorralInfo.UsuarioCreacionID = seguridad.Usuario.UsuarioID;
                checkListCorralInfo.OrganizacionID    = seguridad.Usuario.Organizacion.OrganizacionID;
                var checkListCorralPL = new CheckListCorralPL();

                checkListCorralPL.Guardar(checkListCorralInfo, xml);
                return("OK");
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
Esempio n. 15
0
 /// <summary>
 ///  Obtiene parametros para actualizar
 /// </summary>
 /// <param name="info">Valores de la entidad</param>
 /// <returns></returns>
 internal static Dictionary <string, object> ObtenerParametrosActualizar(CheckListCorralInfo info)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@CheckListCorralID", info.CheckListCorralID },
             { "@OrganizacionID", info.OrganizacionID },
             { "@LoteID", info.LoteID },
             { "@PDF", info.PDF },
             { "@UsuarioModificacionID", info.UsuarioModificacionID },
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 16
0
        /// <summary>
        /// Genera el XML que se guarda en la tabla
        /// </summary>
        /// <param name="checkListCorral">contenedor donde se encuentra la información del Check List</param>
        /// <param name="xml">Layout del XML</param>
        /// <returns></returns>
        internal static void ArmarXML(CheckListCorralInfo checkListCorral, XDocument xml)
        {
            ArmarNodoTablaCheckList(xml, checkListCorral);
            ArmarNodoTablaGanado(xml, checkListCorral.ListaConceptos);
            ArmarNodoTablaCorral(xml, checkListCorral.ListaAcciones);

            var version      = "1.0";
            var codificacion = "ISO-8859-1";
            var xmlString    = String.Format("{0}\r{1}", "<?xml version='" + version + "' encoding='" + codificacion + "' ?>", xml);

            var output   = new MemoryStream();
            var document = new Document();

            PdfWriter.GetInstance(document, output);
            var xmlHandler = new ITextHandler(document);

            var documentoXML = new XmlDocument();

            documentoXML.LoadXml(xmlString);

            xmlHandler.Parse(documentoXML);
            checkListCorral.PDF = output.ToArray();
        }
Esempio n. 17
0
 /// <summary>
 ///  Método que obtiene un registro
 /// </summary>
 /// <param name="ds"></param>
 /// <returns></returns>
 internal static CheckListCorralInfo ObtenerPorID(DataSet ds)
 {
     try
     {
         Logger.Info();
         DataTable           dt      = ds.Tables[ConstantesDAL.DtDatos];
         CheckListCorralInfo entidad =
             (from info in dt.AsEnumerable()
              select
              new CheckListCorralInfo
         {
             CheckListCorralID = info.Field <int>("CheckListCorralID"),
             LoteID = info.Field <int>("LoteID"),
             PDF = info.Field <byte[]>("PDF"),
             Activo = info.Field <bool>("Activo").BoolAEnum(),
         }).First();
         return(entidad);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Obtiene Parametro para obtener las Fechas de proyección
 /// </summary>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal static Dictionary <string, object> ObtenerParametrosGenerarProyeccion(CheckListCorralInfo filtro)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@OrganizacionID", filtro.OrganizacionID },
             { "@LoteID", filtro.LoteID },
             { "@FechaInicio", filtro.FechaAbierto },
             { "@Sexo", filtro.SexoAnimal },
             { "@PesoOrigen", filtro.PesoPromedioCompra },
             { "@Merma", filtro.PorcentajeMerma },
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Obtiene parametros para obtener lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal static Dictionary <string, object> ObtenerParametrosPorPagina(PaginacionInfo pagina, CheckListCorralInfo filtro)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@CheckListCorralID", filtro.CheckListCorralID },
             { "@Activo", filtro.Activo },
             { "@Inicio", pagina.Inicio },
             { "@Limite", pagina.Limite }
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Obtiene un lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 public ResultadoInfo <CheckListCorralInfo> ObtenerPorPagina(PaginacionInfo pagina, CheckListCorralInfo filtro)
 {
     try
     {
         Logger.Info();
         var checkListCorralBL = new CheckListCorralBL();
         ResultadoInfo <CheckListCorralInfo> result = checkListCorralBL.ObtenerPorPagina(pagina, filtro);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Obtiene un lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal ResultadoInfo <CheckListCorralInfo> ObtenerPorPagina(PaginacionInfo pagina, CheckListCorralInfo filtro)
 {
     try
     {
         Dictionary <string, object> parameters = AuxCheckListCorralDAL.ObtenerParametrosPorPagina(pagina, filtro);
         DataSet ds = Retrieve("CheckListCorral_ObtenerPorPagina", parameters);
         ResultadoInfo <CheckListCorralInfo> result = null;
         if (ValidateDataSet(ds))
         {
             result = MapCheckListCorralDAL.ObtenerPorPagina(ds);
         }
         return(result);
     }
     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);
     }
 }