Ejemplo n.º 1
0
        public fTickets(AuthorisedUser user)
        {
            InitializeComponent();
            this.user = user;
            ReadingFromDateBase reading = new ReadingFromDateBase();

            ticketsList      = reading.ReadTickets();
            percentsList     = reading.ReadPercentages();
            totalPercentList = reading.ReadTotalPercents();
            statusTicketList = reading.ReadStatusTickets();
            sessionList      = reading.ReadSessions();
            LoadDataGridView();
        }
Ejemplo n.º 2
0
        public ActionResult Tickets(int OrderID)
        {
            var tickets = db.Tickets.Where(c => c.OrderID == OrderID).Include(c => c.Seat).Include(c => c.Customer).Include(c => c.Flight).ToList();

            foreach (var item in tickets)
            {
                item.Flight.ArrivalPlace   = db.Cities.Where(c => c.ID == item.Flight.ArrivalPlaceID).FirstOrDefault();
                item.Flight.DeparturePlace = db.Cities.Where(c => c.ID == item.Flight.DeparturePlaceID).FirstOrDefault();
            }
            var list = new ListOfTickets()
            {
                Tickets = tickets
            };

            return(View(list));
        }
Ejemplo n.º 3
0
        public fTickets(AuthorisedUser user, Session session, int row, int placeNumber, double price)
        {
            InitializeComponent();
            this.user = user;
            ReadingFromDateBase reading = new ReadingFromDateBase();

            ticketsList      = reading.ReadTickets();
            percentsList     = reading.ReadPercentages();
            totalPercentList = reading.ReadTotalPercents();
            statusTicketList = reading.ReadStatusTickets();
            sessionList      = reading.ReadSessions();
            LoadDataGridView();
            SessionInput.Text     = session.FilmSession.FilmName;
            RowInput.Text         = row.ToString();
            PlaceNumberInput.Text = placeNumber.ToString();
            PriceInput.Text       = price.ToString();
            TicketInput.Text      = (ticketsList.Tickets.Count() + 1).ToString();
        }
