⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectroominfo.aspx.cs

📁 酒店管理系统项目需求说明 第一部分 引言 1 1.1编写目的 1 1.2背景 1 第二部分 任务概述 2 3.1实现目标 2 3.1.1客房类型模块: 2 3.1.2客房信息
💻 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 SelectRoom : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Name"] == null)
            {
                Response.Redirect("Index.aspx");
            }
            if (!string.IsNullOrEmpty(Request.QueryString["TypeName"]))
            {
                MultiView4.ActiveViewIndex = 1;
                Bind2();
            }
            else
            {
                MultiView4.ActiveViewIndex = 0;
                Bind();
            }
            if (Session["Status"].ToString() == "普通用户")
            {
                GridView1.Columns[7].Visible = false;
                GridView1.Columns[8].Visible = false;
                GridView2.Columns[7].Visible = false;
                GridView2.Columns[8].Visible = false;
                GridView1.Columns[9].Visible = true;
                GridView2.Columns[9].Visible = true;
            }
            else
            {
                GridView1.Columns[9].Visible = false;
                GridView2.Columns[9].Visible = false;
            }
        }
    }



    protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {

    }
    /// <summary>
    /// 查询所有
    /// </summary>
    void Bind()
    {
        DataTable dt = RoomBLL.GetRoomByFilter();
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

    /// <summary>
    /// 按条件查询
    /// </summary>
    void Bind1()
    {
        DataTable dt = RoomBLL.GetRoomByFilter(ddl.Text, txtnumber.Text);
        GridView2.DataSource = dt;
        GridView2.DataBind();
    }

    void Bind2()
    {
        string filter = ddl.Text;
        if (!string.IsNullOrEmpty(Request.QueryString["TypeName"]))
        {
            filter = Request.QueryString["TypeName"].ToString();
        }
        DataTable dt = RoomBLL.GetRoomByFilter(filter, txtnumber.Text);
        GridView2.DataSource = dt;
        GridView2.DataBind();
    }

    protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
    {
        string RoomID = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
        if (Session["Status"].ToString() == "普通用户")
        {
            Response.Redirect("BookOnLine.aspx?RoomID=" + RoomID);
        }
        else
        {
            string State = RoomBLL.GetStateByRoomID(Convert.ToInt32(RoomID));
            if (State == "入住" || State == "已预订")
            {
                Session["flag"] = "该房间以有人住或已预订,不能编辑...";
                Response.Redirect("success.aspx");
            }
            else
            {
                Response.Redirect("UpdateRoomInfo.aspx?RoomID=" + RoomID);
            } // get
            //Server.Transfer("") // post
        }
    }

    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {
        string RoomID = GridView2.DataKeys[GridView2.SelectedIndex].Value.ToString();
        if (Session["Status"].ToString() == "普通用户")
        {
            Response.Redirect("BookOnLine.aspx?RoomID=" + RoomID);
        }
        else
        {
            string State = RoomBLL.GetStateByRoomID(Convert.ToInt32(RoomID));
            if (State == "入住" || State == "已预订")
            {
                Session["flag"] = "该房间以有人住或已预订,不能编辑...";
                Response.Redirect("success.aspx");
            }
            else
            {
                Response.Redirect("UpdateRoomInfo.aspx?RoomID=" + RoomID);
            }
        }
    }
    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView2.PageIndex = e.NewPageIndex;
        Bind1();
    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        
        int RoomID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
        Del(RoomID);
    }
    protected void GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        Bind();
    }

    void Del(int RoomID)
    { 
        string State = RoomBLL.GetStateByRoomID(RoomID);
        if (State == "入住" || State == "已预订")
        {
            Session["flag"] = "该房间已有人住或已预订,不能删除...";
            Response.Redirect("success.aspx");
        }
        else
        {
            RoomEntity RE = new RoomEntity();
            RE.RoomID = RoomID;
            if (RoomBLL.DeleteRoom(RE) != 1)
            {
                
            }
            else
            {
                if (MultiView4.ActiveViewIndex == 0)
                    Bind();
                else
                    Bind1();
            }
        }
    }

    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int RoomID = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value);
        Del(RoomID);
    }
    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 LinkButton13_Click(object sender, EventArgs e)
    {
        MultiView4.ActiveViewIndex = 1;
        Bind1();
    }
    protected void LinkButton14_Click(object sender, EventArgs e)
    {
        MultiView4.ActiveViewIndex = 0;
        Bind();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -