コード例 #1
0
        /// <summary>
        /// Método para mostrar el informe
        /// </summary>
        /// <returns></returns>
        private void MostrarReporte()
        {
            try
            {
                DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue
                                       ? DtpFechaInicial.SelectedDate.Value
                                       : new DateTime();
                DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue
                                        ? DtpFechaFinal.SelectedDate.Value
                                        : fechaIni;

                var organizacionInfo = (OrganizacionInfo)cmbOrganizacion.SelectedItem;

                int organizacionId = organizacionInfo.OrganizacionID;

                IList <ReporteMuertesGanadoInfo> resultadoInfo = ObtenerReporteMuertesGanado(organizacionId, fechaIni, fechaFin);

                if (resultadoInfo == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteMuertesGanado_MsgSinInformacion,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }

                var organizacionPl     = new OrganizacionPL();
                var organizacion       = organizacionPl.ObtenerPorIdConIva(organizacionId);
                var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty;
                var encabezado         = new ReporteEncabezadoInfo
                {
                    Titulo       = Properties.Resources.ReporteMuertesGanado_TituloReporte,
                    FechaInicio  = fechaIni,
                    FechaFin     = fechaFin,
                    Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")"
                };

                foreach (var dato in resultadoInfo)
                {
                    dato.Titulo       = encabezado.Titulo;
                    dato.FechaInicio  = encabezado.FechaInicio;
                    dato.FechaFin     = encabezado.FechaFin;
                    dato.Organizacion = encabezado.Organizacion;
                }

                var documento = new ReportDocument();
                var reporte   = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteMuertesDeGanado.rpt");
                documento.Load(reporte);

                documento.DataSourceConnections.Clear();
                documento.SetDataSource(resultadoInfo);
                documento.Refresh();

                var forma = new ReportViewer(documento, encabezado.Titulo);
                forma.MostrarReporte();
                forma.Show();
            }
            catch (ExcepcionServicio ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteMuertesGanado_FalloCargarReporte,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteMuertesGanado_FalloCargarReporte,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #2
0
        /// <summary>
        /// Generar el reporte de Lector Comederos
        /// </summary>
        /// <returns></returns>
        private void Generar()
        {
            try
            {
                var organizacionCombo = (OrganizacionInfo)cmbOrganizacion.SelectedItem;
                var organizacionId    = 0;
                if (organizacionCombo != null)
                {
                    organizacionId = organizacionCombo.OrganizacionID;
                }

                DateTime?fechaHoy;
                if (DtpFecha.SelectedDate != null)
                {
                    fechaHoy = DtpFecha.SelectedDate;
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteLectorComederos_MensajeFechaError,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }
                int horario;
                if (cmbHorarios.SelectedItem != null)
                {
                    horario = cmbHorarios.SelectedIndex;
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteLectorComederos_MensajeHorarioError,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    LimpiarCampos();
                    return;
                }

                var resultadoInfo = ObtenerReporteLectorComederos(organizacionId, horario, fechaHoy);

                if (resultadoInfo == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteLectorComederos_MensajeReporteSinDatos,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    LimpiarCampos();
                    return;
                }


                var organizacionPl = new OrganizacionPL();
                if (organizacionCombo != null)
                {
                    var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionCombo.OrganizacionID);

                    var titulo             = Properties.Resources.ReporteLectorComederos_TituloReporte;
                    var nombreOrganizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + organizacion.Division + ")";


                    foreach (var item in resultadoInfo)
                    {
                        item.NombreOrganizacion = nombreOrganizacion;
                        item.Titulo             = titulo;
                    }
                }

                var documento   = new ReportDocument();
                var reporte     = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteLectorComederos.rpt");
                var rutaReporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\ReporteLectorComederos.xls");
                documento.Load(reporte);


                documento.DataSourceConnections.Clear();
                documento.SetDataSource(resultadoInfo);
                documento.Refresh();

                documento.ExportToDisk(ExportFormatType.Excel, rutaReporte);

                Process.Start(rutaReporte);

                //var forma = new ReportViewer(documento, Properties.Resources.ReporteLectorComederos_Titulo);
                //forma.MostrarReporte();
                //forma.Show();
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteLectorComederos_FalloCargarReporte, MessageBoxButton.OK,
                                  MessageImage.Error);
            }
        }
