コード例 #1
0
        private decimal setTotalPrice()
        {
            decimal totalPrice = 0;
            Journey j          = Journey.getJourneyByID(journeyID);
            Route   r          = Route.getRouteByID(j.RouteID);

            totalPrice += this.numberOfSeats * r.Price;

            totalPrice += this.movies.Count * 4;

            this.totalPrice = totalPrice;
            return(totalPrice);
        }
コード例 #2
0
        public static Journey getJourneyByID(int id)
        {
            List <Route> routes = new List <Route>();

            string     command    = "SELECT * FROM ebJourney WHERE journey_ID = " + id + ";";
            SqlCommand sqlCommand = new SqlCommand(command, DbConn.getInstance().Conn);

            DbConn.getInstance().open();
            try
            {
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        int     journeyID = reader.GetInt32(reader.GetOrdinal("journey_ID"));
                        int     routeID   = reader.GetInt32(reader.GetOrdinal("route_ID"));
                        int     timeID    = reader.GetInt32(reader.GetOrdinal("time_ID"));
                        int     coachID   = reader.GetInt32(reader.GetOrdinal("coach_ID"));
                        Journey j         = new Journey(journeyID, routeID, timeID, coachID);
                        return(j);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (ArgumentOutOfRangeException aoorex)
            {
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                DbConn.getInstance().close();
            }
        }