Exemplo n.º 1
0
        protected void DeleteRooms(object sender, EventArgs e)
        {
            Button      btn  = (Button)sender;
            GridViewRow gvr  = (GridViewRow)btn.NamingContainer;
            string      name = gvr.Cells[1].Text;
            HotelInfo   hf   = new HotelInfo();

            hf = bookContext.HotelInfos.Single(y => y.HotelName == name);
            bookContext.HotelInfos.DeleteOnSubmit(hf);
            bookContext.SubmitChanges();
            GridView1.DataBind();
        }
Exemplo n.º 2
0
        protected void BookRooms(object sender, EventArgs e)
        {
            Button      btn            = (Button)sender;
            GridViewRow gvr            = (GridViewRow)btn.NamingContainer;
            string      name           = gvr.Cells[1].Text;
            int         availableRooms = Convert.ToInt32(gvr.Cells[3].Text);
            int         bookedRooms    = Convert.ToInt32(gvr.Cells[4].Text);

            gvr.Cells[3].Text = (availableRooms - 1).ToString();
            gvr.Cells[4].Text = (bookedRooms + 1).ToString();
            HotelInfo hf = new HotelInfo();

            hf = bookContext.HotelInfos.Single(y => y.HotelName == name);
            hf.AvailableRooms  = Convert.ToInt32(gvr.Cells[3].Text);
            hf.NoOfBookedRooms = Convert.ToInt32(gvr.Cells[4].Text);
            bookContext.SubmitChanges();
            if (Convert.ToInt32(gvr.Cells[3].Text) == 0)
            {
                btn.Visible = false;
                btn.Parent.Controls[3].Visible = true;
            }
        }
Exemplo n.º 3
0
        protected void AddHotel_Click(object sender, EventArgs e)
        {
            try
            {
                using (BookHotelDataContext dataContext = new BookHotelDataContext())
                {
                    HotelInfo htlInf = new HotelInfo();
                    htlInf.HotelName       = nameTxt.Text;
                    htlInf.PricePerNight   = Convert.ToDecimal(priceTxt.Text);
                    htlInf.AvailableRooms  = Convert.ToInt32(availableTxt.Text);
                    htlInf.NoOfBookedRooms = Convert.ToInt32(bookedTxt.Text);
                    dataContext.HotelInfos.InsertOnSubmit(htlInf);
                    dataContext.SubmitChanges();
                }

                Response.Redirect("BookHotel.aspx");
            }
            catch (Exception ex)
            {
                Response.Write(ex);
            }
        }
Exemplo n.º 4
0
 partial void DeleteHotelInfo(HotelInfo instance);
Exemplo n.º 5
0
 partial void UpdateHotelInfo(HotelInfo instance);
Exemplo n.º 6
0
 partial void InsertHotelInfo(HotelInfo instance);