コード例 #3
0
        private bool ReasignarAreteMetalico(int banderaGuardar)
        {
            LimpiarBordes();
            bool guardar = ValidaGuardar();

            RfidNuevo = "";
            if (guardar)
            {
                try
                {
                    if (banderaGuardar > 0)
                    {
                        bool areteYaExiste = ValidarAreteTestigoRegistrado();
                        if (areteYaExiste)
                        {
                            return(false);
                        }
                    }

                    var animalInfo = new AnimalInfo();
                    animalInfo.Arete                 = txtNumeroIndividual.Text;
                    animalInfo.AreteMetalico         = txtAreteMetalico.Text;
                    animalInfo.OrganizacionIDEntrada = organizacionID;
                    animalInfo.UsuarioModificacionID = usuarioLogueadoID;
                    var reimplantePL = new ReimplantePL();
                    var datosCompra  = new DatosCompra();
                    animalInfo = reimplantePL.ReasignarAreteMetalico(animalInfo, banderaGuardar);
                    if (animalInfo != null)
                    {
                        datosCompra = reimplantePL.ObtenerDatosCompra(animalInfo);
                        MostrarDatos(animalInfo, datosCompra);
                        if (banderaGuardar == 1)
                        {
                            RfidNuevo = txtAreteMetalico.Text;
                            SkMessageBox.Show(this, Properties.Resources.ReasignacionArete_GuardadoExito, MessageBoxButton.OK, MessageImage.Correct);
                            guardado = true;
                            Limpiar(true);
                        }
                        else
                        {
                            btnGuardar.Focus();
                        }
                    }
                    else
                    {
                        SkMessageBox.Show(this, Properties.Resources.ReimplanteGanado_ReasignarAreteDatosIncorrectos, MessageBoxButton.OK, MessageImage.Warning);
                    }
                }
                catch (ExcepcionGenerica)
                {
                    SkMessageBox.Show(this, Properties.Resources.ReimplanteGanado_Error_ReasignarArete, MessageBoxButton.OK, MessageImage.Error);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(this, Properties.Resources.ReimplanteGanado_Error_ReasignarArete, MessageBoxButton.OK, MessageImage.Error);
                }
            }
            else
            {
                SkMessageBox.Show(this, Properties.Resources.Reimplante_DatosEnBlanco, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(guardar);
        }
コード例 #4
0
        private void ControlBase_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                CargarAyudaClientes();
                CargarComboTipoVenta();
                organizacionID = Extensor.ValorEntero(Application.Current.Properties["OrganizacionID"].ToString());
                usuario        = Convert.ToInt32(Application.Current.Properties["UsuarioID"]);
                //_nombreImpresora = ConfigurationManager.AppSettings["nombreImpresora"].Trim();
                _nombreImpresora = AuxConfiguracion.ObtenerConfiguracion().ImpresoraRecepcionGanado;

                txtFecha.Text = DateTime.Now.ToShortDateString();

                var tipoMovimientoPl   = new TipoMovimientoPL();
                var tipoMovimientoInfo = tipoMovimientoPl.ObtenerSoloTipoMovimiento((int)TipoMovimiento.SalidaPorVenta);

                if (tipoMovimientoInfo != null)
                {
                    txtSalida.Text = tipoMovimientoInfo.Descripcion;

                    var causa     = new CausaSalidaPL();
                    var causaInfo = causa.ObtenerPorID((int)CausaSalidaEnum.VentaEnPie);

                    if (causaInfo != null)
                    {
                        txtCausa.Text = causaInfo.Descripcion;

                        //se valida que existan trampas configuradas
                        if (!ExistenTrampas())
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.SalidaIndividualGanado_MensajeNoExistenTrampas,
                                              MessageBoxButton.OK,
                                              MessageImage.Stop);
                            DeshabilitarControles(false);
                            return;
                        }

                        InicializarBascula();

                        Limpiar();

                        ObtenerPesoBascula();

                        if (!basculaConectada)
                        {
                            if (_configBasculaCorte != null && !_configBasculaCorte.CapturaManual)
                            {
                                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                                  Properties.Resources.CorteTransferenciaGanado_PermisoCapturaManual,
                                                  MessageBoxButton.OK,
                                                  MessageImage.Warning);
                                DeshabilitarControles(false);
                            }
                        }
                    }
                    else
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.SalidaIndividualGanado_MensajeErrorConsultarCausaSalida,
                                          MessageBoxButton.OK,
                                          MessageImage.Warning);
                        DeshabilitarControles(false);
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.SalidaIndividualGanado_MensajeErrorConsultarTipoMovimiento,
                                      MessageBoxButton.OK,
                                      MessageImage.Warning);
                    DeshabilitarControles(false);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.SalidaIndividualGanado_MensajeErrorInesperado,
                                  MessageBoxButton.OK,
                                  MessageImage.Warning);
                DeshabilitarControles(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(skAyudaOrigen.Clave) ||
                    string.IsNullOrWhiteSpace(skAyudaOrigen.Descripcion) ||
                    skAyudaOrigen.Clave == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgOrganizacionOrigen;
                    skAyudaOrigen.AsignarFoco();
                }
                else if (string.IsNullOrWhiteSpace(skAyudaDestino.Clave) ||
                         string.IsNullOrWhiteSpace(skAyudaDestino.Descripcion) ||
                         skAyudaDestino.Clave == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgOrganizacionDestino;
                    skAyudaDestino.AsignarFoco();
                }
                else if (skAyudaOrigen.Clave == skAyudaDestino.Clave)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProgramacionEmbarque_DestinoIgualOrigen;
                    txtConfiguracionEmbarqueId.Focus();
                    var tRequest = new TraversalRequest(FocusNavigationDirection.Next);
                    txtConfiguracionEmbarqueId.MoveFocus(tRequest);
                }
                else if (!dtuKilometros.Value.HasValue || string.IsNullOrWhiteSpace(dtuKilometros.Text) ||
                         dtuKilometros.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgKilometrosRequerida;
                    dtuKilometros.Focus();
                }
                else if (!dtuHoras.Value.HasValue || string.IsNullOrWhiteSpace(dtuHoras.Text) ||
                         dtuHoras.Text == "0.0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgHorasRequerida;
                    dtuHoras.Focus();
                }
                else
                {
                    int configuracionEmbarqueId = Extensor.ValorEntero(txtConfiguracionEmbarqueId.Text);
                    int organizacionOrigenId    = Extensor.ValorEntero(skAyudaOrigen.Clave);
                    int organizacionDestinoId   = Extensor.ValorEntero(skAyudaDestino.Clave);

                    var configuracionEmbarquePL = new ConfiguracionEmbarquePL();
                    ConfiguracionEmbarqueInfo configuracionEmbarque =
                        configuracionEmbarquePL.ObtenerPorOrganizacion(organizacionOrigenId,
                                                                       organizacionDestinoId);

                    if (configuracionEmbarque != null &&
                        (configuracionEmbarqueId == 0 ||
                         configuracionEmbarqueId != configuracionEmbarque.ConfiguracionEmbarqueID))
                    {
                        resultado = false;
                        mensaje   =
                            string.Format(
                                Properties.Resources.ConfiguracionEmbarqueEdicion_MsgConfiguracionExistente,
                                configuracionEmbarque.ConfiguracionEmbarqueID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
コード例 #6
0
 private void txtCorralOrigen_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter || e.Key == Key.Tab)
     {
         if (String.IsNullOrWhiteSpace(txtCorralOrigen.Text))
         {
             txtCorralOrigen.Focus();
             e.Handled = true;
         }
         else
         {
             //Validar si el corral origen es de tipo enfermeria
             var corralPl   = new CorralPL();
             var corralInfo = new CorralInfo
             {
                 Codigo     = txtCorralOrigen.Text,
                 TipoCorral = new TipoCorralInfo {
                     TipoCorralID = (int)TipoCorral.Enfermeria,
                 },
                 Organizacion = new OrganizacionInfo {
                     OrganizacionID = _organizacionId
                 }
             };
             corralInfo = corralPl.ObtenerPorCodigoCorral(corralInfo);
             if (corralInfo == null)
             {
                 SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                   Properties.Resources.TraspasoGanadoCorral_CorralInvalido,
                                   MessageBoxButton.OK,
                                   MessageImage.Warning);
                 txtCorralOrigen.Focus();
                 return;
             }
             else
             {
                 corralPl   = new CorralPL();
                 corralInfo = new CorralInfo
                 {
                     Codigo       = txtCorralOrigen.Text,
                     Organizacion = new OrganizacionInfo {
                         OrganizacionID = _organizacionId
                     },
                     TipoCorral = new TipoCorralInfo {
                         TipoCorralID = (int)TipoCorral.Enfermeria,
                     }
                 };
                 var animalPL = new AnimalPL();
                 _Animales = animalPL.ObtenerAnimalesPorCodigoCorral(corralInfo);
                 if (_Animales != null)
                 {
                     LlenarAretesOrigen(_Animales);
                     txtCorralDestino.IsEnabled = true;
                     txtCorralDestino.Focus();
                 }
                 else
                 {
                 }
             }
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// Consulta los valores de ayuda
        /// </summary>
        /// <param name="valorParametro"></param>
        private void ConsultarValores(object valorParametro)
        {
            if (ValidarSiPuedeBuscar())
            {
                try
                {
                    existenDatos = false;

                    PropertyInfo property = EsAyudaSimple
                                                ? Contexto.GetType().GetProperty(CampoDescripcion)
                                                : Contexto.GetType().GetProperty(CampoClave);
                    if (property != null)
                    {
                        var tiposParametros = new[] { Contexto.GetType() };
                        var metodo          = ObjetoNegocio.GetType().GetMethod(MetodoInvocacion, tiposParametros);
                        if (metodo != null)
                        {
                            if (valorParametro == null)
                            {
                                object valorPropiedad = property.GetValue(Contexto, null);
                                property.SetValue(Contexto, valorPropiedad, null);
                            }
                            else
                            {
                                try
                                {
                                    property.SetValue(Contexto, valorParametro, null);
                                }
                                catch (Exception)
                                {
                                    property.SetValue(Contexto, Convert.ToInt32(valorParametro), null);
                                }
                            }
                            var    valoresParametros   = new[] { Contexto };
                            object resultadoInvocacion = metodo.Invoke(ObjetoNegocio, valoresParametros);
                            if (resultadoInvocacion != null)
                            {
                                existenDatos = true;
                                AsiganaValores(resultadoInvocacion);
                            }
                            else
                            {
                                SkMessageBox.Show(Application.Current.Windows[1], MensajeClaveInexistenteBusqueda, MessageBoxButton.OK,
                                                  MessageImage.Warning);
                                LimpiarCampos();
                                if (BusquedaVacia != null)
                                {
                                    BusquedaVacia();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(Application.Current.Windows[1],
                                      SuKarne.Controls.Properties.Resources.Ayuda_MensajeError,
                                      MessageBoxButton.OK,
                                      MessageImage.Error);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Obtiene los Valores para Mostrarlos en el
        /// Grid de Ayuda
        /// </summary>
        /// <param name="inicio"></param>
        /// <param name="limite"></param>
        public void ObtenerValoresAyuda(int inicio, int limite)
        {
            var tiposParametros   = new List <Type>();
            var valoresParametros = new List <Object>();

            try
            {
                if (grdDatos.Items.Count > 0)
                {
                    grdDatos.ItemsSource = null;
                    grdDatos.Items.Clear();
                }
                var filtro = txtValorFiltro.Text;
                if (string.Compare(filtro.Trim(), descripcionAnterior.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    descripcionAnterior = filtro;
                    pagControl.Inicio   = 1;
                    inicio = 1;
                }
                var metodoInvocacion = AuxAyuda.ObtenerMetodoEjecutar(Info, PropiedadDescripcion, true,
                                                                      AtributoDescripcion);
                var paginacionInfo = new PaginacionInfo {
                    Inicio = inicio, Limite = limite
                };
                AuxAyuda.AgregarFiltros(false, paginacionInfo, tiposParametros, valoresParametros);

                try
                {
                    Info.GetType().GetProperty(PropiedadDescripcion).SetValue(Info, filtro, null);
                }
                catch (Exception)
                {
                    Info.GetType().GetProperty(PropiedadDescripcion).SetValue(Info, 0, null);
                }


                AuxAyuda.AgregarFiltros(false, Info, tiposParametros, valoresParametros);

                object     resultadoInvocacion = null;
                var        ayudaTipo           = AyudaPL.GetType();
                MethodInfo metodo;
                if (Dependencias == null)
                {
                    metodo = ayudaTipo.GetMethod(metodoInvocacion, tiposParametros.ToArray());
                    if (metodo != null)
                    {
                        resultadoInvocacion = metodo.Invoke(AyudaPL, valoresParametros.ToArray());
                    }
                }
                else
                {
                    AuxAyuda.AgregarFiltros(false, Dependencias, tiposParametros, valoresParametros);
                    metodo = ayudaTipo.GetMethod(metodoInvocacion, tiposParametros.ToArray());
                    if (metodo != null)
                    {
                        resultadoInvocacion = metodo.Invoke(AyudaPL, valoresParametros.ToArray());
                    }
                }
                var resultadoInfo = (ResultadoInfo <T>)resultadoInvocacion;
                if (resultadoInfo != null && resultadoInfo.Lista != null && resultadoInfo.Lista.Count > 0)
                {
                    pagControl.TotalRegistros = resultadoInfo.TotalRegistros;
                    grdDatos.ItemsSource      = resultadoInfo.Lista;
                }
                else
                {
                    pagControl.TotalRegistros = 0;
                }
            }
            catch (ExcepcionGenerica)
            {
                SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #9
0
        /// <summary>
        /// Obtiene los Valores para Mostrarlos en el
        /// Grid de Ayuda
        /// </summary>
        /// <param name="inicio"></param>
        /// <param name="limite"></param>
        public void ObtenerValoresAyudaCamposInfo(int inicio, int limite)
        {
            var tiposParametros   = new List <Type>();
            var valoresParametros = new List <Object>();

            try
            {
                if (grdDatos.Items.Count > 0)
                {
                    grdDatos.ItemsSource = null;
                    grdDatos.Items.Clear();
                }

                var filtro           = txtValorFiltro.Text;
                var metodoInvocacion = MetodoPaginado;
                var paginacionInfo   = new PaginacionInfo {
                    Inicio = inicio, Limite = limite
                };
                AuxAyuda.AgregarFiltros(false, paginacionInfo, tiposParametros, valoresParametros);

                var propiedad = String.Empty;
                for (int indexCamposInfo = 0; indexCamposInfo < CamposInfo.Count; indexCamposInfo++)
                {
                    var indice = CamposInfo[indexCamposInfo].IndexOf("ID");

                    if (indice < 0)
                    {
                        propiedad = CamposInfo[indexCamposInfo];
                    }
                }

                Info.GetType().GetProperty(propiedad).SetValue(Info, filtro, null);
                AuxAyuda.AgregarFiltros(false, Info, tiposParametros, valoresParametros);

                object     resultadoInvocacion = null;
                var        ayudaTipo           = AyudaPL.GetType();
                MethodInfo metodo;
                if (Dependencias == null)
                {
                    metodo = ayudaTipo.GetMethod(metodoInvocacion, tiposParametros.ToArray());
                    if (metodo != null)
                    {
                        resultadoInvocacion = metodo.Invoke(AyudaPL, valoresParametros.ToArray());
                    }
                }
                else
                {
                    AuxAyuda.AgregarFiltros(false, Dependencias, tiposParametros, valoresParametros);
                    metodo = ayudaTipo.GetMethod(metodoInvocacion, tiposParametros.ToArray());
                    if (metodo != null)
                    {
                        resultadoInvocacion = metodo.Invoke(AyudaPL, valoresParametros.ToArray());
                    }
                }
                var resultadoInfo = (ResultadoInfo <T>)resultadoInvocacion;
                if (resultadoInfo != null && resultadoInfo.Lista != null && resultadoInfo.Lista.Count > 0)
                {
                    pagControl.TotalRegistros = resultadoInfo.TotalRegistros;
                    AsignarValoresGridCamposInfo(resultadoInfo.Lista);
                }
                else
                {
                    pagControl.TotalRegistros = 0;
                }
            }
            catch (ExcepcionGenerica)
            {
                SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #10
0
        /// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaBuscar()
        {
            try
            {
                bool   resultado = true;
                string mensaje   = string.Empty;

                DateTime?fechaIni = Contexto.FechaInicial;
                DateTime?fechaFin = Contexto.FechaFinal;

                var organizacion = (OrganizacionInfo)cmbOrganizacion.SelectedItem;
                if (organizacion == null || organizacion.OrganizacionID == 0)
                {
                    mensaje = Properties.Resources.ReporteVentaMuerte_MsgSelecioneOrganizacion;
                    cmbOrganizacion.Focus();
                }
                if (fechaIni == null && fechaFin == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteEjecutivo_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteEjecutivo_MsgFechaIniRequerida;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni > DateTime.Today)
                {
                    mensaje = Properties.Resources.RecepcionReporteVentaMuerte_MsgFechaActual;
                    DtpFechaInicial.Focus();
                }
                else if (fechaFin == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteEjecutivo_MsgFechaFinRequerida;
                    DtpFechaFinal.Focus();
                }
                else if (fechaFin < fechaIni)
                {
                    mensaje = Properties.Resources.RecepcionReporteVentaMuerte_MsgFechaInicialMayorFechaFinal;
                    DtpFechaFinal.Focus();
                }
                else if (!ValidarPeriodoAnio())
                {
                    mensaje = Properties.Resources.RecepcionReporteVentaMuerte_MsgFechaFinalMayordeunanio;
                    DtpFechaInicial.Focus();
                }

                if (!string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
コード例 #11
0
        /// <summary>
        /// Obtiene la lista para mostrar en el grid
        /// </summary>
        private void ObtenerReporte()
        {
            try
            {
                if (DtpFechaInicial.SelectedDate != null && DtpFechaFinal.SelectedDate != null)
                {
                    int organizacionId = (int)cmbOrganizacion.SelectedValue;

                    var reporteVentaMuerteBL = new ReporteVentaMuerteBL();
                    List <ReporteVentaMuerteInfo> resultadoInfo =
                        reporteVentaMuerteBL.GenerarReporteVentaMuerte(organizacionId, DtpFechaInicial.SelectedDate.Value,
                                                                       DtpFechaFinal.SelectedDate.Value);
                    if (resultadoInfo == null)
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.ReporteVentaMuerte_MsgSinInformacion, MessageBoxButton.OK,
                                          MessageImage.Warning);
                    }
                    else
                    {
                        var organizacionPl = new OrganizacionPL();

                        var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId);

                        string formatoFecha =
                            string.Format(Properties.Resources.ReporteVentaMuerte_RangoFecha,
                                          DtpFechaInicial.SelectedDate.Value.ToShortDateString(),
                                          DtpFechaFinal.SelectedDate.Value.ToShortDateString());

                        foreach (var dato in resultadoInfo)
                        {
                            dato.Titulo       = Properties.Resources.ReporteVentaMuerte_TituloReporte;
                            dato.RangoFechas  = formatoFecha;
                            dato.Organizacion = string.Format(Properties.Resources.Reporte_NombreEmpresa, organizacion.Division);
                        }


                        var documento = new ReportDocument();
                        var reporte   = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteVentaMuerte.rpt");
                        documento.Load(reporte);


                        documento.DataSourceConnections.Clear();
                        documento.SetDataSource(resultadoInfo);
                        documento.Refresh();


                        var forma = new ReportViewer(documento, Properties.Resources.ReporteVentaMuerte_TituloReporte);
                        forma.MostrarReporte();
                        forma.Show();
                    }
                }
            }
            catch (ExcepcionServicio ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  ex.Message,
                                  MessageBoxButton.OK, MessageImage.Warning);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.RecepcionReporteEjecutivo_MsgErrorExportarExcel,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #12
0
        private void GenerarReporte()
        {
            try
            {
                var resultadoInfo = ObtenerReporteKardexGanado();

                if (resultadoInfo == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteKardexGanado_MsgSinInformacion,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }
                else
                {
                    //string division = AuxDivision.ObtenerDivision(AuxConfiguracion.ObtenerOrganizacionUsuario());

                    var organizacionPl = new OrganizacionPL();

                    int idOrganizacion = int.Parse(this.cmbOrganizacion.SelectedValue.ToString());

                    var organizacion = organizacionPl.ObtenerPorIdConIva(idOrganizacion);

                    var titulo             = Properties.Resources.ReporteKardexGanado_TituloReporte;
                    var nombreOrganizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + organizacion.Division + ")";

                    foreach (var item in resultadoInfo)
                    {
                        item.Organizacion = nombreOrganizacion;
                        item.Titulo       = titulo;
                        item.Fecha        = DateTime.Now;
                        item.Tipo         = item.Tipo == string.Empty ? Properties.Resources.ReporteKardexGanado_Recepcion : item.Tipo;
                    }

                    var documento = new ReportDocument();
                    var reporte   = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\ReporteKardexDeGanado.rpt");
                    documento.Load(reporte);

                    documento.DataSourceConnections.Clear();
                    documento.SetDataSource(resultadoInfo);
                    documento.Refresh();

                    //ReportViewer
                    var forma = new ReportViewer(documento, Properties.Resources.ReporteKardexGanado_TituloReporte);
                    forma.MostrarReporte();
                    forma.Show();
                }
            }
            catch (ExcepcionServicio ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  ex.Message,
                                  MessageBoxButton.OK, MessageImage.Warning);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteKardexGanado_MsgErrorGenerarRPT,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #13
0
 private void MostrarMensaje(string mensaje)
 {
     SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                       MessageBoxButton.OK, MessageImage.Warning);
 }
コード例 #14
0
        private void generarReporte()
        {
            DateTime dtFechaInicial               = new DateTime(DtpFechaInicial.SelectedDate.Value.Year, DtpFechaInicial.SelectedDate.Value.Month, DtpFechaInicial.SelectedDate.Value.Day);
            DateTime dtFechaFinal                 = new DateTime(DtpFechaFin.SelectedDate.Value.Year, DtpFechaFin.SelectedDate.Value.Month, DtpFechaFin.SelectedDate.Value.Day);
            int      iOrganizacionID              = int.Parse(skAyudaOrganizacion.Clave);
            int      iTipoSalida                  = int.Parse(cmbTipoSalida.SelectedValue.ToString());
            int      iTipoProceso                 = int.Parse(cmbTipoProceso.SelectedValue.ToString());
            String   sVistaCostos                 = cmbVerCostos.Text;
            ReporteSalidaConCostosBL salidaBL     = new ReporteSalidaConCostosBL();
            Boolean            bSalidaVentaMuerte = false;
            Boolean            bDetallado         = false;
            SalidaConCostoInfo salidas            = new SalidaConCostoInfo();

            if (sVistaCostos.ToUpper().Trim() == "DETALLADOS")
            {
                bDetallado = true;
            }
            ReporteSalidasConCostoParametrosInfo parametros = new ReporteSalidasConCostoParametrosInfo
            {
                OrganizacionID = iOrganizacionID,
                FechaInicial   = dtFechaInicial,
                FechaFinal     = dtFechaFinal,
                TipoSalida     = iTipoSalida,
                TipoProceso    = iTipoProceso,
                EsDetallado    = bDetallado
            };
            IList <ReporteSalidaConCostosInfo> resultadoInfo = salidaBL.obtenerReporte(parametros);

            if (resultadoInfo != null)
            {
                if (TipoMovimiento.Muerte.GetHashCode().ToString() == iTipoSalida.ToString() || TipoMovimiento.Muerte.GetHashCode().ToString() == iTipoSalida.ToString())
                {
                    bSalidaVentaMuerte = true;
                }



                foreach (ReporteSalidaConCostosInfo salida in resultadoInfo)
                {
                    salida.esSalidaVentaOMuerte = bSalidaVentaMuerte;
                    salida.esDetallado          = bDetallado;
                    salida.Leyenda     = organizacionLocal.Descripcion;
                    salida.RangoFechas = "De " + dtFechaInicial.Day.ToString().PadLeft(2, '0') + "-" + dtFechaInicial.Month.ToString().PadLeft(2, '0') + dtFechaInicial.Year.ToString() +
                                         " hasta" + dtFechaFinal.Day.ToString().PadLeft(2, '0') + "-" + dtFechaFinal.Month.ToString().PadLeft(2, '0') + dtFechaFinal.Year.ToString();
                    salida.NombreReporte = Properties.Resources.ReporteSalidaConCosto_NombreReporte;
                }

                var encabezado = new ReporteEncabezadoInfo
                {
                    Titulo       = Properties.Resources.ReporteSalidaConCosto_Titulo,
                    FechaInicio  = dtFechaInicial,
                    FechaFin     = dtFechaFinal,
                    Organizacion = Properties.Resources.ReporteSalidaConCosto_Titulo + " (" + organizacionLocal.Division + ")"
                };

                var    documento      = new ReportDocument();
                String directorioBase = String.Empty;
                if (AppDomain.CurrentDomain.BaseDirectory.Substring(AppDomain.CurrentDomain.BaseDirectory.Length - 1, 1) == "\\")
                {
                    directorioBase = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.Length - 1);
                }
                else
                {
                    directorioBase = AppDomain.CurrentDomain.BaseDirectory.ToString();
                }
                var reporte = String.Format("{0}{1}", directorioBase, "\\Reporte\\RptReporteSalidaConCostosDetallado.rpt");
                documento.Load(reporte);

                documento.DataSourceConnections.Clear();
                documento.SetDataSource(resultadoInfo);
                documento.Refresh();

                var forma = new ReportViewer(documento, encabezado.Titulo);
                forma.MostrarReporte();
                forma.Show();
                for (int i = 0; i < resultadoInfo.Count; i++)
                {
                    GC.SuppressFinalize(resultadoInfo[i]);
                }
                GC.SuppressFinalize(resultadoInfo);
            }
            else
            {
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteSalidaConCosto_Msg_SinInformacion,
                                  MessageBoxButton.OK, MessageImage.Warning);
            }
        }
コード例 #15
0
        private bool ValidaEstructuraAreteMasivo(IEnumerable <string> aretes)
        {
            var result           = false;
            var correctoLongitud = true;
            var correctoDigitos  = true;

            try
            {
                if (esAreteSukarne)
                {
                    var logic         = new ParametroGeneralPL();
                    var paramLongitud = logic.ObtenerPorClaveParametro(ParametrosEnum.LongitudAreteSK.ToString());
                    if (paramLongitud != null)
                    {
                        foreach (string arete in aretes)
                        {
                            if (int.Parse(paramLongitud.Valor) != 0 && arete.Length != int.Parse(paramLongitud.Valor))
                            {
                                correctoLongitud = false;
                            }
                        }
                    }

                    if (correctoLongitud)
                    {
                        var paramDigito = logic.ObtenerPorClaveParametro(ParametrosEnum.DigitosIniAreteSK.ToString());
                        if (paramDigito != null)
                        {
                            foreach (string arete in aretes)
                            {
                                if (paramDigito.Valor.Length > arete.Length || !paramDigito.Valor.Trim().Equals(arete.Substring(0, 4)) && !string.IsNullOrEmpty(paramDigito.Valor))
                                {
                                    correctoDigitos = false;
                                }
                                else
                                {
                                    if (!ValidarSiEsNumero(arete))
                                    {
                                        correctoDigitos = false;
                                    }
                                }
                            }
                        }
                    }

                    if (correctoLongitud && correctoDigitos)
                    {
                        result = true;
                    }
                }
                else
                {
                    result = true;
                    foreach (string arete in aretes)
                    {
                        if (!ValidarSiEsNumero(arete))
                        {
                            result = false;
                        }
                    }
                }
            }
            catch (Exception)
            {
                SkMessageBox.Show(System.Windows.Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.GastosMateriasPrimasAretes_ErrorValEstructArete, MessageBoxButton.OK,
                                  MessageImage.Error);
            }

            return(result);
        }
コード例 #16
0
        private void ObtenerRegistrosVigilancia(int inicio, int limite)
        {
            try
            {
                var registroVigilanciaPL      = new RegistroVigilanciaPL();
                RegistroVigilanciaInfo filtro = ObtenerFiltros();
                if (ucPaginacion.Contexto == null)
                {
                    ucPaginacion.Contexto = filtro;
                }
                if (ucPaginacion.ContextoAnterior != null)
                {
                    bool contextosIguales = ucPaginacion.CompararObjetos(filtro, ucPaginacion.Contexto) &&
                                            ucPaginacion.CompararObjetos(filtro, ucPaginacion.ContextoAnterior);
                    if (!contextosIguales)
                    {
                        ucPaginacion.Inicio = 1;
                        inicio = 1;
                    }
                }
                var pagina = new PaginacionInfo {
                    Inicio = inicio, Limite = limite
                };
                ResultadoInfo <RegistroVigilanciaInfo> resultadoTraspasoMateriaPrimaInfo =
                    registroVigilanciaPL.ObtenerPorPagina(pagina, filtro);

                if (resultadoTraspasoMateriaPrimaInfo == null)
                {
                    ucPaginacion.TotalRegistros = 0;
                    gridTrapasos.ItemsSource    = new List <EntradaEmbarqueInfo>();
                    string mensajeNoHayDatos = Properties.Resources.CapturaHumedadBusquedaFolio_SinFolios;
                    SkMessageBox.Show(this, mensajeNoHayDatos, MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }

                List <RegistroVigilanciaInfo> registrosValidos =
                    resultadoTraspasoMateriaPrimaInfo.Lista.Where(
                        rev => ProductosHumedad.Contains(rev.Producto.ProductoId)).ToList();

                resultadoTraspasoMateriaPrimaInfo.Lista = registrosValidos;

                if (resultadoTraspasoMateriaPrimaInfo.Lista != null &&
                    resultadoTraspasoMateriaPrimaInfo.Lista.Count > 0)
                {
                    gridTrapasos.ItemsSource    = resultadoTraspasoMateriaPrimaInfo.Lista;
                    ucPaginacion.TotalRegistros = resultadoTraspasoMateriaPrimaInfo.TotalRegistros;
                }
                else
                {
                    ucPaginacion.TotalRegistros = 0;
                    gridTrapasos.ItemsSource    = new List <EntradaEmbarqueInfo>();
                    string mensajeNoHayDatos = Properties.Resources.CapturaHumedadBusquedaFolio_SinFolios;
                    SkMessageBox.Show(this, mensajeNoHayDatos, MessageBoxButton.OK, MessageImage.Warning);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
コード例 #17
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtCostoPromedioID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CostoPromedioEdicion_MsgcostopromedioidRequerida;
                    txtCostoPromedioID.Focus();
                }
                else if (Contexto.Organizacion == null || Contexto.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CostoPromedioEdicion_MsgorganizacionidRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (Contexto.Costo == null || Contexto.Costo.CostoID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CostoPromedioEdicion_MsgcostoidRequerida;
                    skAyudaCosto.AsignarFoco();
                }
                else if (!dtuImporte.Value.HasValue || Contexto.Importe == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CostoPromedioEdicion_MsgimporteRequerida;
                    dtuImporte.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CostoPromedioEdicion_MsgactivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int costoPromedioId = Extensor.ValorEntero(txtCostoPromedioID.Text);
                    int organizacionId  = Contexto.Organizacion.OrganizacionID;
                    int costoId         = Contexto.Costo.CostoID;

                    var costoPromedioPL             = new CostoPromedioPL();
                    CostoPromedioInfo costoPromedio = costoPromedioPL.ObtenerPorOrganizacionCosto(organizacionId, costoId);

                    if (costoPromedio != null && (costoPromedioId == 0 || costoPromedioId != costoPromedio.CostoPromedioID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.CostoPromedioEdicion_MsgDescripcionExistente, costoPromedio.CostoPromedioID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
コード例 #18
0
        /// <summary>
        /// Metodo para validar el corral destino
        /// </summary>
        private bool ValidarCorralDestino()
        {
            try
            {
                //Buscar el corral en el inventario
                var corralPL   = new CorralPL();
                var corralInfo = corralPL.ObtenerCorralPorCodigo(organizacionID, txtCorralDestino.Text);
                if (corralInfo != null)
                {
                    if (corralInfo.GrupoCorral == (int)GrupoCorralEnum.Enfermeria ||
                        corralInfo.GrupoCorral == (int)GrupoCorralEnum.Produccion)
                    {
                        // Obtener el lote del corral
                        var lotePL = new LotePL();
                        var lote   = lotePL.ObtenerPorCorralCerrado(organizacionID, corralInfo.CorralID);

                        if (lote != null)
                        {
                            //Si existe se obtienen los datos del corral
                            corralDestino = corralInfo;
                        }
                        else
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.TrasferenciaGanadoIndividual_GrupoCorralSinLote,
                                              MessageBoxButton.OK, MessageImage.Warning);
                            txtCorralDestino.Text      = String.Empty;
                            txtCorralDestino.Focusable = true;
                            txtCorralDestino.Focus();
                            //e.Handled = true;
                            return(false);
                        }
                    }
                    else
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.TrasferenciaGanadoIndividual_GrupoCorralInvalido,
                                          MessageBoxButton.OK, MessageImage.Warning);
                        txtCorralDestino.Focusable = true;
                        txtCorralDestino.Focus();
                        txtCorralDestino.Text = String.Empty;
                        //e.Handled = true;
                        return(false);
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.TrasferenciaGanadoIndividual_CorralNoExiste,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    txtCorralDestino.Focusable = true;
                    txtCorralDestino.Focus();
                    txtCorralDestino.Text = String.Empty;
                    //e.Handled = true;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(true);
        }
コード例 #19
0
        /// <summary>
        /// Método para Imprimir
        /// </summary>
        private void Imprimir()
        {
            try
            {
                Mouse.SetCursor(Cursors.Wait);
                var reporte   = new System.Data.DataSet("ReporteSolicitudProductos");
                var solicitud = new System.Data.DataTable("Solicitud");

                var columnasSolicitud = new System.Data.DataColumn[]
                {
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtFolio, typeof(int)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtFechaSolicitud, typeof(DateTime)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtSolicito, typeof(string)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtAutorizo, typeof(string)),
                };

                solicitud.Columns.AddRange(columnasSolicitud);
                var rowSolicitud = solicitud.NewRow();
                rowSolicitud[Properties.Resources.SolicitudProductosAlmacen_DtFolio]          = Contexto.FolioSolicitud;
                rowSolicitud[Properties.Resources.SolicitudProductosAlmacen_DtFechaSolicitud] = Contexto.FechaSolicitud;
                rowSolicitud[Properties.Resources.SolicitudProductosAlmacen_DtSolicito]       = Contexto.UsuarioSolicita.Nombre;
                rowSolicitud[Properties.Resources.SolicitudProductosAlmacen_DtAutorizo]       = Contexto.UsuarioAutoriza.Nombre;
                solicitud.Rows.Add(rowSolicitud);

                var detalle         = new System.Data.DataTable("Detalle");
                var columnasDetalle = new System.Data.DataColumn[]
                {
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtFolio, typeof(int)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtCodigo, typeof(int)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtArticulo, typeof(string)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtCantidad, typeof(decimal)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtUnidadMedicion, typeof(string)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtDescripcion, typeof(string)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtClaseCosto, typeof(string)),
                    new DataColumn(Properties.Resources.SolicitudProductosAlmacen_DtCentroCosto, typeof(string)),
                };
                detalle.Columns.AddRange(columnasDetalle);
                foreach (var row in Contexto.Detalle)
                {
                    if (row.Activo == EstatusEnum.Activo)
                    {
                        var newDetalle = detalle.NewRow();
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtFolio]          = Contexto.FolioSolicitud;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtCodigo]         = row.Producto.ProductoId;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtArticulo]       = row.Producto.Descripcion;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtCantidad]       = row.Cantidad;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtUnidadMedicion] =
                            row.Producto.UnidadMedicion.Descripcion;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtDescripcion] =
                            row.CentroCosto.Descripcion;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtClaseCosto] =
                            row.ClaseCostoProducto != null
                                ? row.ClaseCostoProducto.CuentaSAP.CuentaSAP
                                : string.Empty;
                        newDetalle[Properties.Resources.SolicitudProductosAlmacen_DtCentroCosto] =
                            row.CentroCosto.Descripcion;
                        detalle.Rows.Add(newDetalle);
                    }
                }

                reporte.Tables.Add(solicitud);
                reporte.Tables.Add(detalle);

                string nombreReporte = Properties.Resources.SolicitudProductosAlmacen_NombreReporte;
                var    nombre        = string.Format(@"{0}-{1:d8}.pdf", nombreReporte, Contexto.FolioSolicitud);

                //string archivoXML = string.Format("{0}.xml", nombreArchivo);
                //reporte.WriteXml(string.Format(@"c:\Reporte\{0}", archivoXML), XmlWriteMode.WriteSchema);

                using (var documento = new ReportDocument())
                {
                    using (var streaming = this.GetType().Assembly.GetManifestResourceStream(
                               string.Format("SIE.WinForm.Reporte.{0}.rpt", nombreReporte)))
                    {
                        using (var fileStream = File.Create(nombre))
                        {
                            if (streaming != null)
                            {
                                streaming.CopyTo(fileStream);
                            }
                        }
                    }

                    documento.Load(nombre);
                    documento.DataSourceConnections.Clear();
                    documento.SetDataSource(reporte);
                    documento.Refresh();

                    //Establecemos el nombre correcto de la impresora para enviar directamente el informe
                    //documento.PrintOptions.PrinterName = configuracion.ImpresoraRecepcionGanado;

                    //Iniciando el proceso de impresion ponemos la configuracion de la impresion
                    //documento.PrintToPrinter(1, false, 0, 0);

                    var archivo = new FileStream(nombre, FileMode.Open);
                    archivo.Close();

                    documento.ExportToDisk(ExportFormatType.PortableDocFormat, nombreReporte);
                    documento.Close();
                }

                var dialogo = new SaveFileDialog
                {
                    FileName   = nombre,
                    DefaultExt = ".pdf",
                    Filter     = "Documentos Pdf (*.pdf)|*.pdf"
                };

                bool?resultado = dialogo.ShowDialog();
                if (resultado == true)
                {
                    nombre = dialogo.FileName;
                    if (File.Exists(nombre))
                    {
                        try
                        {
                            var archivo = new FileStream(nombre, FileMode.Open);
                            archivo.Close();
                        }
                        catch (IOException)
                        {
                            //throw new ExcepcionServicio(Properties.Resources.ExportarExcel_ArchivoAbierto);
                        }
                    }
                }
                Mouse.SetCursor(Cursors.Arrow);
                string mensaje = Properties.Resources.SolicitudProductosAlmacen_MsgReporteGenerado;
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje, MessageBoxButton.OK,
                                  MessageImage.Correct);
            }
            catch (Exception err)
            {
                Logger.Error(err);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ProgramacionCorte_ErrorImpresora, MessageBoxButton.OK,
                                  MessageImage.Warning);
            }
        }
コード例 #20
0
        /// <summary>
        /// Evento del boton guardar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGuardar_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ValdiarCamposObligatoriosEnBlanco())
                {
                    if (ValidarValorParametroCorralDestino())
                    {
                        return;
                    }

                    var transferenciaPL = new TransferenciaGanadoIndividualPL();

                    if (ckbCompensacion.IsChecked != null && ckbCompensacion.IsChecked.Value)
                    {
                        // Se guarda una compensacion
                        if (dgAretesDelCorral.SelectedItem != null)
                        {
                            var animalCompensado = (AnimalInfo)dgAretesDelCorral.SelectedItem;
                            // Guarda una transferencia de ganado
                            using (var scope = new TransactionScope())
                            {
                                // como es intercambio no se decrementan las cabezas
                                transferenciaPL.GuardarTransferenciaGanadoCompensacion(animal, corralDestino,
                                                                                       animalCompensado, corralOrigen,
                                                                                       usuario, false);
                                scope.Complete();
                            }
                        }
                        else
                        {
                            // no se encuentra seleccionado el arete para realizar la compensacion
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.TrasferenciaGanadoIndividual_SeleccionarAreteGrid,
                                              MessageBoxButton.OK, MessageImage.Warning);
                            dgAretesDelCorral.Focus();
                            return;
                        }
                    }
                    else
                    {
                        // Guarda una transferencia de ganado
                        using (var scope = new TransactionScope())
                        {
                            transferenciaPL.GuardarTransferenciaGanado(animal, corralDestino, usuario, true);
                            scope.Complete();
                        }
                    }
                    // Se limpia pantalla y se muestra mensaje de éxito
                    Limpiar(true);
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.CorteGanado_SeguardoCorrectamenteElCorte,
                                      MessageBoxButton.OK, MessageImage.Correct);
                    txtArete.Focus();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.TrasferenciaGanadoIndividual_ErrorGuardar,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #21
0
        /// <summary>
        /// Método con el cual se valida el folio del ticket ingresado
        /// </summary>
        private bool ValidarFolioTicket()
        {
            if (txtFolioTicket.Text.Trim() != "")
            {
                var        venta        = new VentaGanadoPL();
                var        ventadetalle = new VentaGanadoDetallePL();
                var        usuarioPl    = new UsuarioPL();
                TicketInfo Ticket       = new TicketInfo();

                Ticket.FolioTicket = int.Parse(txtFolioTicket.Text.Trim());
                if ((string)cmbTipo.SelectedItem == Properties.Resources.SalidaIndividualDeGanado_cmbTipoExterno)
                {
                    Ticket.TipoVenta = TipoVentaEnum.Externo;
                }
                else
                {
                    Ticket.TipoVenta = TipoVentaEnum.Propio;
                }

                listaAretes.Items.Clear();
                skAyudaCliente.LimpiarCampos();

                Ticket.Organizacion = AuxConfiguracion.ObtenerOrganizacionUsuario();
                VentaGanadoInfo ganado = venta.ObtenerVentaGanadoPorTicket(Ticket);
                if (ganado != null)
                {
                    UsuarioInfo usuarioSubioGanado = usuarioPl.ObtenerPorID(ganado.UsuarioModificacionID);
                    var         clientePl          = new ClientePL();
                    var         cliente            = new ClienteInfo {
                        ClienteID = ganado.ClienteID, CodigoSAP = ganado.CodigoSAP
                    };
                    cliente = clientePl.ObtenerClientePorCliente(cliente);
                    skAyudaCliente.Clave       = cliente.CodigoSAP;
                    skAyudaCliente.Descripcion = cliente.Descripcion;
                    skAyudaCliente.Info        = cliente;
                    txtCorral.Text             = ganado.CodigoCorral;

                    var pesoTara = decimal.Parse(ganado.PesoTara.ToString(CultureInfo.InvariantCulture).Replace(".00", "").Replace(",00", ""));
                    txtPesoTara.Text = pesoTara.ToString(CultureInfo.CurrentCulture);

                    txtPesoTara.IsEnabled    = false;
                    txtFolioTicket.IsEnabled = false;
                    if (!basculaConectada)
                    {
                        txtPesoBruto.IsEnabled = true;
                    }
                    skAyudaCliente.IsEnabled = false;
                    _pesoTomado = false;
                    ObtenerPesoBascula();

                    List <VentaGanadoDetalleInfo> detalle = ventadetalle.ObtenerVentaGanadoPorTicket(ganado.VentaGanadoID);
                    if (Ticket.TipoVenta == TipoVentaEnum.Propio)
                    {
                        if (detalle != null)
                        {
                            if (detalle.Count > 0)
                            {
                                lblTotalCabezas.IsEnabled        = true;
                                lblNumeroTotalCabezas.IsEnabled  = true;
                                lblNumeroTotalCabezas.Content    = detalle.Count.ToString();
                                lblNumeroTotalCabezas.Visibility = Visibility.Visible;
                                lblTotalCabezas.Visibility       = Visibility.Visible;
                            }

                            listaAretes.Visibility = Visibility.Visible;
                            cmbTipo.IsEnabled      = false;
                            cmbTipo.SelectedIndex  = 0;

                            foreach (VentaGanadoDetalleInfo ventaGanadoDetalleInfo in detalle)
                            {
                                listaAretes.Items.Add(ventaGanadoDetalleInfo);
                            }
                            nombreUsuarioSubioGanado = usuarioSubioGanado.Nombre;
                        }
                        else
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.SalidaIndividualGanado_MensajeTicketNoTieneAretes,
                                              MessageBoxButton.OK, MessageImage.Warning);
                            Limpiar();

                            return(false);
                        }
                    }
                    else
                    {
                        if (ganado.TotalCabezas > 0)
                        {
                            cmbTipo.SelectedIndex  = 1;
                            cmbTipo.IsEnabled      = false;
                            listaAretes.Visibility = Visibility.Hidden;

                            lblTotalCabezas.IsEnabled        = true;
                            lblNumeroTotalCabezas.IsEnabled  = true;
                            lblNumeroTotalCabezas.Content    = ganado.TotalCabezas.ToString();
                            lblNumeroTotalCabezas.Visibility = Visibility.Visible;
                            lblTotalCabezas.Visibility       = Visibility.Visible;

                            nombreUsuarioSubioGanado = usuarioSubioGanado.Nombre;
                        }
                        else
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.SalidaIndividualGanado_MensajeTicketNoTieneAretes,
                                              MessageBoxButton.OK, MessageImage.Warning);
                            Limpiar();

                            return(false);
                        }
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.SalidaIndividualGanado_MensajeFolioTicketInvalido,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    Limpiar();
                    return(false);
                }
            }
            return(true);
        }
コード例 #22
0
        private bool ValidarAreteMetalico()
        {
            try
            {
                var animalInfo = new AnimalInfo
                {
                    AreteMetalico         = txtAreteMetalico.Text,
                    OrganizacionIDEntrada = organizacionID
                };
                //Buscar el animal en el inventario
                var corteGanadoPl = new CorteGanadoPL();
                animalInfo = corteGanadoPl.ExisteAreteMetalicoEnPartida(animalInfo);
                if (animalInfo != null)
                {
                    //Se obtiene el ultimo movimiento
                    var animalPL         = new AnimalPL();
                    var ultimoMovimiento = animalPL.ObtenerUltimoMovimientoAnimal(animalInfo);
                    if (ultimoMovimiento != null)
                    {
                        //Se obtiene el corral en el que se encuentra
                        var corralPL   = new CorralPL();
                        var corralInfo = corralPL.ObtenerPorId(ultimoMovimiento.CorralID);
                        if (corralInfo != null)
                        {
                            //Se obtiene el Corral Origen
                            txtCorralOrigen.Text = corralInfo.Codigo;
                            var lotePL = new LotePL();
                            //var loteOrigen = new LoteInfo
                            //                 {
                            //                     CorralID = corralInfo.CorralID,
                            //                     OrganizacionID = organizacionID
                            //                 };
                            LoteInfo loteOrigen = lotePL.ObtenerPorId(ultimoMovimiento.LoteID);
                            if (loteOrigen == null || loteOrigen.Activo == EstatusEnum.Inactivo)
                            {
                                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                                  Properties.Resources.TrasferenciaGanadoIndividual_LoteInactivo,
                                                  MessageBoxButton.OK, MessageImage.Warning);
                                txtAreteMetalico.Focusable = true;
                                txtAreteMetalico.Focus();
                                txtAreteMetalico.Clear();
                                return(false);
                            }
                        }

                        //Si existe se obtienen los datos del animal
                        txtPesoOrigen.Text = animalInfo.PesoCompra.ToString(CultureInfo.InvariantCulture);
                        var tipoGanadoPl = new TipoGanadoPL();
                        var tipoGanado   = tipoGanadoPl.ObtenerPorID(animalInfo.TipoGanadoID);
                        if (tipoGanado != null)
                        {
                            //Se obtiene el tipo de ganado y sexo
                            txtSexo.Text = tipoGanado.Sexo.ToString();
                        }
                        //Se inicializa la info del animal de forma global
                        animal        = animalInfo;
                        corralOrigen  = corralInfo;
                        txtArete.Text = animal.Arete;
                    }
                    else
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.TrasferenciaGanadoIndividual_AreteNoExiste,
                                          MessageBoxButton.OK, MessageImage.Warning);
                        txtAreteMetalico.Focusable = true;
                        txtAreteMetalico.Focus();
                        txtAreteMetalico.Clear();
                        return(false);
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.TrasferenciaGanadoIndividual_AreteNoExiste,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    txtAreteMetalico.Focusable = true;
                    txtAreteMetalico.Focus();
                    txtAreteMetalico.Clear();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(true);
        }
コード例 #23
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            int           folioTicket, numeroDeCabezas;
            decimal       pesoNeto, peso, pesoBruto;
            string        corral = string.Empty;
            TipoVentaEnum tipoVenta;

            if (txtFolioTicket.Text.Trim() != string.Empty)
            {
                var salida = new SalidaIndividualPL();
                folioTicket     = int.Parse(txtFolioTicket.Text.Trim());
                pesoNeto        = Convert.ToDecimal(txtPesoNeto.Value);
                pesoBruto       = Convert.ToDecimal(txtPesoBruto.Value);
                numeroDeCabezas = int.Parse(lblNumeroTotalCabezas.Content.ToString().Trim());
                peso            = pesoNeto / numeroDeCabezas;
                corral          = txtCorral.Text;

                if ((string)cmbTipo.SelectedItem == Properties.Resources.SalidaIndividualDeGanado_cmbTipoExterno)
                {
                    tipoVenta = TipoVentaEnum.Externo;
                }
                else
                {
                    tipoVenta = TipoVentaEnum.Propio;
                }

                try
                {
                    var salidaIndividual = new SalidaIndividualInfo
                    {
                        FolioTicket     = folioTicket,
                        PesoBruto       = pesoBruto,
                        Peso            = peso,
                        NumeroDeCabezas = numeroDeCabezas,
                        Organizacion    = organizacionID,
                        Usuario         = usuario,
                        TipoVenta       = tipoVenta,
                        Corral          = corral
                    };


                    MemoryStream stream = salida.GuardarSalidaIndividualGanadoVenta(salidaIndividual);

                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.SalidaIndividualGanado_MensajeGuardadoOK,
                                      MessageBoxButton.OK, MessageImage.Correct);

                    try
                    {
                        if (stream != null)
                        {
                            var exportarPoliza = new ExportarPoliza();
                            exportarPoliza.ImprimirPoliza(stream,
                                                          string.Format("{0} {1}", "Poliza Salida Folio No.",
                                                                        folioTicket));
                        }
                    }
                    catch
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.SalidaIndividualGanado_MensajeErrorAlImprimirPoliza,
                                          MessageBoxButton.OK, MessageImage.Warning);
                    }

                    _pesoTomado = false;
                    Limpiar();
                }
                catch (ExcepcionServicio ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      ex.Message, MessageBoxButton.OK, MessageImage.Stop);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.SalidaIndividualGanado_MensajeErrorAlGuardar,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    _pesoTomado = false;
                    Limpiar();
                }
            }
        }
