コード例 #1
0
        public void DoReservation(ReservationHotelVol reservation)
        {
            ReservationHotels resaHotel = new ReservationHotels();
            ReservationVols resaVol = new ReservationVols();

            if (reservation == null)
            {
                throw new ArgumentNullException("Reservation incorrecte", "reservation");
            }
            if(reservation.DateEnd == null || reservation.DateStart == null)
            {
                throw new ArgumentNullException("Dates incorrectes");
            }
            else
            {
                if(reservation.DateStart > reservation.DateEnd)
                {
                    throw new ArgumentException("Dates de début après la date de fin.");
                }
            }
            if(reservation.Hotel == null)
            {
                throw new ArgumentNullException("Hotel incorrect", "hotel");
            }
            if(reservation.Vol == null)
            {
                throw new ArgumentNullException("Vol incorrect", "Vol");
            }

            resaHotel.ReservationHotel(reservation);
            resaVol.ReservationVol(reservation);
        }
コード例 #2
0
        public void ReservationVol(ReservationHotelVol reservation)
        {
            SqlConnection MyC = new SqlConnection();
            MyC.ConnectionString = "Data Source=(local)\\SQLEXPRESS; Initial Catalog=cmd_vols; Integrated Security = true";
            MyC.Open();
            SqlCommand MyCom = new SqlCommand("insertCmdVols", MyC);
            MyCom.CommandType = CommandType.StoredProcedure;

            // Client
            MyCom.Parameters.Add("@FirstName", SqlDbType.VarChar);
            MyCom.Parameters["@FirstName"].Value = reservation.Client.FirstName;
            MyCom.Parameters.Add("@LastName", SqlDbType.VarChar);
            MyCom.Parameters["@LastName"].Value = reservation.Client.LastName;
            MyCom.Parameters.Add("@Address", SqlDbType.VarChar);
            MyCom.Parameters["@Address"].Value = reservation.Client.Address;
            MyCom.Parameters.Add("@Phone", SqlDbType.VarChar);
            MyCom.Parameters["@Phone"].Value = reservation.Client.Phone;
            MyCom.Parameters.Add("@Mail", SqlDbType.VarChar);
            MyCom.Parameters["@Mail"].Value = reservation.Client.Mail;
            MyCom.Parameters.Add("@PostalCode", SqlDbType.VarChar);
            MyCom.Parameters["@PostalCode"].Value = reservation.Client.PostalCode;
            MyCom.Parameters.Add("@City", SqlDbType.VarChar);
            MyCom.Parameters["@City"].Value = reservation.Client.City;
            MyCom.Parameters.Add("@Country", SqlDbType.VarChar);
            MyCom.Parameters["@Country"].Value = reservation.Client.Country;

            // Vols
            MyCom.Parameters.Add("@Vols_name", SqlDbType.VarChar);
            MyCom.Parameters["@Vols_name"].Value = reservation.Vol.Name;
            MyCom.Parameters.Add("@Vols_from", SqlDbType.VarChar);
            MyCom.Parameters["@Vols_from"].Value = reservation.Vol.From;
            MyCom.Parameters.Add("@Vols_to", SqlDbType.VarChar);
            MyCom.Parameters["@Vols_to"].Value = reservation.Vol.To;
            MyCom.Parameters.Add("@Vols_category", SqlDbType.VarChar);
            MyCom.Parameters["@Vols_category"].Value = reservation.Vol.Category;
            MyCom.Parameters.Add("@Vols_DateStart", SqlDbType.DateTime);
            MyCom.Parameters["@Vols_DateStart"].Value = reservation.DateStart;
            MyCom.Parameters.Add("@Vols_DateEnd", SqlDbType.DateTime);
            MyCom.Parameters["@Vols_DateEnd"].Value = reservation.DateEnd;
            MyCom.Parameters.Add("@Vols_Price", SqlDbType.Money);
            MyCom.Parameters["@Vols_Price"].Value = reservation.Vol.Price;

            int Res = Convert.ToInt32(MyCom.ExecuteScalar());
            MyCom.Dispose();
            MyC.Close();
        }
コード例 #3
0
 public void Reserver(ReservationHotelVol reservation)
 {
     Reservation resa = new Reservation();
     resa.DoReservation(reservation);
 }