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

📄 selectroomtype.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 SelectRoomType : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Name"] == null)
            {
                Response.Redirect("Index.aspx");
            }

            if (Session["Status"].ToString() == "普通用户")
            {
                GridView1.Columns[5].Visible = false;
                GridView1.Columns[6].Visible = false;
                GridView2.Columns[5].Visible = false;
                GridView2.Columns[6].Visible = false;
                GridView1.Columns[7].Visible = true;
                GridView2.Columns[7].Visible = true;
            }
            else
            {
                GridView1.Columns[7].Visible = false;
                GridView2.Columns[7].Visible = false;
            }
            MultiView3.ActiveViewIndex = 0;
            Bind();
        }
    }
    /// <summary>
    /// 查询所有
    /// </summary>
    void Bind()
    {
        DataTable dt = RoomTypeBLL.GetRoomTypeByFilter();
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
    /// <summary>
    /// 按条件查询
    /// </summary>
    void Bind1()
    {
        DataTable dt = RoomTypeBLL.GetRoomTypeByFilter(txtfilter.Text);
        GridView2.DataSource = dt;
        GridView2.DataBind();
        
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string TypeID = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
        if (Session["Status"].ToString() == "普通用户")
        {
            Response.Redirect("SelectRoomTypeInfo.aspx?TypeID=" + TypeID);
        }
        else
        {
            Response.Redirect("UpdateRoomType.aspx?TypeID=" + TypeID);
        }
    }

    void Del(int TypeID)
    { 
        if (RoomTypeBLL.GetRoomTypeByRoom_TypeID(TypeID))
        {
            Session["flag"] = "已存在该房间类型的房间,不能删除...要删除请先删除该类型的房间...";
            Response.Redirect("success.aspx");
        }
        else
        {
            RoomTypeEntity RTE = new RoomTypeEntity();
            RTE.TypeID = TypeID;
            if (RoomTypeBLL.DeleteRoomType(RTE) == 1)
            {
                if (MultiView3.ActiveViewIndex == 0)
                    Bind();
                else
                    Bind1();
            }
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        Bind();
    }
    protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
    {
        int TypeID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
        Del(TypeID);
    }
    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {
        string TypeID = GridView2.DataKeys[GridView2.SelectedIndex].Value.ToString();
        if (Session["Status"].ToString() == "普通用户")
        {
            Response.Redirect("SelectRoomTypeInfo.aspx?TypeID=" + TypeID);
        }
        else
        {
            Response.Redirect("UpdateRoomType.aspx?TypeID=" + TypeID);
        }
    }
    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView2.PageIndex = e.NewPageIndex;
        Bind1();
    }
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int TypeID = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value);
        Del(TypeID);
    }

    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)
    {
        MultiView3.ActiveViewIndex = 1;
        Bind1();
    }
    protected void LinkButton13_Click(object sender, EventArgs e)
    {
        MultiView3.ActiveViewIndex = 0;
        Bind();
    }
}

⌨️ 快捷键说明

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