コード例 #24
0
        /// <summary>
        /// Asigna el valor al campo folio
        /// </summary>
        private void AyudaConDatosFolio()
        {
            try
            {
                if (Contexto.Solicitud.FolioID > 0)
                {
                    if (Contexto.UsuarioIDEntrega == 0)
                    {
                        Contexto.UsuarioIDEntrega = usuario.UsuarioID;
                        Contexto.UsuarioEntrega   = usuario;
                    }
                    Contexto = ObtenerSolicitudPorId(Contexto.Solicitud.FolioID);

                    //Obtener los productos ligados a familia de HerramientaYEquipo y valdiar si ya se entrego en INFOR
                    IList <SolicitudProductoDetalleInfo> idsProductosHerramienta = Contexto.Detalle
                                                                                   .Where(d => d.Producto.FamiliaId == (int)FamiliasEnum.HerramientaYEquipo).ToList();
                    if (idsProductosHerramienta.Any())
                    {
                        //Validar si el folio ya se encuentra en INFOR Entregado
                        if (!solicitudProductoBL.ExisteFolioEnINFOR(Contexto.Solicitud.FolioSolicitud, Contexto.Solicitud.OrganizacionID))
                        {
                            Limpiar();
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                              Properties.Resources.EntregarProductoAlmacen_MsgNoExisteReferenciaInfor,
                                              MessageBoxButton.OK,
                                              MessageImage.Warning);
                            return;
                        }
                    }

                    int porEntregar = Contexto.Detalle.Count(e => e.EstatusID == Estatus.SolicitudProductoAutorizado.GetHashCode());

                    if (porEntregar > 0)
                    {
                        Contexto.Detalle = Contexto.Detalle.Where(e => e.Activo == EstatusEnum.Activo).ToList();
                        var disponibilidad = ValidaDisponibilidad(Contexto);

                        Contexto.Detalle.ForEach(e =>
                        {
                            e.Entregado = e.EstatusID == Estatus.SolicitudProductoEntregado.GetHashCode() ||
                                          e.EstatusID == Estatus.SolicitudProductoRecibido.GetHashCode();
                            var registro =
                                disponibilidad.FirstOrDefault(d => d.ProductoID == e.ProductoID);
                            if (registro != null && !registro.IsDisponible)
                            {
                                e.Editar = registro.IsDisponible;
                            }
                            else
                            {
                                e.Editar = e.EstatusID == Estatus.SolicitudProductoPendiente.GetHashCode() ||
                                           e.EstatusID == Estatus.SolicitudProductoAutorizado.GetHashCode();
                            }
                        });

                        DtpFecha.SelectedDate   = Contexto.FechaSolicitud;
                        Contexto.DetalleGrid    = Contexto.Detalle.ConvertirAObservable();
                        Contexto.UsuarioEntrega = usuario;

                        var habilitarBotonGuardar = Contexto.Detalle.FirstOrDefault(e => e.Editar);
                        if (habilitarBotonGuardar == null)
                        {
                            Contexto.Guardar = false;
                        }

                        gridDatos.ItemsSource  = Contexto.Detalle.Where(e => e.Activo == EstatusEnum.Activo);
                        skAyudaFolio.IsEnabled = false;
                    }
                    else
                    {
                        Limpiar();
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.EntregarProductoAlmacen_MsgNoTieneEstatusAutorizada,
                                          MessageBoxButton.OK, MessageImage.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.EntregarProductoAlmacen_MsgErrorConsultarFolio,
                                  MessageBoxButton.OK, MessageImage.Error);
            }
        }
