Exemplo n.º 1
0
        public ScannedStatus ConfirmArrival(ScannedTicket scannedTicket, bool forceUpdate = false)
        {
            logger.logMessage("Request to mak ticket " + scannedTicket.TicketNumber, LogLevel.debug);
            var ticketScanned        = db.TicketsIssueds.FirstOrDefault(a => a.TicketNumber == scannedTicket.TicketNumber);
            var ticketScannedOutcome = new ScannedStatus();

            if (ticketScanned == null)
            {
                return(new ScannedStatus {
                    StatusOfScan = TicketScannedStatus.TicketDoesNotExist
                });
            }
            else
            {
                ticketScannedOutcome.TableNumber  = ticketScanned.TableNumber;
                ticketScannedOutcome.TicketNumber = ticketScanned.TicketNumber;

                ticketScannedOutcome.TicketId = ticketScanned.TicketId;
                if (ticketScanned.ArrivedAt != null)
                {
                    ticketScannedOutcome.StatusOfScan         = TicketScannedStatus.TicketAlreadyScanned;
                    ticketScannedOutcome.TicketScannedMessage = string.Format("Ticket was scanned at {0} and was sold by {1} to {2}", ticketScanned.ArrivedAt, ticketScanned.Agent.AgentName, ticketScanned.SoldTo);
                }
                else
                {
                    ticketScanned.ArrivalConfirmedBy   = scannedTicket.ScannedBy;
                    ticketScanned.ArrivedAt            = DateTime.Now;
                    ticketScannedOutcome.StatusOfScan  = TicketScannedStatus.Ok;
                    ticketScannedOutcome.Zone          = ticketScanned.Zone;
                    ticketScannedOutcome.TicketNotPaid = ticketScanned.TicketStatusCode != Constants.TicketStatus.Paid && ticketScanned.TicketStatusCode != Constants.TicketStatus.PaidNoCharge;
                    if (ticketScannedOutcome.TicketNotPaid)
                    {
                        if (forceUpdate)
                        {
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        db.SaveChanges();
                    }
                }
            }
            return(ticketScannedOutcome);
        }
Exemplo n.º 2
0
        private void UpdateTicketStatus(string ticketNumber)
        {
            logger.logMessage(string.Format("Ticket {0} scanned", ticketNumber), LogLevel.message);
            var scannedTicket = new ScannedTicket(ticketNumber, currentSystemInformation);
            var ticketMarked  = new Business.TicketConfirmerService(logger).ConfirmArrival(scannedTicket);
            var userMessage   = new StringBuilder();

            LabelLastScanned.Text      = ticketMarked.TicketNumber;
            labelLastScannedTable.Text = ticketMarked.TableNumber.HasValue ? ticketMarked.TableNumber.Value.ToString() : "No Table";
            if (ticketMarked.StatusOfScan == TicketScannedStatus.Ok)
            {
                Console.WriteLine(ticketNumber);
                if (ticketMarked.TicketNotPaid)
                {
                    var ticketDetailsForm = new TicketDetails(ticketMarked.TicketId, "This ticket is not paid for, Please collect money");
                    ticketDetailsForm.FormClosed += new FormClosedEventHandler(ob_FormClosed);
                    ticketDetailsForm.Show(this);
                }
                SimpleTicketNumberTextBox.Clear();

                ScannerTabPage.BackColor = Color.LightGreen;
                //ScannedTextBoxInError = false;
            }
            else
            {
                if (ticketMarked.StatusOfScan == TicketScannedStatus.TicketAlreadyScanned)
                {
                    SimpleTicketNumberTextBox.SelectAll();
                    ScannerTabPage.BackColor = Color.Red;
                    //ScannedTextBoxInError = true;
                    MessageBox.Show(ticketMarked.TicketScannedMessage);
                }
                else
                {
                    SimpleTicketNumberTextBox.SelectAll();
                    ScannerTabPage.BackColor = Color.Red;
                    //ScannedTextBoxInError = true;
                    MessageBox.Show("Ticket not found.");
                }
            }
        }