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

📄 viewroomtype.aspx.cs

📁 一个简单的宾馆管理系统 环境:SQL Server Visual C#
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HotelManager.BLL;
using HotelManager.Models;
/*********************************
 * 类名:ViewRoomType
 * 功能描述:提供客房类型信息预览页面  
 * ******************************/
public partial class ViewRoomType : System.Web.UI.Page
{
    #region "Event Handlers"
    /// <summary>
    /// 页面加载时,绑定类型信息
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindRoomType();
        }
    }
    /// <summary>
    /// 执行GridView数据行绑定事件
    /// </summary>
    protected void gvRoomType_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //设置行颜色   
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ff9900'");
            //添加自定义属性,当鼠标移走时还原该行的背景色   
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
            //添加删除确认
            ImageButton imgbtn = (ImageButton)e.Row.FindControl("imgbtnDelete");
            imgbtn.Attributes.Add("onclick", "return confirm('您确认要删除吗?');");
        }
    }
    /// <summary>
    /// 执行GridView数据行按钮事件
    /// </summary>
    protected void gvRoomType_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string cmd = e.CommandName;//获取命令名称
        int typeId = Convert.ToInt32(e.CommandArgument);//获取命令参数
        if (cmd == "De")
        {
            //删除类型信息
            RoomTypeManager.DeleteRoomTypeByTypeId(typeId);
        }
        else if (cmd == "Ed")
        {
            //编辑类型信息
            Page.Server.Transfer("EditRoomType.aspx?typeId=" + Convert.ToString(typeId));
        }
        BindRoomType();
    }
    /// <summary>
    /// 执行分页事件
    /// </summary>
    protected void gvRoomType_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvRoomType.PageIndex = e.NewPageIndex;
        BindRoomType();
    }
    #endregion

    #region "Public Methods"
    /// <summary>
    /// 绑定类型信息
    /// </summary>
    public void BindRoomType()
    {
        this.gvRoomType.DataSource = RoomTypeManager.GetAllRoomTypes();
        this.gvRoomType.DataBind();
    }
    #endregion
}

⌨️ 快捷键说明

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