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

📄 returnroom.aspx.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 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 = "出错:" + exx.Message;
        }
        finally
        {
            ST_myCon.Close();
 
        }





    }
}

⌨️ 快捷键说明

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