Example #1
0
        public static Tickets Load(System.IO.TextReader textIn)                      //Load method for customer class using StreamReader  GB
        {
            Tickets result = null;

            try
            {
                string      PlayID     = textIn.ReadLine();
                string      TicketID   = textIn.ReadLine();
                string      CustomerID = textIn.ReadLine();
                PRICE_RANGE priceRange = (PRICE_RANGE)Enum.Parse(typeof(PRICE_RANGE), textIn.ReadLine());
                DateTime    playtime   = Convert.ToDateTime(textIn.ReadLine());
                string      TicketNO   = textIn.ReadLine();
                result = new Tickets(PlayID, TicketID, CustomerID, priceRange, playtime, TicketNO);
            }
            catch
            {
                return(null);
            }
            return(result);
        }
Example #2
0
        public static Tickets Load(string filename)
        {
            Tickets result = null;

            System.IO.TextReader textIn = null;
            try
            {
                textIn = new System.IO.StreamReader(filename);
                result = Tickets.Load(textIn);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (textIn != null)
                {
                    textIn.Close();
                }
            }
            return(result);
        }
Example #3
0
        //Creates a booking(s) for a given customer ID and Play.
        public bool AddBooking(string incustomerID, string inPlayID, int Amount, List <string> seatLocations)
        {
            try
            {
                string CustomerId = incustomerID;
                string playID     = inPlayID;
                for (int i = 0; i < Amount; i++)
                {
                    string TicketID = seatLocations[i];
                    string TicketNo = (PlayDictionary[playID].getTicketsSold() + 1).ToString();
                    PlayDictionary[playID].Addticket();
                    Tickets NewBooking = new Tickets(inPlayID, TicketID, CustomerId, PlayDictionary[playID].GetPrice(), DateTime.Now, TicketNo);

                    TicketsDictionary.Add(TicketID, NewBooking);
                }

                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(false);
            }
        }