Ejemplo n.º 1
0
        protected void StartTicketWindow(Ticket ticket)
        {
            if (ticket.Vehiculo == null)
            {
                ShowResourceError("TICKET_NO_VEHICLE_ASSIGNED");
                return;
            }

            if (ticket.Vehiculo.Dispositivo == null)
            {
                ShowResourceError("VEHICLE_NO_DEVICE_ASSIGNED");
                return;
            }

            var stateList = ticket.Detalles.OfType <DetalleTicket>().OrderBy(t => t.EstadoLogistico.Orden).ToList();

            if (stateList.Count == 0)
            {
                ShowResourceError("NO_CLOG_STATES");
                return;
            }

            var primerEstado = stateList[0].EstadoLogistico;

            if (primerEstado == null || primerEstado.Mensaje == null)
            {
                ShowResourceError("NO_MESSAGE_FOR_START_CLOG");
                return;
            }

            TicketToInitId.Set(ticket.Id);

            var opened = DAOFactory.TicketDAO.FindEnCurso(ticket.Vehiculo.Dispositivo);

            if (opened != null)
            {
                lblCodigoTicket.Text = opened.Codigo;
                lblCliente.Text      = opened.Cliente.Descripcion;
                lblPuntoEntrega.Text = opened.PuntoEntrega.Descripcion;
                lblFecha.Text        = opened.FechaTicket.Value.ToDisplayDateTime().ToString("dd/MM/yyyy HH:mm");
            }
            else
            {
                var tieneDocumentosVencidos = !ValidateDocuments(ticket);
                TieneDocumentosVencidos.Set(tieneDocumentosVencidos);
                if (!NoValidarDocumentos && tieneDocumentosVencidos)
                {
                    return;
                }
            }

            panelStartTicket.Visible  = opened == null;
            panelOpenedTicket.Visible = opened != null;
            mpePanel.CancelControlID  = opened == null ? btCancelar.ID : btOpenedCancelar.ID;

            mpePanel.Show();

            dtHora.SelectedDate = ticket.FechaTicket.Value.ToDisplayDateTime();
        }
Ejemplo n.º 2
0
        protected void btIniciar_Click(object sender, EventArgs e)
        {
            mpePanel.Hide();
            if (TicketToInitId.Get() <= 0)
            {
                return;
            }

            var date = dtHora.SelectedDate;

            if (!date.HasValue)
            {
                ThrowMustEnter("FECHA");
            }

            var ticket = DAOFactory.TicketDAO.FindById(TicketToInitId.Get());

            TicketToInitId.Set(-1);

            SetStartDate(ticket, SecurityExtensions.ToDataBaseDateTime(date.Value));

            var messageSaver = new MessageSaver(DAOFactory);

            var ciclo = new CicloLogisticoHormigon(ticket, DAOFactory, messageSaver);

            var evento = new InitEvent(DateTime.UtcNow);

            try
            {
                ciclo.ProcessEvent(evento);
                ShowInfo(CultureManager.GetSystemMessage("CLOG_START_SENT") + ticket.Vehiculo.Interno);
                Bind();
                if (TieneDocumentosVencidos.Get())
                {
                    messageSaver.Save(MessageCode.CicloLogisticoIniciadoDocumentosInvalidos.GetMessageCode(),
                                      ticket.Vehiculo, evento.Date.AddSeconds(1), null, string.Empty);
                }
            }
            catch (NoVehicleException)
            {
                ShowError(new ApplicationException(CultureManager.GetError("TICKET_NO_VEHICLE_ASSIGNED")));
            }
            catch //AlreadyOpenException, QueueException, Exception
            {
                ShowError(new ApplicationException(CultureManager.GetError("CLOG_MESSAGE_NOT_SENT") + ticket.Vehiculo.Interno));
            }
        }
Ejemplo n.º 3
0
 protected void btCancelar_Click(object sender, EventArgs e)
 {
     TicketToInitId.Set(-1);
 }