コード例 #1
0
        //
        /// <summary>
        /// MEthod for Retrieving BookingID
        /// </summary>
        /// <param name="_userId"> User ID</param>
        /// <returns> Returns List of Booking ID</returns>
        public List <EntityLayers.Booking> RegBookingIDRetrival(string _userId)
        {
            SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");

            try
            {
                SqlCommand _cmd1 = new SqlCommand("select BookingId from Booking where UserID = '" + _userId + "' ", _conObj);
                _conObj.Open();
                SqlDataReader dr = _cmd1.ExecuteReader();
                List <EntityLayers.Booking> _listObj = new List <EntityLayers.Booking>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Booking _bobj = new EntityLayers.Booking()
                        {
                            _bookingID = int.Parse(dr[0].ToString())
                        };
                        _listObj.Add(_bobj);
                    }
                }
                return(_listObj);
            }

            catch (Exception)
            {
                throw;
            }

            finally
            {
                _conObj.Close();
            }
        }
        /// <summary>
        /// Method for retreiving BookingID value for Drop down list
        /// </summary>
        /// <returns>Returns List of BookingID</returns>
        public List <EntityLayers.Booking> GetBookingID()
        {
            SqlConnection _conobj = new SqlConnection(constr);

            try
            {
                SqlCommand _cmd = new SqlCommand("select BookingID from Booking Where BookingStatus = 'PENDING'  ", _conobj);
                _conobj.Open();
                SqlDataReader dr = _cmd.ExecuteReader();
                List <EntityLayers.Booking> _listObj1 = new List <EntityLayers.Booking>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Booking _bookDDLObj = new EntityLayers.Booking()
                        {
                            _bookingID = int.Parse(dr[0].ToString())
                        };
                        _listObj1.Add(_bookDDLObj);
                    }
                }
                return(_listObj1);
            }

            catch (SqlException)
            {
                throw;
            }
            finally
            {
                _conobj.Close();
            }
        }
        protected void btnBook_Click(object sender, EventArgs e)
        {
            int _temp;

            txtBookingDate.Text = System.DateTime.Now.ToShortDateString();
            EntityLayers.Booking _bookobj = new EntityLayers.Booking()
            {
                _bookingDate  = txtBookingDate.Text,
                _checkIn      = txtCheckInDate.Text,
                _checkOut     = txtCheckOutDate.Text,
                _guestName    = txtGuestName.Text,
                _identityNO   = txtIdentityNumber.Text,
                _identityType = txtIdentityType.Text,
                _noAdults     = int.Parse(txtNoOfAdults.Text),
                _nochildren   = int.Parse(txtNoOfChildren.Text),
                _noInfants    = int.Parse(txtNoOfInfants.Text),
                _userID       = txtUserID.Text,
                _roomTypeID   = Convert.ToInt32(ddlRoomType.SelectedValue),
                _roomType     = ddlRoomType.SelectedItem.ToString()
            };

            _temp = _serbookObj.BookNow(_bookobj);



            if (_temp == -1)
            {
                Response.Write("<script>alert('Problem with the server register again')</script>");
            }
            else if (_temp == 1)
            {
                UserOperation _uObj = new UserOperation();
                string        _uid  = Session["UserID"].ToString();
                List <EntityLayers.Booking> _lObj = _uObj.RegBookingIDRetrival(_uid);

                int _bID = _lObj[0]._bookingID;
                Session["BookingID"] = _bID;
                Response.Write("<script>alert('Successfully " + _bID + " registered')</script>");
                Response.Redirect("UserHome.aspx");
            }
        }
コード例 #4
0
        /// <summary>
        /// Method for Retreiving Values to Order Food
        /// </summary>
        /// <param name="_bObj1"> Object of Booking class</param>
        /// <returns>Returns Booking Status</returns>
        public List <EntityLayers.Booking> RetreiveOrderFood(Booking _bObj1)
        {
            SqlConnection _conobj = new SqlConnection("server=.; database=HotelDB; trusted_connection=yes");

            try
            {
                SqlCommand _cmd = new SqlCommand("select BookingStatus from Booking where BookingID = " + _bObj1._bookingID + " and UserID ='" + _bObj1._userID + "'  ", _conobj);
                _conobj.Open();

                SqlDataReader dr = _cmd.ExecuteReader();

                List <EntityLayers.Booking> _bObj = new List <EntityLayers.Booking>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Booking _bookAddObj = new EntityLayers.Booking()
                        {
                            _status = dr[0].ToString()
                        };

                        _bObj.Add(_bookAddObj);
                    }
                }

                return(_bObj);
            }

            catch (Exception)
            {
                throw;
            }
            finally
            {
                _conobj.Close();
            }
        }
コード例 #5
0
        /// <summary>
        /// Method for Retreiving values for booking ID to check Booking Status
        /// </summary>
        /// <param name="_bobj">Object of Booking class</param>
        /// <returns>Returns List of Booking status and RoomTypeID</returns>
        public List <EntityLayers.Booking> BookingIDRetrival(Booking _bobj)
        {
            SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");

            try
            {
                SqlCommand _cmd = new SqlCommand("select BookingStatus, RoomTypeID from Booking where BookingID = '" + _bobj._bookingID + "' ", _conObj);
                _conObj.Open();
                SqlDataReader dr = _cmd.ExecuteReader();


                List <EntityLayers.Booking> _listObj = new List <EntityLayers.Booking>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Booking _bookObject = new EntityLayers.Booking()
                        {
                            _status     = dr[0].ToString(),
                            _roomTypeID = int.Parse(dr[1].ToString())
                        };
                        _listObj.Add(_bookObject);
                    }
                }

                return(_listObj);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _conObj.Close();
            }
        }