温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:酒店管理系统(三层开发)源码
当前文件:
ThreeLayerHotel/WebSite_hotel/SelectRoomType.aspx.cs,打开代码结构图
ThreeLayerHotel/WebSite_hotel/SelectRoomType.aspx.cs,打开代码结构图12
using System; 3
using System.Collections; 4
using System.Configuration; 5
using System.Data; 6
using System.Linq; 7
using System.Web; 8
using System.Web.Security; 9
using System.Web.UI; 10
using System.Web.UI.HtmlControls; 11
using System.Web.UI.WebControls; 12
using System.Web.UI.WebControls.WebParts; 13
using System.Xml.Linq; 14
using BLL; 15
using Entity; 16
17
public partial class SelectRoomType : System.Web.UI.Page 18
{ 19
20
protected void Page_Load(object sender, EventArgs e) 21
{ 22
if (!IsPostBack) 23
{ 24
if (Session["Name"] == null) 25
{ 26
Response.Redirect("Index.aspx"); 27
} 28
29
if (Session["Status"].ToString() == "普通用户") 30
{ 31
GridView1.Columns[5].Visible = false; 32
GridView1.Columns[6].Visible = false; 33
GridView2.Columns[5].Visible = false; 34
GridView2.Columns[6].Visible = false; 35
GridView1.Columns[7].Visible = true; 36
GridView2.Columns[7].Visible = true; 37
} 38
else 39
{ 40
GridView1.Columns[7].Visible = false; 41
GridView2.Columns[7].Visible = false; 42
} 43
MultiView3.ActiveViewIndex = 0; 44
Bind(); 45
} 46
} 47
/// <summary> 48
/// 查询所有 49
/// </summary> 50
void Bind() 51
{ 52
DataTable dt = RoomTypeBLL.GetRoomTypeByFilter(); 53
GridView1.DataSource = dt; 54
GridView1.DataBind(); 55
} 56
/// <summary> 57
/// 按条件查询 58
/// </summary> 59
void Bind1() 60
{ 61
DataTable dt = RoomTypeBLL.GetRoomTypeByFilter(txtfilter.Text); 62
GridView2.DataSource = dt; 63
GridView2.DataBind(); 64
65
} 66
67
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 68
{ 69
string TypeID = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString(); 70
if (Session["Status"].ToString() == "普通用户") 71
{ 72
Response.Redirect("SelectRoomTypeInfo.aspx?TypeID=" + TypeID); 73
} 74
else 75
{ 76
Response.Redirect("UpdateRoomType.aspx?TypeID=" + TypeID); 77
} 78
} 79
80
void Del(int TypeID) 81
{ 82
if (RoomTypeBLL.GetRoomTypeByRoom_TypeID(TypeID)) 83
{ 84
Session["flag"] = "已存在该房间类型的房间,不能删除...要删除请先删除该类型的房间..."; 85
Response.Redirect("success.aspx"); 86
} 87
else 88
{ 89
RoomTypeEntity RTE = new RoomTypeEntity(); 90
RTE.TypeID = TypeID; 91
if (RoomTypeBLL.DeleteRoomType(RTE) == 1) 92
{ 93
if (MultiView3.ActiveViewIndex == 0) 94
Bind(); 95
else 96
Bind1(); 97
} 98
} 99
} 100
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 101
{ 102
GridView1.PageIndex = e.NewPageIndex; 103
Bind(); 104
} 105
protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e) 106
{ 107
int TypeID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); 108
Del(TypeID); 109
} 110
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) 111
{ 112
string TypeID = GridView2.DataKeys[GridView2.SelectedIndex].Value.ToString(); 113
if (Session["Status"].ToString() == "普通用户") 114
{ 115
Response.Redirect("SelectRoomTypeInfo.aspx?TypeID=" + TypeID); 116
} 117
else 118
{ 119
Response.Redirect("UpdateRoomType.aspx?TypeID=" + TypeID); 120
} 121
} 122
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e) 123
{ 124
GridView2.PageIndex = e.NewPageIndex; 125
Bind1(); 126
} 127
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e) 128
{ 129
int TypeID = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value); 130
Del(TypeID); 131
} 132
133
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 134
{ 135
if (e.Row.RowType == DataControlRowType.DataRow) 136
{ 137
e.Row.Attributes.Add("onmouseover", "current=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); 138
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=current"); 139
} 140
} 141
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) 142
{ 143
if (e.Row.RowType == DataControlRowType.DataRow) 144
{ 145
e.Row.Attributes.Add("onmouseover", "current=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); 146
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=current"); 147
} 148
} 149
protected void LinkButton12_Click(object sender, EventArgs e) 150
{ 151
MultiView3.ActiveViewIndex = 1; 152
Bind1(); 153
} 154
protected void LinkButton13_Click(object sender, EventArgs e) 155
{ 156
MultiView3.ActiveViewIndex = 0; 157
Bind(); 158
} 159
} 160





}
}