示例#1
0
        /// <summary>
        /// Deletes hotel information from database
        /// </summary>
        /// <param name="hotel"></param>
        /// <returns>Status of the delete operation of a hotel</returns>
        public bool DeleteHotel(Model.Entities.Hotel.Hotel hotel)
        {
            bool isDeleted = true;

            try
            {
                DataSet      hotelDS  = this.GetAllHotels();
                DataColumn[] pkColumn = new DataColumn[1];
                pkColumn[0] = hotelDS.Tables[0].Columns["HotelId"];
                hotelDS.Tables[0].PrimaryKey = pkColumn;
                hotelDS.Tables[0].Rows.Find(hotel.HotelId).Delete();
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(dataAdapter as SqlDataAdapter);
                dataAdapter.Update(hotelDS);
            }
            catch (SqlException ex)
            {
                throw new HotelDAOException("Unable to delete hotel info", ex);
            }
            catch (Exception e)
            {
                throw new HotelDAOException("Unable to delete hotel info", e);
            }

            return(isDeleted);
        }
        /// <summary>
        /// Inserts hotel information into database
        /// </summary>
        /// <param name="hotel"></param>
        /// <returns>Status of the insert operation of the hotel</returns>
        public bool SaveHotel(Model.Entities.Hotel.Hotel hotel)
        {
            bool isSaved = true;

            try
            {
                DataSet hotelDS = this.GetAllHotels();
                DataRow row     = hotelDS.Tables[0].NewRow();
                row["HotelId"]     = hotel.HotelId;
                row["HotelName"]   = hotel.HotelName;
                row["Address"]     = hotel.Address;
                row["BriefNote"]   = hotel.BriefNote;
                row["CityId"]      = hotel.CityID;
                row["PhotoURL"]    = hotel.PhotoUrl;
                row["ContactNo"]   = hotel.ContactNo;
                row["EMail"]       = hotel.Email;
                row["Pincode"]     = hotel.Pincode;
                row["StarRanking"] = hotel.StarRanking;
                row["WebsiteURL"]  = hotel.WebsiteURL;
                dataAdapter.Update(hotelDS);
            }
            catch (SqlException ex)
            {
                throw new HotelDAOException("Unable to insert hotel info", ex);
            }
            catch (Exception e)
            {
                throw new HotelDAOException("Unable to insert hotel info", e);
            }

            return(isSaved);
        }
        /// <summary>
        /// Deletes hotel information from database
        /// </summary>
        /// <param name="hotel"></param>
        /// <returns>Status of the delete operation of a hotel</returns>
        public bool DeleteHotel(Model.Entities.Hotel.Hotel hotel)
        {
            bool isDeleted = true;

            try
            {
                DataSet hotelDS = this.GetAllHotels();
                dataAdapter.Update(hotelDS);
            }
            catch (SqlException ex)
            {
                throw new HotelDAOException("Unable to delete hotel info", ex);
            }
            catch (Exception e)
            {
                throw new HotelDAOException("Unable to delete hotel info", e);
            }

            return(isDeleted);
        }
示例#4
0
        /// <summary>
        /// Inserts hotel information into database
        /// </summary>
        /// <param name="hotel"></param>
        /// <returns>Status of the insert operation of the hotel</returns>
        public bool SaveHotel(Model.Entities.Hotel.Hotel hotel)
        {
            bool isSaved = true;

            try
            {
                DataSet hotelDS = this.GetAllHotels();

                DataColumn[] pkColumn = new DataColumn[1];
                pkColumn[0] = hotelDS.Tables[0].Columns["HotelId"];
                hotelDS.Tables[0].PrimaryKey = pkColumn;

                DataRow row = hotelDS.Tables[0].NewRow();
                row["HotelId"]     = hotel.HotelId;
                row["HotelName"]   = hotel.HotelName;
                row["Address"]     = hotel.Address;
                row["BriefNote"]   = hotel.BriefNote;
                row["CityId"]      = hotel.CityID;
                row["PhotoURL"]    = hotel.PhotoUrl;
                row["ContactNo"]   = hotel.ContactNo;
                row["EMail"]       = hotel.Email;
                row["Pincode"]     = hotel.Pincode;
                row["StarRanking"] = hotel.StarRanking;
                row["WebsiteURL"]  = hotel.WebsiteURL;

                hotelDS.Tables[0].Rows.Add(row);
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(dataAdapter as SqlDataAdapter);
                dataAdapter.Update(hotelDS);
            }
            catch (SqlException ex)
            {
                throw new HotelDAOException("Unable to insert hotel info", ex);
            }
            catch (Exception e)
            {
                throw new HotelDAOException("Unable to insert hotel info", e);
            }

            return(isSaved);
        }