📄 userreception.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 UserReception : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!IsPostBack)
{
if (Session["Name"] == null)
{
Response.Redirect("Index.aspx");
}
}
MultiView4.ActiveViewIndex = 0;
Bind();
}
}
/// <summary>
/// 查询所有
/// </summary>
void Bind()
{
DataTable dt = UserRoomBLL.GetReceptionTable();
GridView1.DataSource = dt;
GridView1.DataBind();
}
/// <summary>
/// 条件查询
/// </summary>
void Bind1()
{
if (ddl.Text == "用户ID")
{
DataTable dt = UserRoomBLL.GetUserReceptionByUserName(txtfilter.Text);
GridView2.DataSource = dt;
GridView2.DataBind();
}
else
{
DataTable dt = UserRoomBLL.GetUserReceptionByName(txtfilter.Text);
GridView2.DataSource = dt;
GridView2.DataBind();
}
}
void Do(int RoomID)
{
DataTable dt = UserRoomBLL.GetUserReceptionStateByRoomID(RoomID);
if (dt.Rows[0]["state"].ToString() == "已预订")
{
int flag = UserRoomBLL.UpdateUserReceptionStateByRoomID(RoomID);
if (flag == 1)
{
Session["flag"] = "成功的将用户“" + dt.Rows[0]["username"].ToString() + "”预订的房间“" + dt.Rows[0]["Number"] + "”修改为入住状态";
if (MultiView4.ActiveViewIndex == 0)
Bind();
else
Bind1();
}
}
else
{
return;
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int RoomID = Convert.ToInt32(GridView1.DataKeys[GridView1.SelectedIndex].Value);
Do(RoomID);
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
int RoomID = Convert.ToInt32(GridView2.DataKeys[GridView2.SelectedIndex].Value);
Do(RoomID);
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Bind();
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView2.PageIndex = e.NewPageIndex;
Bind1();
}
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 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 LinkButton12_Click(object sender, EventArgs e)
{
MultiView4.ActiveViewIndex = 0;
Bind();
}
protected void LinkButton11_Click(object sender, EventArgs e)
{
MultiView4.ActiveViewIndex = 1;
Bind1();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -