/// <summary>
 /// Metodo para ver si existe el animal como vendido
 /// </summary>
 /// <param name="animal"></param>
 /// <returns></returns>
 public VentaGanadoDetalleInfo ExisteAnimal(AnimalInfo animal)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxVentaGanadoDetalle.ObtenerParametrosAnimalID(animal);
         DataSet ds = Retrieve("SalidaIndividualVenta_ObtenerVentaDetallePorAnimalID", parameters);
         VentaGanadoDetalleInfo ventaDetalle = null;
         if (ValidateDataSet(ds))
         {
             ventaDetalle = MapVentaGanadoDetalleDAL.ObtenerVentaGanadoDetalle(ds);
         }
         return(ventaDetalle);
     }
     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);
     }
 }
示例#2
0
        internal static List <VentaGanadoDetalleInfo> ObtenerVentaGanadoDetallePorID(DataSet ds)
        {
            try
            {
                List <VentaGanadoDetalleInfo> lista = new List <VentaGanadoDetalleInfo>();
                DataTable dt = ds.Tables[ConstantesDAL.DtDatos];
                VentaGanadoDetalleInfo item;

                foreach (DataRow info in dt.Rows)
                {
                    item = new VentaGanadoDetalleInfo();
                    item.VentaGanadoDetalleID = info.Field <int>("VentaGanadoDetalleID");
                    item.VentaGanadoID        = info.Field <int>("VentaGanadoID");
                    item.FotoVenta            = info.Field <string>("FotoVenta");
                    item.CausaPrecioID        = info.Field <int>("CausaPrecioID");
                    item.Arete         = info.Field <string>("Arete");
                    item.AreteMetalico = info.Field <string>("AreteMetalico");
                    item.Activo        = info.Field <bool>("Activo");
                    lista.Add(item);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
示例#3
0
        /// <summary>
        /// Mapear el objeto de venta ganado detalle
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        internal static VentaGanadoDetalleInfo ObtenerVentaGanadoDetalle(DataSet ds)
        {
            try
            {
                VentaGanadoDetalleInfo ventaDetalle = null;
                DataTable dt = ds.Tables[ConstantesDAL.DtDatos];

                foreach (DataRow info in dt.Rows)
                {
                    ventaDetalle = new VentaGanadoDetalleInfo
                    {
                        VentaGanadoDetalleID = info.Field <int>("VentaGanadoDetalleID"),
                        VentaGanadoID        = info.Field <int>("VentaGanadoID"),
                        FotoVenta            = (info["FotoVenta"] == DBNull.Value ? "" : info.Field <string>("FotoVenta")),
                        CausaPrecioID        = info.Field <int>("CausaPrecioID"),
                        Animal = new AnimalInfo
                        {
                            AnimalID = info.Field <long>("AnimalID")
                        },
                        Activo = info.Field <bool>("Activo")
                    };
                }
                return(ventaDetalle);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
 /// <summary>
 /// Validar si existe el animal como vendido.
 /// </summary>
 /// <param name="animal"></param>
 /// <returns></returns>
 internal VentaGanadoDetalleInfo ExisteAnimal(AnimalInfo animal)
 {
     try
     {
         Logger.Info();
         var ventaGanadoDetalleDAL      = new VentaGanadoDetalleDAL();
         VentaGanadoDetalleInfo retorno = ventaGanadoDetalleDAL.ExisteAnimal(animal);
         return(retorno);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
示例#5
0
        /// <summary>
        /// Metodo para Guardar la Salida Ganado
        /// </summary>
        /// <param name="animalInactivo"></param>
        internal bool GuardarSalidaGanado(AnimalInfo animalInactivo)
        {
            var envioAnimal = false;

            try
            {
                Logger.Info();
                var animalBL = new AnimalBL();

                //Se obtiene el ultimo movimiento
                var ultimoMovimiento = animalBL.ObtenerUltimoMovimientoAnimal(animalInactivo);

                var salidaGanadoInfo = new SalidaGanadoInfo
                {
                    Organizacion = new OrganizacionInfo
                    {
                        OrganizacionID = animalInactivo.OrganizacionIDEntrada
                    },
                    TipoMovimiento = (TipoMovimiento)ultimoMovimiento.TipoMovimientoID,
                    Activo         = EstatusEnum.Activo,
                    //VentaGanado = new VentaGanadoInfo(){VentaGanadoID = null},
                    UsuarioCreacionID = animalInactivo.UsuarioCreacionID
                };

                if (ultimoMovimiento.TipoMovimientoID == (int)TipoMovimiento.SalidaPorVenta)
                {
                    //Si el ultimo movimiento es venta obtener el ID de la VentaGanado
                    var ventaDetalleBL = new VentaGanadoDetalleBL();
                    VentaGanadoDetalleInfo ventaDetalleInfo =
                        ventaDetalleBL.ExisteAnimal(animalInactivo);

                    if (ventaDetalleInfo != null)
                    {
                        salidaGanadoInfo.VentaGanado = new VentaGanadoInfo
                        {
                            VentaGanadoID = ventaDetalleInfo.VentaGanadoID
                        };
                    }
                }

                var salidaGanadoDAL           = new SalidaGanadoDAL();
                SalidaGanadoInfo salidaGanado = null;

                //Se valida si la venta es
                if (salidaGanadoInfo.VentaGanado != null)
                {
                    //Se busca la venta en la salida Ganado
                    salidaGanado = salidaGanadoDAL.ExisteVentaEnSalidaGanado(salidaGanadoInfo);
                }

                if (salidaGanado == null)
                {
                    //Se guarda en SalidaGanado
                    salidaGanado =
                        salidaGanadoDAL.GuardarSalidaGanado(salidaGanadoInfo, (int)TipoFolio.SalidaGanado);
                }

                //Se almacena SalidaAnimal
                var salidaAnimalBL = new SalidaAnimalBL();

                var salidaAnimalInfo = new SalidaAnimalInfo()
                {
                    SalidaGanado = salidaGanado,
                    Animal       = animalInactivo,
                    Lote         = new LoteInfo {
                        LoteID = ultimoMovimiento.LoteID
                    },
                    Activo            = EstatusEnum.Activo,
                    UsuarioCreacionID = animalInactivo.UsuarioCreacionID
                };

                envioAnimal = salidaAnimalBL.Guardar(salidaAnimalInfo);

                envioAnimal = true;
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(envioAnimal);
        }