📄 checkoutform.aspx.vb
字号:
'文件名:CheckOutForm.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class RoomManage_CheckOutForm
Inherits System.Web.UI.Page
Private Shared My入住编号 As String = ""
Private Shared My店内消费 As Double = 0
Private Shared My电话费 As Double = 0
Private Shared My用餐费 As Double = 0
Private Shared My住宿费 As Double = 0
Private Shared My费用总额 As Double = 0
Private Shared My结账编号 As String = ""
Private Shared My入住日期 As DateTime
Private Shared My结账日期 As DateTime
Private Shared My住宿人数 As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim MyForbidString As String = Session("MyForbid").ToString()
If (MyForbidString.IndexOf("A3") > 1) Then
Server.Transfer("~/SystemManage/AllErrorHelp.aspx")
End If
If (Not IsPostBack) Then
Me.Page.Title = "当前位置:客房管理->旅客结账退房"
Me.TextBox9.Text = DateTime.Now.Year.ToString()
Me.TextBox10.Text = DateTime.Now.Month.ToString()
Me.TextBox11.Text = DateTime.Now.Day.ToString()
Me.Button3.OnClientClick = "return confirm('请检查旅客离店结账信息是否正确,一旦保存就无法修改,是否继续?')"
End If
Me.Page.Title = "当前位置:客房管理->旅客结账退房"
Me.Button3.OnClientClick = "return confirm('请检查旅客离店结账信息是否正确,一旦保存就无法修改,是否继续?')"
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'查询旅客的费用信息
My结账编号 = System.Guid.NewGuid().ToString().ToUpper()
My店内消费 = 0
My电话费 = 0
My用餐费 = 0
My住宿费 = 0
My费用总额 = 0
Me.TextBox5.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox7.Text = ""
Me.TextBox6.Text = ""
My入住编号 = Me.DropDownList2.SelectedValue.ToString()
Dim MySQLConnectionString As String = ConfigurationManager.ConnectionStrings("MyHotelDBConnectionString").ConnectionString
Dim MyConnection As New SqlConnection(MySQLConnectionString)
MyConnection.Open()
Dim MySQL As String = "Select SUM(预收押金) From 客房入住单 Where 入住编号='" + My入住编号 + "'"
Dim MyCommand As New SqlCommand(MySQL, MyConnection)
Me.TextBox5.Text = MyCommand.ExecuteScalar().ToString()
MySQL = "Select SUM(金额) From 话费入账 Where 入住编号='" + My入住编号 + "'"
MyCommand = New SqlCommand(MySQL, MyConnection)
Me.TextBox3.Text = MyCommand.ExecuteScalar().ToString()
MySQL = "Select SUM(金额) From 餐费入账 Where 入住编号='" + My入住编号 + "'"
MyCommand = New SqlCommand(MySQL, MyConnection)
Me.TextBox4.Text = MyCommand.ExecuteScalar().ToString()
MySQL = "Select SUM(消费数量*折扣价格) From 消费入账 Where 入住编号='" + My入住编号 + "'"
MyCommand = New SqlCommand(MySQL, MyConnection)
Me.TextBox1.Text = MyCommand.ExecuteScalar().ToString()
MySQL = "Select 折扣价格,入住日期,住宿人数 From 客房入住单 Where 入住编号='" + My入住编号 + "'"
Dim MyNewTable As New DataTable()
Dim MyAdapter As New SqlDataAdapter(MySQL, MyConnection)
MyAdapter.Fill(MyNewTable)
Dim My折扣价格 As String = MyNewTable.Rows(0)(0).ToString()
My入住日期 = MyNewTable.Rows(0)(1)
My结账日期 = New DateTime(Convert.ToInt16(Me.TextBox9.Text), Convert.ToInt16(Me.TextBox10.Text), Convert.ToInt16(Me.TextBox11.Text))
Dim MySpan As TimeSpan = My结账日期.Subtract(My入住日期)
My住宿人数 = Convert.ToInt16(MyNewTable.Rows(0)(2).ToString())
My住宿费 = Convert.ToDouble(My折扣价格) * Math.Round(MySpan.TotalDays, 0) * My住宿人数
Me.TextBox2.Text = My住宿费.ToString()
If (Me.TextBox1.Text.Length > 1) Then
My店内消费 = Convert.ToDouble(Me.TextBox1.Text)
End If
If (Me.TextBox3.Text.Length > 1) Then
My电话费 = Convert.ToDouble(Me.TextBox3.Text)
End If
If (Me.TextBox4.Text.Length > 1) Then
My用餐费 = Convert.ToDouble(Me.TextBox4.Text)
End If
My费用总额 = My住宿费 + My电话费 + My用餐费 + My店内消费
Me.TextBox6.Text = My费用总额.ToString()
Dim My补交押金 As Double = My费用总额 - Convert.ToDouble(Me.TextBox5.Text)
Me.TextBox7.Text = My补交押金.ToString()
MySQL = "Select 入住编号,证件名称,证件号码,入住日期,离开日期 From 客房入住单 Where 入住编号='" + My入住编号 + "'"
Dim MyGuestTable As New DataTable()
Dim MyDataAdapter As New SqlDataAdapter(MySQL, MyConnection)
MyDataAdapter.Fill(MyGuestTable)
Me.GridView1.DataSource = MyGuestTable
Me.GridView1.DataBind()
If (MyConnection.State = ConnectionState.Open) Then
MyConnection.Close()
End If
End Sub
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint入住编号() As String
Get
Return My入住编号
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint入住房号() As String
Get
Return Me.DropDownList1.SelectedValue.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint客人姓名() As String
Get
Return Me.DropDownList2.SelectedItem.Text.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint店内消费() As String
Get
Return My店内消费.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint住宿费() As String
Get
Return My住宿费.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint电话费() As String
Get
Return My电话费.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint用餐费() As String
Get
Return My用餐费.ToString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint预收押金() As String
Get
Return Me.TextBox5.Text
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint结账金额() As String
Get
Return Me.TextBox7.Text
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint结账编号() As String
Get
Return My结账编号
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint结账日期() As String
Get
Return My结账日期.ToShortDateString()
End Get
End Property
'设置要传递到打印页的数据
Public ReadOnly Property MyPrint入住日期() As String
Get
Return My入住日期.ToShortDateString()
End Get
End Property
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'打印旅客离店结账信息
Server.Transfer("~/RoomManage/CheckOutPrint.aspx")
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
'保存旅客离店结账信息
If (Session("MyUserName") Is Nothing) Then
Return
End If
Dim MySQLConnectionString As String = ConfigurationManager.ConnectionStrings("MyHotelDBConnectionString").ConnectionString
Dim MyConnection As New SqlConnection(MySQLConnectionString)
MyConnection.Open()
Dim MySQL As String = "Select Count(*) From 客房结账单 Where 入住编号='" + My入住编号 + "'"
Dim MyCommand As New SqlCommand(MySQL, MyConnection)
Dim MyCount As Integer = MyCommand.ExecuteScalar()
If (MyCount > 0) Then
If (MyConnection.State = ConnectionState.Open) Then
MyConnection.Close()
End If
Return
End If
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 = Me.DropDownList1.SelectedValue.ToString()
MyCommand.Parameters("@客人姓名").Value = Me.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 = Convert.ToDouble(Me.TextBox5.Text)
MyCommand.Parameters("@结账金额").Value = Convert.ToDouble(Me.TextBox7.Text)
MyCommand.Parameters("@操作人员").Value = Session("MyUserName").ToString()
MyCommand.Parameters("@说明").Value = Me.TextBox8.Text
MyCommand.ExecuteNonQuery()
MySQL = "Update 酒店房间 Set 已住人数=已住人数-" + My住宿人数.ToString() + " WHERE 房号='" + Me.DropDownList1.SelectedValue.ToString() + "'"
MyCommand.CommandText = MySQL
MyCommand.ExecuteNonQuery()
If (MyConnection.State = ConnectionState.Open) Then
MyConnection.Close()
End If
Me.DropDownList1.DataBind()
Me.Button1_Click(Nothing, Nothing)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -