Ejemplo n.º 1
0
        private bool ValidateDocuments(Ticket ticket)
        {
            cbDocumentosVencidos.Items.Clear();

            var tiposVehiculoSinPresentar = new List <TipoDocumento>();
            var tiposEmpleadoSinPresentar = new List <TipoDocumento>();
            var tiposVehiculoVencidos     = new List <TipoDocumento>();
            var tiposEmpleadoVencidos     = new List <TipoDocumento>();

            if (ticket.Vehiculo != null)
            {
                var empresa       = ticket.Vehiculo.Empresa != null ? ticket.Vehiculo.Empresa.Id : -1;
                var linea         = ticket.Vehiculo.Linea != null ? ticket.Vehiculo.Linea.Id : -1;
                var tiposVehiculo = DAOFactory.TipoDocumentoDAO.FindObligatorioVehiculo(empresa, linea);
                foreach (var tipo in tiposVehiculo)
                {
                    var docs = DAOFactory.DocumentoDAO.FindForVehiculo(tipo.Id, ticket.Vehiculo.Id);
                    if (docs.Count == 0 || !docs.Any(d => d.Presentacion.HasValue))
                    {
                        tiposVehiculoSinPresentar.Add(tipo);
                    }
                    else if (!docs.Any(d => d.Presentacion.HasValue && (!d.Vencimiento.HasValue || d.Vencimiento.Value > ticket.FechaTicket.Value)))
                    {
                        tiposVehiculoVencidos.Add(tipo);
                    }
                }
            }
            if (ticket.Empleado != null)
            {
                var empresa       = ticket.Empleado.Empresa != null ? ticket.Empleado.Empresa.Id : -1;
                var linea         = ticket.Empleado.Linea != null ? ticket.Empleado.Linea.Id : -1;
                var tiposEmpleado = DAOFactory.TipoDocumentoDAO.FindObligatorioEmpleado(empresa, linea);
                foreach (var tipo in tiposEmpleado)
                {
                    var docs = DAOFactory.DocumentoDAO.FindForEmpleado(tipo.Id, ticket.Empleado.Id);
                    if (docs.Count == 0 || !docs.Any(d => d.Presentacion.HasValue))
                    {
                        tiposEmpleadoSinPresentar.Add(tipo);
                    }
                    if (!docs.Any(d => d.Presentacion.HasValue && (!d.Vencimiento.HasValue || d.Vencimiento.Value > ticket.FechaTicket.Value)))
                    {
                        tiposEmpleadoVencidos.Add(tipo);
                    }
                }
            }

            if (tiposVehiculoSinPresentar.Count > 0 || tiposEmpleadoSinPresentar.Count > 0 ||
                tiposVehiculoVencidos.Count > 0 || tiposEmpleadoVencidos.Count > 0)
            {
                foreach (var tipo in tiposVehiculoSinPresentar)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI03"), ")"));
                }
                foreach (var tipo in tiposVehiculoVencidos)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI03"), ")"));
                }
                foreach (var tipo in tiposEmpleadoSinPresentar)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI09"), ")"));
                }
                foreach (var tipo in tiposEmpleadoVencidos)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI09"), ")"));
                }

                if (!NoValidarDocumentos)
                {
                    ModalPopupExtenderDocumentos.Show();
                    updDocumentos.Update();
                }
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool ValidateDocuments()
        {
            if (NoValidarDocumentos)
            {
                return(true);
            }

            cbDocumentosVencidos.Items.Clear();

            var tiposVehiculoSinPresentar = new List <TipoDocumento>();
            var tiposEmpleadoSinPresentar = new List <TipoDocumento>();
            var tiposVehiculoVencidos     = new List <TipoDocumento>();
            var tiposEmpleadoVencidos     = new List <TipoDocumento>();


            if (cbMovil.Selected > 0)
            {
                var coche         = DAOFactory.CocheDAO.FindById(cbMovil.Selected);
                var empresa       = coche.Empresa != null ? coche.Empresa.Id : -1;
                var linea         = coche.Linea != null ? coche.Linea.Id : -1;
                var tiposVehiculo = DAOFactory.TipoDocumentoDAO.FindObligatorioVehiculo(empresa, linea);
                foreach (var tipo in tiposVehiculo)
                {
                    var docs = DAOFactory.DocumentoDAO.FindForVehiculo(tipo.Id, coche.Id);
                    if (docs.Count == 0 || !docs.Any(d => d.Presentacion.HasValue))
                    {
                        tiposVehiculoSinPresentar.Add(tipo);
                    }
                    else if (!docs.Any(d => d.Presentacion.HasValue && (!d.Vencimiento.HasValue || d.Vencimiento.Value > dtFecha.SelectedDate.Value)))
                    {
                        tiposVehiculoVencidos.Add(tipo);
                    }
                }
            }

            if (cbChofer.Selected > 0)
            {
                var chofer        = DAOFactory.EmpleadoDAO.FindById(cbChofer.Selected);
                var empresa       = chofer.Empresa != null ? chofer.Empresa.Id : -1;
                var linea         = chofer.Linea != null ? chofer.Linea.Id : -1;
                var tiposEmpleado = DAOFactory.TipoDocumentoDAO.FindObligatorioEmpleado(empresa, linea);
                foreach (var tipo in tiposEmpleado)
                {
                    var docs = DAOFactory.DocumentoDAO.FindForEmpleado(tipo.Id, chofer.Id);
                    if (docs.Count == 0 || !docs.Any(d => d.Presentacion.HasValue))
                    {
                        tiposEmpleadoSinPresentar.Add(tipo);
                    }
                    if (!docs.Any(d => d.Presentacion.HasValue && (!d.Vencimiento.HasValue || d.Vencimiento.Value > dtFecha.SelectedDate.Value)))
                    {
                        tiposEmpleadoVencidos.Add(tipo);
                    }
                }
            }

            if (tiposVehiculoSinPresentar.Count > 0 || tiposEmpleadoSinPresentar.Count > 0 ||
                tiposVehiculoVencidos.Count > 0 || tiposEmpleadoVencidos.Count > 0)
            {
                foreach (var tipo in tiposVehiculoSinPresentar)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI03"), ")"));
                }
                foreach (var tipo in tiposVehiculoVencidos)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI03"), ")"));
                }
                foreach (var tipo in tiposEmpleadoSinPresentar)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI09"), ")"));
                }
                foreach (var tipo in tiposEmpleadoVencidos)
                {
                    cbDocumentosVencidos.Items.Add(string.Concat(tipo.Nombre, "(", CultureManager.GetEntity("PARENTI09"), ")"));
                }

                ModalPopupExtenderDocumentos.Show();
                updDocumentos.Update();
                return(false);
            }

            return(true);
        }