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

📄 frombooktoregisterform.aspx.cs

📁 一个关于宾馆酒店管理系统的源代码
💻 CS
字号:
//文件名:FromBookToRegisterForm.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_FromBookToRegisterForm : System.Web.UI.Page
{
    public static string My预约编号="";
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("A5") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        this.Page.Title = "当前位置:客房管理->预订旅客入住";
        if (Session["MyUserName"] != null)
        {//设置操作用户
            this.TextBox14.Text = Session["MyUserName"].ToString();
        }
        this.Button2.OnClientClick = "return confirm('请检查旅客登记信息是否正确,一旦保存就无法修改,是否继续?')";
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {   //设置入住编号
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = "Select max(入住编号) 最大编号 From 客房入住单";
        object MyResult = MyCommand.ExecuteScalar();
        Int64 MyID = 1;
        if (MyResult != System.DBNull.Value)
        {
            String MyMaxID = MyResult.ToString().Trim();
            MyMaxID = MyMaxID.Substring(2, MyMaxID.Length - 2);
            MyID = Convert.ToInt64(MyMaxID) + 1;
        }
        int MyLength = MyID.ToString().Length;
        string MyNewID = "";
        switch (MyLength)
        {
            case 1:
                MyNewID = "RZ0000000" + MyID.ToString();
                break;
            case 2:
                MyNewID = "RZ000000" + MyID.ToString();
                break;
            case 3:
                MyNewID = "RZ00000" + MyID.ToString();
                break;
            case 4:
                MyNewID = "RZ0000" + MyID.ToString();
                break;
            case 5:
                MyNewID = "RZ000" + MyID.ToString();
                break;
            case 6:
                MyNewID = "RZ00" + MyID.ToString();
                break;
            case 7:
                MyNewID = "RZ0" + MyID.ToString();
                break;
        }
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.TextBox1.Text = MyNewID;
        My预约编号 = this.GridView1.SelectedRow.Cells[1].Text.ToString();
        this.TextBox2.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString();
        this.TextBox4.Text = this.GridView1.SelectedRow.Cells[3].Text.ToString();
        this.TextBox5.Text = this.GridView1.SelectedRow.Cells[4].Text.ToString();
        this.TextBox6.Text = this.GridView1.SelectedRow.Cells[5].Text.ToString();
        this.TextBox7.Text = this.GridView1.SelectedRow.Cells[6].Text.ToString();
        this.TextBox13.Text = this.GridView1.SelectedRow.Cells[9].Text.ToString();
        this.TextBox15.Text = this.GridView1.SelectedRow.Cells[11].Text.ToString();
        this.TextBox8.Text = this.GridView1.SelectedRow.Cells[7].Text.ToString();
        this.TextBox11.Text = this.GridView1.SelectedRow.Cells[8].Text.ToString();        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//保存入住旅客登记信息
        if (this.TextBox14.Text.Length > 1)
        {
            //向客房入住单数据表增加记录
            this.SqlDataSource2.Insert();
            String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString;
            string MySQL = "Update 客房预约单 Set 入住编号='" + this.TextBox1.Text + "' WHERE 自编号='" + My预约编号 + "'";
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            SqlCommand MyCommand = MyConnection.CreateCommand();
            MyCommand.CommandText = MySQL;
            MyCommand.ExecuteNonQuery();
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
            this.GridView1.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//打印入住旅客登记信息
        HttpCookie My入住编号 = new HttpCookie("My入住编号");
        My入住编号.Value = this.TextBox1.Text;
        Response.Cookies.Add(My入住编号);
        HttpCookie My入住房号 = new HttpCookie("My入住房号");
        My入住房号.Value = this.TextBox2.Text;
        Response.Cookies.Add(My入住房号);
        HttpCookie My折扣价格 = new HttpCookie("My折扣价格");
        My折扣价格.Value = this.TextBox3.Text;
        Response.Cookies.Add(My折扣价格);
        HttpCookie My预收押金 = new HttpCookie("My预收押金");
        My预收押金.Value = this.TextBox4.Text;
        Response.Cookies.Add(My预收押金);
        HttpCookie My入住日期 = new HttpCookie("My入住日期");
        My入住日期.Value = DateTime.Parse(TextBox5.Text).ToShortDateString();
        Response.Cookies.Add(My入住日期);
        HttpCookie My离开日期 = new HttpCookie("My离开日期");
        My离开日期.Value = DateTime.Parse(TextBox6.Text).ToShortDateString();
        Response.Cookies.Add(My离开日期);
        HttpCookie My客人姓名 = new HttpCookie("My客人姓名");
        My客人姓名.Value = this.TextBox7.Text;
        Response.Cookies.Add(My客人姓名);
        HttpCookie My证件名称 = new HttpCookie("My证件名称");
        My证件名称.Value = this.DropDownList2.SelectedValue.ToString();
        Response.Cookies.Add(My证件名称);
        HttpCookie My证件号码 = new HttpCookie("My证件号码");
        My证件号码.Value = this.TextBox9.Text;
        Response.Cookies.Add(My证件号码);
        HttpCookie My证件地址 = new HttpCookie("My证件地址");
        My证件地址.Value = this.TextBox10.Text;
        Response.Cookies.Add(My证件地址);
        HttpCookie My住宿人数 = new HttpCookie("My住宿人数");
        My住宿人数.Value = this.TextBox8.Text;
        Response.Cookies.Add(My住宿人数);
        HttpCookie My客人性别 = new HttpCookie("My客人性别");
        My客人性别.Value = this.TextBox11.Text;
        Response.Cookies.Add(My客人性别);
        HttpCookie My联系电话 = new HttpCookie("My联系电话");
        My联系电话.Value = this.TextBox13.Text;
        Response.Cookies.Add(My联系电话);
        HttpCookie My操作人员 = new HttpCookie("My操作人员");
        My操作人员.Value = this.TextBox14.Text;
        Response.Cookies.Add(My操作人员);
        HttpCookie My登记说明 = new HttpCookie("My登记说明");
        My登记说明.Value = this.TextBox15.Text;
        Response.Cookies.Add(My登记说明);
        Server.Transfer("~/RoomManage/RegisterPrint.aspx");
    }
}

⌨️ 快捷键说明

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