?? st_rcatgmanmodule.ascx.cs
字號(hào):
namespace ST_GROUP.Modules
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
/// <summary>
/// ST_RCategoryModule 的摘要說(shuō)明。
/// </summary>
public partial class ST_RCategoryModule : ST_ModuleBase
{
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack) Show_RCategoryList();
}
protected void Show_RCategoryList()
{
//從文件Web.config中讀取連接字符串
string ST_sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//連接ST_GinShopManage數(shù)據(jù)庫(kù)
SqlConnection ST_Conn = new SqlConnection (ST_sqldb);
//定義sql語(yǔ)句
String ST_selsql="select ST_RCategoryId,ST_Name,ST_BedNum,ST_Price from ST_RoomCategory";
//創(chuàng)建SqlDataAdapter對(duì)象,調(diào)用ST_selsql
SqlDataAdapter ST_myadapter = new SqlDataAdapter (ST_selsql,ST_Conn);
//創(chuàng)建并填充DataSet
DataSet ds = new DataSet ();
ST_myadapter.Fill (ds);
dg_RCategoryList.DataSource =ds;
dg_RCategoryList.DataBind ();
//關(guān)閉ST_Conn
ST_Conn.Close ();
}
protected void DataGrid_Delete(Object sender,DataGridCommandEventArgs E)
{
//從文件Web.config中讀取連接字符串
string ST_sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//連接ST_GinShopManage數(shù)據(jù)庫(kù)
SqlConnection ST_Conn = new SqlConnection (ST_sqldb);
ST_Conn.Open ();
//定義sql語(yǔ)句
String delsql="delete from ST_RoomCategory where ST_RCategoryId = @RCategoryId";
//創(chuàng)建ST_mycommand對(duì)象,調(diào)用delsql
SqlCommand ST_mycommand = new SqlCommand (delsql,ST_Conn);
ST_mycommand.Parameters .Add ("@RCategoryId",SqlDbType.VarChar );
//從dg_RCategoryList中獲取RCategoryId值
ST_mycommand.Parameters ["@RCategoryId"].Value =E.Item.Cells [0].Text .ToString ();
ST_mycommand.ExecuteNonQuery ();
dg_RCategoryList.EditItemIndex =-1;
//更新dg_RCategoryList
Show_RCategoryList();
}
protected void DataGrid_Page(Object sender,DataGridPageChangedEventArgs E)
{
dg_RCategoryList.CurrentPageIndex =E.NewPageIndex ;
Show_RCategoryList();
}
#region Web 窗體設(shè)計(jì)器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.search.Click += new System.EventHandler(this.btn_search_Click);
this.ShowAll.Click += new System.EventHandler(this.ShowAll_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ShowAll_Click(object sender, System.EventArgs e)
{
Show_RCategoryList();
}
private void btn_search_Click(object sender, System.EventArgs e)
{
//從文件Web.config中讀取連接字符串
string ST_sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//連接ST_GinShopManage數(shù)據(jù)庫(kù)
SqlConnection ST_Conn = new SqlConnection (ST_sqldb);
//定義sql語(yǔ)句
String ST_selsql="select ST_RCategoryId,ST_Name,ST_BedNum,ST_Price from ST_RoomCategory where ST_Name = @Name";
//創(chuàng)建SqlDataAdapter對(duì)象,調(diào)用ST_selsql
SqlDataAdapter ST_myadapter = new SqlDataAdapter (ST_selsql,ST_Conn);
ST_myadapter.SelectCommand.Parameters .Add ("@Name",SqlDbType.VarChar );
ST_myadapter.SelectCommand.Parameters ["@Name"].Value =RNameTextBox.Text.Trim();
//創(chuàng)建并填充DataSet
DataSet ds = new DataSet ();
ST_myadapter.Fill (ds);
dg_RCategoryList.DataSource =ds;
dg_RCategoryList.DataBind ();
ST_Conn.Close ();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -