?? returnroom.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 ReturnRoom : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.lblRoomId.Text = Request.QueryString["RoomId"].ToString();
SetDataBind();
}
}
public void SetDataBind()
{
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 ST_BookID,ST_RoomId,ST_BeginTime,ST_Price from ReturnBookView where ST_RoomId=" + RoomId + " and ST_IsBook='已訂'";
ST_myCon.Open();
SqlDataReader dl = ST_mycommand.ExecuteReader();
if (dl.Read())
{
ViewState["BookRoomId"] = dl["ST_BookID"];
DateTime begintime = System.Convert.ToDateTime(dl["ST_BeginTime"]);
this.lblBeginTime.Text = dl["ST_BeginTime"].ToString();
this.lblEndTime.Text = DateTime.Now.ToString();
this.lblPrice.Text = dl["ST_Price"].ToString();
this.lblCount.Text = System.Convert.ToString((DateTime.Now-begintime).Days);
this.lblMoney.Text = System.Convert.ToString(int.Parse(this.lblCount.Text) * System.Convert.ToDouble(this.lblPrice.Text));
}
dl.Close();
ST_myCon.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
int BookRoomId = System.Convert.ToInt32(ViewState["BookRoomId"]);
string str = BookRoomId.ToString();
Response.Write(str);
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_UpdateReturnRoom";
ST_mycommand.Parameters.Add("@BookId", SqlDbType.Int);
ST_mycommand.Parameters.Add("@EndTime", SqlDbType.DateTime);
ST_mycommand.Parameters.Add("@Price", SqlDbType.Money);
ST_mycommand.Parameters.Add("@RoomId", SqlDbType.Int);
ST_mycommand.Parameters["@BookId"].Value = BookRoomId;
ST_mycommand.Parameters["@EndTime"].Value = System.Convert.ToDateTime(this.lblEndTime.Text);
ST_mycommand.Parameters["@Price"].Value = System.Convert.ToDouble(this.lblMoney.Text);
ST_mycommand.Parameters["@RoomId"].Value = int.Parse(this.lblRoomId.Text);
try
{
ST_myCon.Open();
ST_mycommand.ExecuteNonQuery();
this.lblInfo.Text = "退房成功";
}
catch (SqlException exx)
{
this.lblInfo.Text = "出錯(cuò):" + exx.Message;
}
finally
{
ST_myCon.Close();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -