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

📄 consumeform.aspx.vb

📁 旅客信息管理、酒店客房管理、各种信息查询
💻 VB
字号:
'文件名:ConsumeForm.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class ConsumeManage_ConsumeForm
    Inherits System.Web.UI.Page
    Private Shared MyConsumeTable As New DataTable()
    Private Shared MyID 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("B3") > 1) Then
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx")
        End If
        If (Not IsPostBack) Then
            '创建无连接的数据表
            Dim MyKey(1) As DataColumn
            MyConsumeTable = New DataTable("消费入账")
            Dim MyColumn As New DataColumn()
            MyColumn.DataType = System.Type.GetType("System.Int16")
            MyColumn.ColumnName = "自编号"
            MyConsumeTable.Columns.Add(MyColumn)
            MyKey(0) = MyColumn
            MyConsumeTable.PrimaryKey = MyKey
            MyConsumeTable.Columns.Add("入住编号", System.Type.GetType("System.String"))
            MyConsumeTable.Columns.Add("消费编号", System.Type.GetType("System.String"))
            MyConsumeTable.Columns.Add("商品名称", System.Type.GetType("System.String"))
            MyConsumeTable.Columns.Add("消费数量", System.Type.GetType("System.Int16"))
            MyConsumeTable.Columns.Add("折扣价格", System.Type.GetType("System.Double"))
            MyConsumeTable.Columns.Add("说明", System.Type.GetType("System.String"))
            MyConsumeTable.Columns.Add("记账时间", System.Type.GetType("System.DateTime"))
            MyConsumeTable.Columns.Add("操作人员", System.Type.GetType("System.String"))
            Me.TextBox1.Text = "1"
        End If
        Me.Page.Title = "当前位置:消费管理->其他消费登记"
        Me.GridView1.DataSource = MyConsumeTable
        Me.Button3.OnClientClick = "return confirm('请检查旅客消费信息是否正确,一旦保存就无法修改,是否继续?')"
    End Sub
    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        '随机生成消费编号
        Me.TextBox4.Text = System.Guid.NewGuid().ToString().ToUpper()
        Me.TextBox5.Text = Session("MyUserName").ToString()
        Me.TextBox6.Text = DateTime.Now.ToShortDateString()
        MyConsumeTable.Rows.Clear()
        Me.GridView1.DataBind()
        MyID = 0
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        '向临时数据表中新增消费信息
        MyID = MyID + 1
        Dim MyRow As DataRow = MyConsumeTable.NewRow()
        MyRow(0) = MyID
        MyRow("入住编号") = Me.DropDownList2.SelectedValue.ToString()
        MyRow("消费编号") = Me.TextBox4.Text
        MyRow("商品名称") = Me.DropDownList3.SelectedValue.ToString()
        MyRow("消费数量") = Me.TextBox1.Text
        MyRow("折扣价格") = Me.TextBox2.Text
        MyRow("说明") = Me.TextBox3.Text
        MyRow("记账时间") = Me.TextBox6.Text
        MyRow("操作人员") = Me.TextBox5.Text
        MyConsumeTable.Rows.Add(MyRow)
        Me.GridView1.DataBind()
    End Sub
    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        '保存旅客消费信息
        Dim MySQLConnectionString As String = ConfigurationManager.ConnectionStrings("MyHotelDBConnectionString").ConnectionString
        Dim MyConnection As New SqlConnection(MySQLConnectionString)
        MyConnection.Open()
        Dim MyBulkCopy As New SqlBulkCopy(MyConnection)
        MyBulkCopy.DestinationTableName = "消费入账"
        MyBulkCopy.WriteToServer(MyConsumeTable)
        MyConsumeTable.Rows.Clear()
        If (MyConnection.State = ConnectionState.Open) Then
            MyConnection.Close()
        End If
        Button5_Click(Nothing, Nothing)
    End Sub
    Protected Sub DropDownList3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList3.SelectedIndexChanged
        Dim MySQLConnectionString As String = ConfigurationManager.ConnectionStrings("MyHotelDBConnectionString").ConnectionString
        Dim MyConnection As New SqlConnection(MySQLConnectionString)
        MyConnection.Open()
        Dim MySQL As String = "Select 单价 From 消费商品 Where 名称='" + Me.DropDownList3.SelectedValue.ToString() + "'"
        Dim MyCommand As New SqlCommand(MySQL, MyConnection)
        Me.TextBox2.Text = MyCommand.ExecuteScalar().ToString()
        If (MyConnection.State = ConnectionState.Open) Then
            MyConnection.Close()
        End If
    End Sub
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        '打印旅客消费信息
        Server.Transfer("~/ConsumeManage/ConsumePrint.aspx")
    End Sub
    '设置要传递到打印页的数据表
    Public ReadOnly Property MyTable() As System.Data.DataTable
        Get
            Return MyConsumeTable
        End Get
    End Property
    '设置要传递到打印页的入住房号
    Public ReadOnly Property My入住房号() As String
        Get
            Return Me.DropDownList1.SelectedValue.ToString()
        End Get
    End Property
    '设置要传递到打印页的客人姓名
    Public ReadOnly Property My客人姓名() As String
        Get
            Return Me.DropDownList2.SelectedItem.Text
        End Get
    End Property
End Class

⌨️ 快捷键说明

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