コード例 #25
0
        /// <summary>
        /// Ocurre cuando se presiona click sobre el control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGenerar_OnClick(object sender, RoutedEventArgs e)
        {
            var muertesPl            = new MuertePL();
            var salidaGanadoMuertePl = new SalidaGanadoMuertoPL();
            var muerteInfo           = new MuerteInfo()
            {
                OrganizacionId = Convert.ToInt32(Application.Current.Properties["OrganizacionID"]),
                FechaNecropsia = dtFecha.SelectedDate.Value
            };

            try
            {
                IList <SalidaGanadoMuertoInfo> listaMuertes = muertesPl.ObtenerMuertesFechaNecropsia(muerteInfo);

                if (listaMuertes != null && listaMuertes.Count > 0)
                {
                    int folio = 0;
                    IList <SalidaGanadoMuertoInfo> result = listaMuertes.Where(muerte => muerte.FolioSalida != 0).ToList();
                    if (result != null && result.Count > 0)
                    {
                        folio = result[0].FolioSalida;
                    }
                    else
                    {
                        var salidaGanadoMuerteInfo = new SalidaGanadoMuertoInfo()
                        {
                            OrganizacionID = Convert.ToInt32(Application.Current.Properties["OrganizacionID"]),
                            TipoFolio      = (int)TipoFolio.SalidaGanadoMuerte
                        };
                        folio = salidaGanadoMuertePl.ObtenerFolio(salidaGanadoMuerteInfo);
                    }
                    var organizacionPl   = new OrganizacionPL();
                    var organizacionInfo = new OrganizacionInfo();
                    organizacionInfo = organizacionPl.ObtenerPorID(muerteInfo.OrganizacionId);
                    var etiquetas = ObtenerEtiquetas();
                    etiquetas.Titulo = organizacionInfo.Descripcion;
                    etiquetas.Folio  = folio.ToString().PadLeft(5, '0');
                    etiquetas.Fecha  = dtFecha.Text;

                    listaMuertes[0].FolioSalida           = folio;
                    listaMuertes[0].UsuarioModificacionID = Convert.ToInt32(Application.Current.Properties["UsuarioID"]);

                    salidaGanadoMuertePl.AsignarFolioMuertes(listaMuertes);
                    try
                    {
                        salidaGanadoMuertePl.CrearOrdenSalidaGandoMuerto(etiquetas, listaMuertes);
                        salidaGanadoMuertePl.MostrarReportePantalla();
                    }
                    catch
                    {
                        SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                          Properties.Resources.OrdenSalidaMuerteGanado_msgArchivoAbierto,
                                          MessageBoxButton.OK,
                                          MessageImage.Stop);
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.OrdenSalidaMuerteGanado_msgNoExistenMuertes,
                                      MessageBoxButton.OK,
                                      MessageImage.Stop);
                    dtFecha.SelectedDate = DateTime.Now;
                }
            }
            catch (System.Exception ex)
            {
                Logger.Error(ex);
            }
        }
