📄 bookonline.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
using Entity;
public partial class BookOnLine : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["Name"] == null)
{
Response.Redirect("Index.aspx");
}
Label7.Text = Request.RawUrl;
if (!string.IsNullOrEmpty(Request.QueryString["RoomID"]))
{
MultiView5.ActiveViewIndex = 1;
Show(Convert.ToInt32(Request.QueryString["RoomID"]));
Label7.Text = Request.UrlReferrer.ToString();
}
else
{
MultiView5.ActiveViewIndex = 0;
MultiView4.ActiveViewIndex = 0;
Bind1();
}
}
}
void Bind1()
{
RoomEntity RE = new RoomEntity();
DataTable dt = RoomBLL.GetRoom_RoomTypeInfo();
GridView1.DataSource = dt;
GridView1.DataBind();
}
void Bind()
{
int bednumber = 0;
int guestnumber = 0;
if (txtbednumber.Text != "")
{
bednumber = Convert.ToInt32(txtbednumber.Text);
}
if (txtguestnumber.Text != "")
{
guestnumber = Convert.ToInt32(txtguestnumber.Text);
}
DataTable dt = RoomBLL.GetRoom_RoomTypeInfo(DropDownList1.Text,bednumber, guestnumber);
GridView2.DataSource = dt;
GridView2.DataBind();
}
void Show(int RoomID)
{
DataTable dt = RoomBLL.GetRoom_RoomTypeInfoByRoomID(RoomID);
lbladdbedprice.Text = dt.Rows[0]["AddBedPrice"].ToString();
lblbednumber.Text = dt.Rows[0]["bedNumber"].ToString();
lblguestnumber.Text = dt.Rows[0]["GuestNumber"].ToString();
lblisaddbed.Text = dt.Rows[0]["IsAddbed"].ToString();
lblnumber.Text = dt.Rows[0]["Number"].ToString();
lbldescription.Text = dt.Rows[0]["Description"].ToString();
lbltypename.Text = dt.Rows[0]["TypeName"].ToString();
lblstate.Text = dt.Rows[0]["State"].ToString();
lbltypeprice.Text = dt.Rows[0]["TypePrice"].ToString();
Image1.ImageUrl = dt.Rows[0]["ImageURL"].ToString();
Image1.ToolTip = dt.Rows[0]["TypeName"].ToString();
lblRoomID.Text = RoomID.ToString();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
MultiView5.ActiveViewIndex = 1;
int RoomID = Convert.ToInt32(GridView1.DataKeys[GridView1.SelectedIndex].Value);
Show(RoomID);
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
Response.Redirect(Label7.Text);
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
if (lblstate.Text == "空房")
{
int flag = RoomBLL.UpdateStateByRoomID(Convert.ToInt32(lblRoomID.Text));
if (flag == 1)
{
lblstate.Text = "已预订";
int UserID = HotelUserBLL.GetUserIDByUserName(Session["Name"].ToString());
UserRoomEntity URE = new UserRoomEntity();
URE.UserID = UserID;
URE.State = lblstate.Text;
URE.RoomID = Convert.ToInt32(lblRoomID.Text);
if (UserRoomBLL.AddUserRoom(URE) == 1)
{
Session["flag"] = "成功预订房间:"+lblnumber.Text;
Response.Redirect("success.aspx");
}
}
}
else
{
Label8.Visible = true;
Label8.Text = "该房间已有人住或正在维修中,不能预订...";
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
Bind1();
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
MultiView5.ActiveViewIndex = 1;
int RoomID = Convert.ToInt32(GridView2.DataKeys[GridView2.SelectedIndex].Value);
Show(RoomID);
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView2.PageIndex = e.NewPageIndex;
Bind();
}
void All()
{
MultiView4.ActiveViewIndex = 0;
Bind1();
}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "current=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=current");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "current=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=current");
}
}
protected void LinkButton11_Click(object sender, EventArgs e)
{
MultiView4.ActiveViewIndex = 1;
Bind();
}
protected void LinkButton12_Click(object sender, EventArgs e)
{
All();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
Label8.Visible = false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -