Ejemplo n.º 1
0
        public string InsertRoomDetails(RoomDetails Inroomdetails)
        {
            try
            {
                ServiceHotelContextCls TC = new ServiceHotelContextCls();
                TC.rooms.Add(Inroomdetails);
                TC.SaveChanges();

                return("1 Row Inserted");
            }
            catch (DbUpdateException Ex)
            {
                SqlException sql = (SqlException)Ex.GetBaseException();
                return(sql.Message);
            }
        }
Ejemplo n.º 2
0
        public string InsertCity(City Incity)
        {
            try
            {
                ServiceHotelContextCls TC = new ServiceHotelContextCls();
                TC.cities.Add(Incity);
                TC.SaveChanges();

                return("1 Row Inserted");
            }
            catch (DbUpdateException Ex)
            {
                SqlException sql = (SqlException)Ex.GetBaseException();
                return(sql.Message);
            }
        }
Ejemplo n.º 3
0
        public string Upadtehotel(HotelDetails UH)
        {
            //SqlConnection con = new SqlConnection("data source=LAPTOP-OIHMLL23; persist security info=True; initial catalog=HotelJBP;user id=sa;password=abhi123");
            //con.Open();
            //SqlCommand cmd = new SqlCommand("update tblHotelDetails set HotelName=@HotelName where HotelId=@HotelId", con);
            //cmd.Parameters.AddWithValue("@HotelId", UH.HotelId);
            //cmd.Parameters.AddWithValue("@HotelName", UH.HotelName);

            //cmd.ExecuteNonQuery();
            //con.Close();

            //return "1 Row Update";

            try
            {
                var LE = from L in yy.hotels
                         where L.HotelId == UH.HotelId

                         select L;
                HotelDetails E = LE.First();
                E.HotelName            = UH.HotelName;
                E.HotelAddress         = UH.HotelAddress;
                E.HotelDes             = UH.HotelDes;
                E.ContactNo            = UH.ContactNo;
                E.TotalAcRooms         = UH.TotalAcRooms;
                E.AcRoomsAdultRate     = UH.AcRoomsAdultRate;
                E.AcRoomsChildtRate    = UH.AcRoomsChildtRate;
                E.NonAcRoomsAdultRate  = UH.NonAcRoomsAdultRate;
                E.NonAcRoomsChildtRate = UH.NonAcRoomsChildtRate;



                yy.SaveChanges();
                return("Data Update Successfully");
            }

            catch (Exception ET)
            {
                return("Please Try Again");
            }
        }
Ejemplo n.º 4
0
        public string Addhotel(HotelDetails AH)
        {
            try
            {
                ServiceHotelContextCls TC = new ServiceHotelContextCls();
                TC.hotels.Add(AH);
                TC.SaveChanges();

                return("Record Saved Successfully");
            }
            catch (DbUpdateException Ex)
            {
                SqlException sql = (SqlException)Ex.GetBaseException();
                return(sql.Message);
            }

            catch (Exception EE)
            {
                return("Please Try Again");
            }
        }
Ejemplo n.º 5
0
        public string Removehotel(string RH)
        {
            using (ServiceHotelContextCls Delhotel = new ServiceHotelContextCls())
            {
                try
                {
                    var res = (from D1 in Delhotel.hotels
                               where D1.HotelId == RH
                               select D1).FirstOrDefault();


                    Delhotel.hotels.Remove(res);

                    Delhotel.SaveChanges();

                    return("Data Deleted Successfully");
                }
                catch (DbUpdateException Ex)
                {
                    SqlException sql = (SqlException)Ex.GetBaseException();
                    return(sql.Message);
                }
            }
        }