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

📄 st_roomedit.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_RoomEdit : System.Web.UI.UserControl
{
    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.txtCategory.Items.Add(li);
            }
            dl.Close();
            ST_myCon.Close();
            SetDataBind();
        }
    }
    public void SetDataBind()
    {
        this.lblRoomId.Text = Request.QueryString["RoomId"].ToString();
        int RoomId = int.Parse(this.lblRoomId.Text);
        SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
        SqlCommand ST_mycommand = new SqlCommand();
        ST_mycommand.Connection = ST_myCon;
        ST_mycommand.CommandText = "select * from RoomsInfoView where ST_RoomId=" + RoomId + "";
        ST_myCon.Open();
        SqlDataReader dl = ST_mycommand.ExecuteReader();
        if (dl.Read())
        {
           
            this.txtCategory.Items.FindByText(dl["ST_Name"].ToString()).Selected = true;
            this.txtPosition.Text = dl["ST_RPosition"].ToString();
            this.txtDesc.Text = dl["ST_Description"].ToString();
        }
        dl.Close();
        ST_myCon.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      //  Response.Write(this.txtCategory.SelectedValue);
         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_UpdateRoom";
         ST_mycommand.Parameters.Add("@RoomId", SqlDbType.Int);
         ST_mycommand.Parameters.Add("@RCategoryId", SqlDbType.Int);
         ST_mycommand.Parameters.Add("@RPosition", SqlDbType.VarChar, 50);
         ST_mycommand.Parameters.Add("@Description", SqlDbType.VarChar, 50);

         ST_mycommand.Parameters["@RoomId"].Value = System.Convert.ToInt32(int.Parse(this.lblRoomId.Text.ToString()));
         ST_mycommand.Parameters["@RCategoryId"].Value =this.txtCategory.SelectedValue;
         ST_mycommand.Parameters["@RPosition"].Value = this.txtPosition.Text;
         ST_mycommand.Parameters["@Description"].Value = this.txtDesc.Text;

         try
         {
             ST_myCon.Open();
             ST_mycommand.ExecuteNonQuery();
             this.lblInfo.Text = "修改成功";
         }
         catch (SqlException exx)
         {
             this.lblInfo.Text = "修改失败:" + exx.Message;

         }
         finally
         {
             ST_myCon.Close();
         }

    }
}

⌨️ 快捷键说明

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