Exemple #1
0
 public Ticket BookTicket(Trip trip, int noOfPassengers, string travelClass, out bool couponStatus)
 {
     if (trip != null)
     {
         Ticket ticket;
         if (trip.TravelClass.Contains(travelClass) && trip.Availability.Length > noOfPassengers)
         {
             ticket = new Ticket(trip, noOfPassengers, travelClass);
             TicketHistory.Add(ticket);
             couponStatus = CheckForCoupon(ticket);
             return(ticket);
         }
     }
     couponStatus = false;
     return(null);
 }
Exemple #2
0
        private void AddTicket()
        {
            Milestone[] milestones = Project.GetMilestones(mContext);
            if (milestones.Length == 0)
            {
                MessageBox.Show(
                    Resources.String_PleaseAddAMilestoneBeforeAddingATicket,
                    Resources.String_Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    FormUtil.GetMessageBoxOptions(this));
                tabControl.SelectedTab = milestonesTabPage;
                return;
            }

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, null)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Ticket ticket = form.RetrieveTicket();

                // Add.
                ticket.Add(mContext);

                // Flush.
                mContext.Flush();

                // Create ticket history entry.
                TicketHistory ticketHistory = ticket.NewHistory(Resources.String_TicketCreated);
                ticketHistory.Add(mContext);

                // Show tickets.
                ShowTickets();

                FormUtil.SelectNew(ticketsListView, ticket);

                UpdateButtonsEnabledProperty();

                ticketsListView.Focus();

                UpdateTicket(true);
            }
        }