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

📄 st_roomsmanmodule.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_RoomsManModule : ST_ModuleBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Show_RoomList();
        }
    }
    protected void Show_RoomList()
    {
        DataSet ds = new DataSet();
        SQLExe.SQLExe myExe = new SQLExe.SQLExe();
        string str = "select * from RoomsInfoView";
        ds = myExe.GetDataSet(str);
        this.DataGrid1.DataSource = ds.Tables[0].DefaultView;
        this.DataGrid1.DataBind();
 
    }
    protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "Detail")
        {
           
            Response.Redirect("ST_RoomsEdit.aspx?RoomId="+e.Item.Cells[0].Text.ToString()); //传递房间编号
        }
        if (e.CommandName == "Detele")
        {
            SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            SqlCommand ST_mycommand = new SqlCommand();
            ST_mycommand.Connection = ST_myCon;
            ST_mycommand.CommandType = CommandType.StoredProcedure;
            ST_mycommand.CommandText = "ST_DeleteRoom";
            ST_mycommand.Parameters.Add("@RoomId", SqlDbType.Int);
            ST_mycommand.Parameters["@RoomId"].Value=int.Parse(e.Item.Cells[0].Text);
            try
            {
                ST_myCon.Open();
                ST_mycommand.ExecuteNonQuery();
                Show_RoomList();
                
            }
            catch (SqlException exx)
            {
                throw (exx);
            }
            finally
            {
                ST_myCon.Close();
            }
            
 
        }
    }
    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
        Show_RoomList();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
        SqlCommand ST_mycommand = new SqlCommand();
        SqlDataAdapter ST_myadapter = new SqlDataAdapter();
        DataSet ds = new DataSet();
        ST_mycommand.Connection = ST_myCon;
        ST_mycommand.CommandText = "select * from RoomsInfoView where ST_RoomId=@RoomId";

        ST_mycommand.Parameters.Add("@RoomId", SqlDbType.Int);
       ST_mycommand.Parameters["@RoomId"].Value = int.Parse(this.txtSearch.Text);
        try
        {
            ST_myCon.Open();
            ST_mycommand.ExecuteNonQuery();
            ST_myadapter.SelectCommand = ST_mycommand;
            ST_myadapter.Fill(ds);
            this.DataGrid1.DataSource = ds.Tables[0].DefaultView;
            this.DataGrid1.DataBind();
           
        }
       catch (SqlException exx)
        {
            throw (exx);
        }
        finally
        {
            ST_myCon.Close();
        }
    }
}

⌨️ 快捷键说明

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