Ejemplo n.º 4
0
        public ListOfTickets ReadTickets()
        {
            Hall          hall;
            Film          film;
            Session       session;
            PlaceInHall   place;
            List <Ticket> ticketsList       = new List <Ticket>();
            SqlConnection connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    "SELECT TICKET_ID, [TICKETSALES].SESSION_ID, [TICKETSALES].PLACE_ID, AGE_VISITOR, TOTAL_COST, " + // 4
                    "[SESSIONS].SESSION_ID, [SESSIONS].HALL_ID, [SESSIONS].[FILM_ID], DATE_SESSION, TIME_SESSION, " + // 9
                    "NAME_HALL, SEATING_CAPACITY, PLACES_IN_ROW,  " +                                                 //12
                    "[PLACESINHALLS].PLACE_ID, ROW_PLACES, PLACE, " +                                                 //15
                    "NAME_FILM, LENGTH_FILM, AGE_LIMIT, TICKET_PRICE " +                                              //19
                    "FROM [TICKETSALES], [SESSIONS], [PLACESINHALLS], [HALLS], [FILMS]" +
                    "WHERE [TICKETSALES].SESSION_ID = [SESSIONS].SESSION_ID AND [TICKETSALES].PLACE_ID = [PLACESINHALLS].PLACE_ID " +
                    "AND [SESSIONS].HALL_ID = [HALLS].HALL_ID AND [SESSIONS].[FILM_ID] = [FILMS].[FILM_ID] " +
                    "AND [PLACESINHALLS].HALL_ID = [HALLS].HALL_ID;",
                    connectToDateBase);
                connectToDateBase.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        hall  = new Hall(reader.GetInt32(6), reader.GetString(10), reader.GetInt32(11), reader.GetInt32(12));
                        place = new PlaceInHall(reader.GetInt32(13), reader.GetInt32(6), reader.GetInt32(14), reader.GetInt32(15));
                        film  = new Film(reader.GetInt32(7), reader.GetString(16), reader.GetInt32(17),
                                         reader.GetInt32(18), reader.GetInt32(19));
                        session = new Session(reader.GetInt32(5), film, hall, reader.GetDateTime(8), reader.GetTimeSpan(9));
                        Ticket ticket = new Ticket(reader.GetInt32(0), session, place.PlaceNumber, place.Row, reader.GetDateTime(3), reader.GetInt32(4));
                        ticketsList.Add(ticket);
                    }
                }
                reader.Close();
            }
            ListOfTickets tickets = new ListOfTickets(ticketsList);

            return(tickets);
        }
        /// <summary>
        /// These tests mostly operate by printing something out, and relying on the user
        /// to catch errors.
        /// There is some limited automation around the 'isEmpty' method
        /// </summary>
        /// <returns>True if all tests passed ; false if one (or more) failed</returns>
        public bool RunTests()
        {
            bool          retVal = true;
            ListOfTickets lot    = new ListOfTickets();
            Ticket        t;

            Console.WriteLine("\n\n ListOfTicketsts::TESTS \n\n");

            Console.WriteLine(" ================ Test #0: Empty ListOfTickets.isEmpty() =======================");
            if (lot.isEmpty())
            {
                Console.WriteLine("Passed: .isEmpty on empty ListOfTickets returns expected value (true)");
            }
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on empty ListOfTickets returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #1: Print An Empty ListOfTickets =======================");
            Console.WriteLine(" Should should see: \"End Of Test\" on the next line");
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #2: Print A ListOfTickets With 1 Item ==================");
            Console.WriteLine(" Should should see: \"Sample Item\", then \"End Of Test\" on the next 2 lines");
            lot.AddTicket(new Ticket("Sample Item", Priority.Low));
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #3: ListOfTickets with 1 item.isEmpty() =================");
            if (!lot.isEmpty())
            {
                Console.WriteLine("Passed: .isEmpty on ListOfTickets with 1 item returns expected value (true)");
            }
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on ListOfTickets with 1 item returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");


            Console.WriteLine(" ================ Test #4: Add, Remove Leaves ListOfTickets Empty  ========");
            Console.WriteLine(" Should should see: next part of this test, on the next line");
            t = lot.RemoveNextTicket();
            lot.PrintAll();
            Console.WriteLine("\nShould should see: \"Sample Item\", then \"End Of Test\" on the next lines");
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #5: Empty ListOfTickets.isEmpty() =======================");
            if (lot.isEmpty())
            {
                Console.WriteLine("Passed: .isEmpty on (once again) empty ListOfTickets returns expected value (true)");
            }
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on (once again) empty ListOfTickets returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");


            Console.WriteLine(" ================ Test #6: Multiple Adds Preserve Order ============");
            Console.WriteLine(" Should should see: \"Sample Item\", then \"Another Item\", then \"Final Item\", and then \"End Of Test\" on the next 4 lines");
            lot.AddTicket(new Ticket("Sample Item", Priority.Low));
            lot.AddTicket(new Ticket("Another Item", Priority.Low));
            lot.AddTicket(new Ticket("Final Item", Priority.Low));
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #7: ListOfTickets with several items.isEmpty() ===========");
            if (!lot.isEmpty())
            {
                Console.WriteLine("Passed: .isEmpty on ListOfTickets with 1 item returns expected value (true)");
            }
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on ListOfTickets with 1 item returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine("\n\n ListOfTicketsts::End of Tests\n\n");

            return(retVal);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// These tests mostly operate by printing something out, and relying on the user
        /// to catch errors.  
        /// There is some limited automation around the 'isEmpty' method
        /// </summary>
        /// <returns>True if all tests passed ; false if one (or more) failed</returns>
        public bool RunTests()
        {
            bool retVal = true;
            ListOfTickets lot = new ListOfTickets();
            Ticket t;

            Console.WriteLine("\n\n ListOfTicketsts::TESTS \n\n");

            Console.WriteLine(" ================ Test #0: Empty ListOfTickets.isEmpty() =======================");
            if (lot.isEmpty())
                Console.WriteLine("Passed: .isEmpty on empty ListOfTickets returns expected value (true)");
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on empty ListOfTickets returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #1: Print An Empty ListOfTickets =======================");
            Console.WriteLine(" Should should see: \"End Of Test\" on the next line");
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #2: Print A ListOfTickets With 1 Item ==================");
            Console.WriteLine(" Should should see: \"Sample Item\", then \"End Of Test\" on the next 2 lines");
            lot.AddTicket(new Ticket("Sample Item", Priority.Low));
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #3: ListOfTickets with 1 item.isEmpty() =================");
            if (!lot.isEmpty())
                Console.WriteLine("Passed: .isEmpty on ListOfTickets with 1 item returns expected value (true)");
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on ListOfTickets with 1 item returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #4: Add, Remove Leaves ListOfTickets Empty  ========");
            Console.WriteLine(" Should should see: next part of this test, on the next line");
            t = lot.RemoveNextTicket();
            lot.PrintAll();
            Console.WriteLine("\nShould should see: \"Sample Item\", then \"End Of Test\" on the next lines");
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #5: Empty ListOfTickets.isEmpty() =======================");
            if (lot.isEmpty())
                Console.WriteLine("Passed: .isEmpty on (once again) empty ListOfTickets returns expected value (true)");
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on (once again) empty ListOfTickets returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #6: Multiple Adds Preserve Order ============");
            Console.WriteLine(" Should should see: \"Sample Item\", then \"Another Item\", then \"Final Item\", and then \"End Of Test\" on the next 4 lines");
            lot.AddTicket(new Ticket("Sample Item", Priority.Low));
            lot.AddTicket(new Ticket("Another Item", Priority.Low));
            lot.AddTicket(new Ticket("Final Item", Priority.Low));
            lot.PrintAll();
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine(" ================ Test #7: ListOfTickets with several items.isEmpty() ===========");
            if (!lot.isEmpty())
                Console.WriteLine("Passed: .isEmpty on ListOfTickets with 1 item returns expected value (true)");
            else
            {
                Console.WriteLine("FAILED FAILED: .isEmpty on ListOfTickets with 1 item returns unexpected value (false)");
                retVal = false;
            }
            Console.WriteLine("End Of Test\n\n");

            Console.WriteLine("\n\n ListOfTicketsts::End of Tests\n\n");

            return retVal;
        }