?? bookroom.aspx.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 BookRoom : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.lblRoomId.Text = Request.QueryString["RoomId"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
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_InsertCustomer";
ST_mycommand.Parameters.Add("@RoomId", SqlDbType.Int);
ST_mycommand.Parameters.Add("@Name", SqlDbType.VarChar, 50);
ST_mycommand.Parameters.Add("@CID", SqlDbType.VarChar, 50);
ST_mycommand.Parameters.Add("@Telephone", SqlDbType.VarChar, 50);
ST_mycommand.Parameters.Add("@Address", SqlDbType.VarChar, 50);
ST_mycommand.Parameters["@RoomId"].Value = int.Parse(this.lblRoomId.Text);
ST_mycommand.Parameters["@Name"].Value = this.txtName.Text.ToString();
ST_mycommand.Parameters["@CID"].Value = this.txtCID.Text.ToString();
ST_mycommand.Parameters["@Telephone"].Value = this.txtTelephone.Text.ToString();
ST_mycommand.Parameters["@Address"].Value = this.txtAddress.Text.ToString();
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 + -