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

📄 st_rbussimanmodule.ascx.cs

📁 功能强大的酒店管理系统!毕业设计专用!在上呈上!以提使用!
💻 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 System.Data.SqlClient;
public partial class Context_ST_RBussiManModule :ST_ModuleBase
{
    protected string Status;
    private int PageSize = 1;///每页的记录数
    private int CurrentPage;////当前页
    private int RecordCount;///记录数
    private int PageCount;//总页数
    
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!this.IsPostBack)
        {
            SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);/////填冲 房间类型 下拉列表
            SqlCommand ST_mycommand = new SqlCommand();
            ST_mycommand.Connection = ST_myCon;
            ST_mycommand.CommandText = "select ST_RCategoryId,ST_Name from ST_RoomCategory";
            ST_myCon.Open();
            SqlDataReader dl = ST_mycommand.ExecuteReader();
            while (dl.Read())
            {
                ListItem li = new ListItem(dl["ST_Name"].ToString(), dl["ST_RCategoryId"].ToString());
                this.ddlCategory.Items.Add(li);
            }
            dl.Close();
            ST_myCon.Close();
            ViewState["str"]="select * from RoomStatusView";////ViewState["str"]用于保存SQL语句 (次出用于全部显示时)           
            Shoe_RoomList(ViewState["str"].ToString());


           this.CurrentPage = 0;//////当前页
            ViewState["PageIndex"] = 0;
            this.RecordCount = RetrunCount(ViewState["str"].ToString());//得到总记录数

            if (this.RecordCount % this.PageSize == 0)
            {
                this.PageCount = this.RecordCount / this.PageSize;
            }
            else
            {
                this.PageCount = this.RecordCount / this.PageSize;
                this.PageCount++;

            }

            ViewState["PageCount"] = this.PageCount;
        }
    }
    public int RetrunCount(string str)/////得到总记录数
    {
        SQLExe.SQLExe myExe = new SQLExe.SQLExe();
        DataSet tempds = new DataSet();
        tempds = myExe.GetDataSet(str);
        int count = tempds.Tables[0].Rows.Count;
        return count;
 
    }
    public void Shoe_RoomList(string str)
    {
        this.lblPre.Enabled = true;
       this.lblNext.Enabled = true;

        int StartIndex;
        StartIndex = this.CurrentPage * this.PageSize;

        SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
        SqlCommand ST_mycommand = new SqlCommand();        
        DataSet ds = new DataSet();
        SqlCommand myCommand = new SqlCommand();
        SqlDataAdapter sda = new SqlDataAdapter();
        myCommand.Connection = ST_myCon;
        myCommand.CommandText=str;
        sda.SelectCommand = myCommand;
        sda.Fill(ds, StartIndex, this.PageSize, "guest");
        this.DataList1.DataSource = ds;
        this.DataList1.DataKeyField = "ST_RoomId";
        this.DataList1.DataBind();



        if (this.CurrentPage == (this.PageCount - 1))////判断上下页按钮是否有效
        {
            this.lblNext.Enabled = false;
        }
        if (this.CurrentPage == 0)
        {
            this.lblPre.Enabled = false;
        }



        for (int i = 0; i < this.DataList1.Items.Count; i++)
        {
            DataRow dr = ds.Tables[0].Rows[i];
            if (dr["ST_Status"].ToString() == "2")
            {
                ((Label)this.DataList1.Items[i].FindControl("lblIsNull")).Text = "否";
                Status = "否";
            }
            else if(dr["ST_Status"].ToString()=="1")
            {
                ((Label)this.DataList1.Items[i].FindControl("lblIsNull")).Text = "有";
                Status = "有";
            }
        }

 
    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Detail")
        {
            int RoomId =int.Parse(this.DataList1.DataKeys[e.Item.ItemIndex].ToString());
            Response.Redirect("RoomDetail.aspx?RoomId=" + RoomId);
           
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SQLExe.SQLExe myExe = new SQLExe.SQLExe();
        DataSet ds = new DataSet();
        string str="";
        if (this.ddlCategory.SelectedItem.ToString() != "--请选择--" && this.ddlState.SelectedItem.ToString() != "--请选择--")
        {
            if (this.ddlState.SelectedItem.ToString()== "未订")
            {
                str = "select * from RoomStatusView where ST_RCategoryId=" + System.Convert.ToInt32(this.ddlCategory.SelectedValue) + " and ST_Status='2'";
            }
            else if (this.ddlState.SelectedItem.ToString() == "已订")
            {
                str = "select * from RoomStatusView where ST_RCategoryId=" + System.Convert.ToInt32(this.ddlCategory.SelectedValue) + " and ST_Status='1'";
 
            }
            
          
            
        }
        else if (this.ddlCategory.SelectedItem.ToString() != "--请选择--")
        {
            str = "select * from RoomStatusView where ST_RCategoryId=" + System.Convert.ToInt32(this.ddlCategory.SelectedValue) + "";
        }

        else if (this.ddlState.SelectedItem.ToString() != "--请选择--")
        {
            if (this.ddlState.SelectedItem.ToString() == "未订")
            {
                str = "select * from RoomStatusView where ST_Status='2'";
            }
            else if (this.ddlState.SelectedItem.ToString() == "已订")
            {
                str = "select * from RoomStatusView where ST_Status='1'";
            }
        }
        else if (this.ddlCategory.SelectedItem.ToString() == "--请选择--" && this.ddlState.SelectedItem.ToString() == "--请选择--")
        {
            str="select * from RoomStatusView";
        }



        this.CurrentPage = 0;//////当前页
        ViewState["PageIndex"] = 0;
        ViewState["str"] = str;
        this.RecordCount = RetrunCount(ViewState["str"].ToString());//得到总记录数

        if (this.RecordCount % this.PageSize == 0)
        {
            this.PageCount = this.RecordCount / this.PageSize;
        }
        else
        {
            this.PageCount = this.RecordCount / this.PageSize;
            this.PageCount++;

        }

        ViewState["PageCount"] = this.PageCount;



        Shoe_RoomList(str);
     
    }
    protected void lblNext_Click(object sender, EventArgs e) /////下页
    {
        this.CurrentPage = (int)ViewState["PageIndex"];
        this.PageCount = (int)ViewState["PageCount"];

        if (this.CurrentPage < (this.PageCount - 1))
        {
            this.CurrentPage++;
        }
        ViewState["PageIndex"] = this.CurrentPage;
        Shoe_RoomList(ViewState["str"].ToString());
    }
    protected void lblPre_Click(object sender, EventArgs e)////上页
    {
        this.CurrentPage = (int)ViewState["PageIndex"];
        this.PageCount = (int)ViewState["PageCount"];

        if (this.CurrentPage > 0)
        {
            this.CurrentPage--;
        }
        ViewState["PageIndex"] = this.CurrentPage;
        Shoe_RoomList(ViewState["str"].ToString());
    }
}

⌨️ 快捷键说明

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