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

📄 checkoutform.aspx.cs

📁 一个关于宾馆酒店管理系统的源代码
💻 CS
字号:
//文件名:CheckOutForm.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 RoomManage_CheckOutForm : System.Web.UI.Page
{
    private static string My入住编号;
    private static double My店内消费 = 0;
    private static double My电话费 = 0;
    private static double My用餐费 = 0;
    private static double My住宿费 = 0;
    private static double My费用总额 = 0;
    private static string My结账编号 = "";
    private static DateTime My入住日期;
    private static DateTime My结账日期;
    private static int My住宿人数 = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("A3") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        if (!IsPostBack)
        {
            this.Page.Title = "当前位置:客房管理->旅客结账退房";
            this.TextBox9.Text = DateTime.Now.Year.ToString();
            this.TextBox10.Text = DateTime.Now.Month.ToString();
            this.TextBox11.Text = DateTime.Now.Day.ToString();
            this.Button3.OnClientClick = "return confirm('请检查旅客离店结账信息是否正确,一旦保存就无法修改,是否继续?')";
        }
        this.Page.Title = "当前位置:客房管理->旅客结账退房";
        this.Button3.OnClientClick = "return confirm('请检查旅客离店结账信息是否正确,一旦保存就无法修改,是否继续?')";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//查询旅客的费用信息   
        My结账编号 = System.Guid.NewGuid().ToString().ToUpper();
        My店内消费 = 0;
        My电话费 = 0;
        My用餐费 = 0;
        My住宿费 = 0;
        My费用总额 = 0;
        this.TextBox5.Text = "";
        this.TextBox3.Text = "";
        this.TextBox4.Text = "";
        this.TextBox1.Text = "";
        this.TextBox2.Text = "";
        this.TextBox7.Text = "";
        this.TextBox6.Text = "";
        My入住编号 = this.DropDownList2.SelectedValue.ToString();
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MySQL = "Select SUM(预收押金) From 客房入住单 Where 入住编号='" + My入住编号 + "'";
        SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
        this.TextBox5.Text = MyCommand.ExecuteScalar().ToString();

        MySQL = "Select SUM(金额) From 话费入账 Where 入住编号='" + My入住编号 + "'";
        MyCommand = new SqlCommand(MySQL, MyConnection);
        this.TextBox3.Text = MyCommand.ExecuteScalar().ToString();

        MySQL = "Select SUM(金额) From 餐费入账 Where 入住编号='" + My入住编号 + "'";
        MyCommand = new SqlCommand(MySQL, MyConnection);
        this.TextBox4.Text = MyCommand.ExecuteScalar().ToString();

        MySQL = "Select SUM(消费数量*折扣价格) From 消费入账 Where 入住编号='" + My入住编号 + "'";
        MyCommand = new SqlCommand(MySQL, MyConnection);
        this.TextBox1.Text = MyCommand.ExecuteScalar().ToString();

        MySQL = "Select 折扣价格,入住日期,住宿人数 From 客房入住单 Where 入住编号='" + My入住编号 + "'";
        DataTable MyNewTable = new DataTable();
        SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
        MyAdapter.Fill(MyNewTable);
        string My折扣价格 = MyNewTable.Rows[0][0].ToString();
        My入住日期 = (DateTime)MyNewTable.Rows[0][1];
        My结账日期 = new DateTime(Convert.ToInt16(this.TextBox9.Text),
            Convert.ToInt16(this.TextBox10.Text), Convert.ToInt16(this.TextBox11.Text));
        TimeSpan MySpan = My结账日期.Subtract(My入住日期);
        My住宿人数 = Convert.ToInt16(MyNewTable.Rows[0][2].ToString());
        My住宿费 = Convert.ToDouble(My折扣价格) * Math.Round(MySpan.TotalDays, 0) * My住宿人数;
        this.TextBox2.Text = My住宿费.ToString();

        if (this.TextBox1.Text.Length > 1)
            My店内消费 = Convert.ToDouble(this.TextBox1.Text);
        if (this.TextBox3.Text.Length > 1)
            My电话费 = Convert.ToDouble(this.TextBox3.Text);
        if (this.TextBox4.Text.Length > 1)
            My用餐费 = Convert.ToDouble(this.TextBox4.Text);
        My费用总额 = My住宿费 + My电话费 + My用餐费 + My店内消费;
        this.TextBox6.Text = My费用总额.ToString();
        double My补交押金 = My费用总额 - Convert.ToDouble(this.TextBox5.Text);
        this.TextBox7.Text = My补交押金.ToString();

        MySQL = "Select 入住编号,证件名称,证件号码,入住日期,离开日期 From 客房入住单 Where 入住编号='" + My入住编号 + "'";
        DataTable MyGuestTable = new DataTable();
        SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
        MyDataAdapter.Fill(MyGuestTable);
        this.GridView1.DataSource = MyGuestTable;
        this.GridView1.DataBind();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
    public String MyPrint入住编号
    {//设置要传递到打印页的数据
        get
        {
            return My入住编号;
        }
    }
    public String MyPrint入住房号
    {//设置要传递到打印页的数据
        get
        {
            return this.DropDownList1.SelectedValue.ToString();
        }
    }
    public String MyPrint客人姓名
    {//设置要传递到打印页的数据
        get
        {
            return this.DropDownList2.SelectedItem.Text.ToString();
        }
    }
    public String MyPrint店内消费
    {//设置要传递到打印页的数据
        get
        {
            return My店内消费.ToString();
        }
    }
    public String MyPrint住宿费
    {//设置要传递到打印页的数据
        get
        {
            return My住宿费.ToString();
        }
    }
    public String MyPrint电话费
    {//设置要传递到打印页的数据
        get
        {
            return My电话费.ToString();
        }
    }
    public String MyPrint用餐费
    {//设置要传递到打印页的数据
        get
        {
            return My用餐费.ToString();
        }
    }
    public String MyPrint预收押金
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox5.Text;
        }
    }
    public String MyPrint结账金额
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox7.Text;
        }
    }
    public String MyPrint结账编号
    {//设置要传递到打印页的数据
        get
        {
            return My结账编号;
        }
    }
    public String MyPrint结账日期
    {//设置要传递到打印页的数据
        get
        {
            return My结账日期.ToShortDateString();
        }
    }
    public String MyPrint入住日期
    {//设置要传递到打印页的数据
        get
        {
            return My入住日期.ToShortDateString();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//打印旅客离店结账信息
        Server.Transfer("~/RoomManage/CheckOutPrint.aspx");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {//保存旅客离店结账信息
        if (Session["MyUserName"] == null)
            return;
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MySQL = "Select Count(*) From 客房结账单 Where 入住编号='" + My入住编号 + "'";
        SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
        int MyCount = (int)MyCommand.ExecuteScalar();
        if (MyCount > 0)
        {
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
            return;
        }
        MySQL = "INSERT INTO [客房结账单] ([入住编号],[结账编号], [入住房号], [客人姓名], [入住日期], [结账日期], [店内消费], [住宿费], [电话费], [用餐费], [预收押金], [结账金额], [操作人员],[说明]) VALUES (@入住编号,@结账编号, @入住房号, @客人姓名, @入住日期, @结账日期, @店内消费, @住宿费, @电话费, @用餐费, @预收押金, @结账金额, @操作人员,@说明)";
        MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = MySQL;
        MyCommand.Parameters.Add(new SqlParameter("@入住编号", SqlDbType.VarChar));
        MyCommand.Parameters.Add(new SqlParameter("@结账编号", SqlDbType.VarChar));
        MyCommand.Parameters.Add(new SqlParameter("@入住房号", SqlDbType.VarChar));
        MyCommand.Parameters.Add(new SqlParameter("@客人姓名", SqlDbType.VarChar));
        MyCommand.Parameters.Add(new SqlParameter("@入住日期", SqlDbType.DateTime));
        MyCommand.Parameters.Add(new SqlParameter("@结账日期", SqlDbType.DateTime));
        MyCommand.Parameters.Add(new SqlParameter("@店内消费", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@住宿费", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@电话费", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@用餐费", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@预收押金", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@结账金额", SqlDbType.Float));
        MyCommand.Parameters.Add(new SqlParameter("@操作人员", SqlDbType.VarChar));
        MyCommand.Parameters.Add(new SqlParameter("@说明", SqlDbType.VarChar));

        MyCommand.Parameters["@入住编号"].Value = My入住编号;
        MyCommand.Parameters["@结账编号"].Value = My结账编号;
        MyCommand.Parameters["@入住房号"].Value = this.DropDownList1.SelectedValue.ToString();
        MyCommand.Parameters["@客人姓名"].Value = this.DropDownList2.SelectedItem.Text;
        MyCommand.Parameters["@入住日期"].Value = My入住日期;
        MyCommand.Parameters["@结账日期"].Value = My结账日期;
        MyCommand.Parameters["@店内消费"].Value = My店内消费;
        MyCommand.Parameters["@住宿费"].Value = My住宿费;
        MyCommand.Parameters["@电话费"].Value = My电话费;
        MyCommand.Parameters["@用餐费"].Value = My用餐费;
        MyCommand.Parameters["@预收押金"].Value = this.TextBox5.Text;
        MyCommand.Parameters["@结账金额"].Value = this.TextBox7.Text;
        MyCommand.Parameters["@操作人员"].Value = Session["MyUserName"].ToString();
        MyCommand.Parameters["@说明"].Value = this.TextBox8.Text;

        MyCommand.ExecuteNonQuery();
        MySQL = "Update 酒店房间 Set 已住人数=已住人数-" + My住宿人数.ToString() + " WHERE 房号='" + this.DropDownList1.SelectedValue.ToString() + "'";
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.DropDownList1.DataBind();
        this.Button1_Click(null, null);
    }
}

⌨️ 快捷键说明

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