コード例 #26
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtFleteMermaPermitidaID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.FleteMermaPermitidaEdicion_MsgFleteMermaPermitidaIDRequerida;
                    txtFleteMermaPermitidaID.Focus();
                }
                else if (Contexto.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.FleteMermaPermitidaEdicion_MsgOrganizacionIDRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (Contexto.SubFamilia.SubFamiliaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.FleteMermaPermitidaEdicion_MsgSubFamiliaIDRequerida;
                    skAyudaSubFamilia.AsignarFoco();
                }
                else if (Contexto.MermaPermitida == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.FleteMermaPermitidaEdicion_MsgMermaPermitidaRequerida;
                    dtuMermaPermitida.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.FleteMermaPermitidaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int fleteMermaPermitidaId = Contexto.FleteMermaPermitidaID;

                    var fleteMermaPermitidaBL = new FleteMermaPermitidaBL();
                    FleteMermaPermitidaInfo fleteMermaPermitida = fleteMermaPermitidaBL.ObtenerPorDescripcion(Contexto);

                    if (fleteMermaPermitida != null && (fleteMermaPermitidaId == 0 || fleteMermaPermitidaId != fleteMermaPermitida.FleteMermaPermitidaID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.FleteMermaPermitidaEdicion_MsgDescripcionExistente, fleteMermaPermitida.FleteMermaPermitidaID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
コード例 #27
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                    txtDescripcion.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(skAyudaOrganizacion.Clave) ||
                         string.IsNullOrWhiteSpace(skAyudaOrganizacion.Descripcion))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgOrganizacionRequerida;

                    txtDescripcion.Focus();
                    var tRequest = new TraversalRequest(FocusNavigationDirection.Next);
                    txtDescripcion.MoveFocus(tRequest);
                }

                else if (cmbTipoCorral.SelectedItem == null || Contexto.TipoCorral.TipoCorralID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgTipoCorralRequerida;
                    cmbTipoCorral.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtCapacidad.Text) || txtCapacidad.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgCapacidadRequerida;
                    txtCapacidad.Focus();
                    txtCapacidad.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(txtSeccion.Text) || txtSeccion.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgSeccionRequerida;
                    txtSeccion.Focus();
                    txtSeccion.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(txtOrden.Text) || txtOrden.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgOrdenRequerida;
                    txtOrden.Focus();
                    txtOrden.SelectAll();
                }
                else
                {
                    var    lotePL         = new LotePL();
                    int    corralId       = Extensor.ValorEntero(txtCorralId.Text);
                    string descripcion    = txtDescripcion.Text;
                    int    organizacionID = Contexto.Organizacion.OrganizacionID;

                    var corralPL = new CorralPL();
                    //CorralInfo corral = corralPL.ValidaCorralConLoteConExistenciaActivo(Contexto.CorralID);
                    //if (corral != null)
                    //{
                    //    mensaje = Properties.Resources.Corral_MsgConExistencia;
                    //    resultado = false;
                    //}
                    //else

                    CorralInfo corral = corralPL.ObtenerPorDescripcionOrganizacion(descripcion, organizacionID);

                    if (corral != null && (corralId == 0 || corralId != corral.CorralID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.CorralEdicion_MsgDescripcionExistente,
                                                  corral.CorralID);
                    }
                    var loteFiltro = new LoteInfo
                    {
                        OrganizacionID = organizacionID,
                        CorralID       = corralId
                    };
                    LoteInfo lote = lotePL.ObtenerPorCorralID(loteFiltro);
                    if (lote != null)
                    {
                        if (corral != null)
                        {
                            if (corral.TipoCorral.TipoCorralID != Contexto.TipoCorral.TipoCorralID)
                            {
                                resultado = false;
                                mensaje   = string.Format(Properties.Resources.CorralEdicion_MsgCambiarTipoCorral,
                                                          lote.Lote);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
コード例 #28
0
        //Metodo de validar al guardar el nivel de alerta.
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                // si esta en blanco manda un mensaje que es requerido el campo descripcion.
                if (string.IsNullOrWhiteSpace(Contexto.Descripcion) && txtDescripcion.Text.Trim() == string.Empty)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.NivelAlertaEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.NivelAlertaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    // se realiza la busqueda por descripcion para no editar y asignarle una descripcion igual a una ya existente.
                    int             NivelAlertaID = Contexto.NivelAlertaId;
                    var             NivelAlertaPL = new NivelAlertaPL();
                    NivelAlertaInfo NivelALerta   = NivelAlertaPL.ObtenerPorDescripcion(Contexto.Descripcion.Trim());

                    //Obtiene un contador de los niveles que se encuentran deshabilitados
                    int nivelesAlertaDesactivados = NivelAlertaPL.NivelesAlertaDesactivados();

                    //validacion si la descripcion del nivel registrado ya existe
                    if (NivelALerta != null && (NivelAlertaID == 0 || NivelAlertaID != NivelALerta.NivelAlertaId))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.NivelAlertaEdicion_MsgDescripcionExistente, NivelALerta.NivelAlertaId);
                    }
                    //validacion para cuando se crea un nuevo registro activo pero hay un registro previo desactivado
                    else if (nivelesAlertaDesactivados > 0 && Contexto.Activo == EstatusEnum.Activo && Contexto.NivelAlertaId == 0)
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.NivelAlertaCreacion_MsgInactivos);
                    }
                    //validacion para cuando editas un nivel alerta
                    else if (Contexto.Activo == EstatusEnum.Inactivo && Contexto.NivelAlertaId != 0)
                    {
                        //validacion para cuando editas un nivel alerta pero solo modificas su descripcion
                        //(AuxInactivo guarda en valor original en cuanto se cargan los datos del nivel a editar
                        if (AuxInactivo != Contexto.Activo)
                        {
                            int verificarAsignacionNivelAlerta = NivelAlertaPL.VerificarAsignacionNivelAlerta(NivelAlertaID);
                            //verifica si el nivel seleccionado no a sido asignado
                            if (verificarAsignacionNivelAlerta > 0)
                            {
                                resultado = false;
                                mensaje   = string.Format(Properties.Resources.NivelAlertaEdicion_MsgAsignado);
                            }
                        }
                    }
                    //validacion cuando un inactivo quiere pasar a activo...
                    else if (AuxInactivo != EstatusEnum.Activo && Contexto.NivelAlertaId != 0)
                    {
                        int habilitarPrimerRegistro = NivelAlertaPL.NivelAlerta_ActivarPrimerNivelDesactivado(NivelAlertaID);
                        //Si regresa 0 no es el primero deshabilitado si regresa > 0 es el primero deshabilitado
                        if (habilitarPrimerRegistro == 0)
                        {
                            resultado = false;
                            mensaje   = string.Format(Properties.Resources.NivelAlertaActivacion_MsgActivar);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
コード例 #29
0
        /// <summary>
        /// Obtiene los datos de la entrada ganado transito
        /// </summary>
        private void ObtenerDatosEntradaGanadoTransito()
        {
            int cabezasOrigen     = ContenedorCosteoEntrada.EntradaGanado.CabezasOrigen;
            int cabezasLlegada    = ContenedorCosteoEntrada.EntradaGanadoCosteo.ListaEntradaDetalle.Sum(cab => cab.Cabezas);
            int diferenciaCabezas = cabezasLlegada - cabezasOrigen;

            if (diferenciaCabezas != 0)
            {
                var parametroOrganizacionPL = new ParametroOrganizacionPL();
                var codigoParametro         = ParametrosEnum.CORRALFALTDIRECTA;
                switch ((TipoOrganizacion)ContenedorCosteoEntrada.EntradaGanado.TipoOrigen)
                {
                case TipoOrganizacion.Cadis:
                case TipoOrganizacion.Centro:
                case TipoOrganizacion.Praderas:
                    codigoParametro = ParametrosEnum.CORRALFALTPROPIO;
                    break;
                }
                ParametroOrganizacionInfo parametroOrganizacion =
                    parametroOrganizacionPL.ObtenerPorOrganizacionIDClaveParametro(organizacionIdLogin,
                                                                                   codigoParametro.ToString());
                if (parametroOrganizacion == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.CosteoEntradaGanado_ConfiguracionCorralesTransito, MessageBoxButton.OK,
                                      MessageImage.Stop);
                    return;
                }
                var entradaGanadoTransitoBL = new EntradaGanadoTransitoBL();
                EntradaGanadoTransitoInfo entradaGanadoTransito =
                    entradaGanadoTransitoBL.ObtenerPorCorralOrganizacion(parametroOrganizacion.Valor,
                                                                         organizacionIdLogin);
                if (entradaGanadoTransito != null)
                {
                    entradaGanadoTransito.Sobrante = diferenciaCabezas >= 0;
                    decimal pesoTransito =
                        ContenedorCosteoEntrada.EntradaGanadoCosteo.ListaEntradaDetalle.Sum(
                            peso => peso.PesoLlegada - peso.PesoOrigen);
                    decimal importeTransito = ContenedorCosteoEntrada.EntradaGanadoCosteo.ListaEntradaDetalle.Sum(
                        imp => imp.Importe);
                    decimal importeOrigen = ContenedorCosteoEntrada.EntradaGanadoCosteo.ListaEntradaDetalle.Sum(
                        imp => imp.ImporteOrigen);

                    LoteInfo lote = entradaGanadoTransito.Lote;
                    lote.Cabezas = lote.Cabezas + diferenciaCabezas;
                    lote.UsuarioModificacionID = AuxConfiguracion.ObtenerUsuarioLogueado();

                    int multiplicador;
                    if (entradaGanadoTransito.Sobrante)
                    {
                        multiplicador = 1;
                    }
                    else
                    {
                        multiplicador = -1;
                    }
                    entradaGanadoTransito.Cabezas = (diferenciaCabezas * multiplicador) * -1;
                    entradaGanadoTransito.Peso    = Convert.ToInt32(pesoTransito * multiplicador);

                    int totalCabezasTipoGanado = ContenedorCosteoEntrada.EntradaGanadoCosteo
                                                 .ListaEntradaDetalle.Sum(cab => cab.Cabezas);
                    totalCabezasTipoGanado += (diferenciaCabezas * multiplicador);
                    int porcentajeDescontar = Convert.ToInt32(Math.Round(100 - ((importeTransito * 100) / importeOrigen), 0, MidpointRounding.AwayFromZero));

                    List <EntradaGanadoTransitoDetalleInfo> detalles = entradaGanadoTransito.EntradasGanadoTransitoDetalles;
                    EntradaGanadoTransitoDetalleInfo        detalle;

                    decimal importeConDescuento;
                    for (int index = 0; index < detalles.Count; index++)
                    {
                        detalle = detalles[index];

                        importeOrigen = ContenedorCosteoEntrada.EntradaGanadoCosteo.ListaCostoEntrada
                                        .Where(id => id.Costo.CostoID == detalle.Costo.CostoID)
                                        .Select(imp => imp.Importe).FirstOrDefault();
                        importeConDescuento = (importeOrigen / 100) * porcentajeDescontar;
                        detalle.Importe     = importeConDescuento * multiplicador;
                    }
                    entradaGanadoTransito.UsuarioModificacionID   = AuxConfiguracion.ObtenerUsuarioLogueado();
                    ContenedorCosteoEntrada.EntradaGanadoTransito = entradaGanadoTransito;
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Generar el reporte de solicitud de procesos
        /// </summary>
        /// <returns></returns>
        private void Generar()
        {
            try
            {
                var organizacionCombo = (OrganizacionInfo)cmbOrganizacion.SelectedItem;
                int organizacionId    = 0;
                if (organizacionCombo != null)
                {
                    organizacionId = organizacionCombo.OrganizacionID;
                }

                DateTime fechaInicial = DtpFechaInicial.SelectedDate.Value;
                DateTime fechaFinal   = DtpFechaFinal.SelectedDate.Value;


                var resultadoInfo = ObtenerReporteResumenInventario(organizacionId, familiaSeleccionada.FamiliaID, fechaInicial, fechaFinal);

                if (resultadoInfo == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ReporteResumenInventario_MensajeReporteSinDatos,
                                      MessageBoxButton.OK, MessageImage.Warning);
                    return;
                }


                //int organizacionIdu = AuxConfiguracion.ObtenerOrganizacionUsuario();
                var organizacionPl = new OrganizacionPL();

                var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId);
                var titulo       = Properties.Resources.ReporteResumenInventarioAlimentos_TituloReporte;

                var nombreOrganizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + organizacion.Division + ")";

                foreach (var item in resultadoInfo)
                {
                    item.Organizacion = nombreOrganizacion;
                    item.Titulo       = titulo;
                    item.FechaFinal   = fechaFinal;
                    item.FechaInicial = fechaInicial;
                }

                var documento = new ReportDocument();
                var reporte   = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteResumenInventario.rpt");
                documento.Load(reporte);


                documento.DataSourceConnections.Clear();
                documento.SetDataSource(resultadoInfo);
                documento.Refresh();


                var forma = new ReportViewer(documento, Properties.Resources.ReporteResumenInventario_Titulo);
                forma.MostrarReporte();
                forma.Show();
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteMedicamentosAplicados_FalloCargarReporte, MessageBoxButton.OK,
                                  MessageImage.Error);
            }
        }