📄 eatingform.aspx.vb
字号:
'文件名:EatingForm.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class ConsumeManage_EatingForm
Inherits System.Web.UI.Page
Private Shared MyEatingTable 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("B1") > 1) Then
Server.Transfer("~/SystemManage/AllErrorHelp.aspx")
End If
If (Not IsPostBack) Then
'创建无连接的数据表
Dim MyKey(1) As DataColumn
MyEatingTable = New System.Data.DataTable("餐费入账")
Dim MyColumn As New System.Data.DataColumn()
MyColumn.DataType = System.Type.GetType("System.Int16")
MyColumn.ColumnName = "自编号"
MyEatingTable.Columns.Add(MyColumn)
MyKey(0) = MyColumn
MyEatingTable.PrimaryKey = MyKey
MyEatingTable.Columns.Add("入住编号", System.Type.GetType("System.String"))
MyEatingTable.Columns.Add("餐费编号", System.Type.GetType("System.String"))
MyEatingTable.Columns.Add("用餐时间", System.Type.GetType("System.DateTime"))
MyEatingTable.Columns.Add("类别", System.Type.GetType("System.String"))
MyEatingTable.Columns.Add("金额", System.Type.GetType("System.Double"))
MyEatingTable.Columns.Add("说明", System.Type.GetType("System.String"))
MyEatingTable.Columns.Add("记账时间", System.Type.GetType("System.DateTime"))
MyEatingTable.Columns.Add("操作人员", System.Type.GetType("System.String"))
Me.TextBox1.Text = DateTime.Now.ToShortDateString()
End If
Me.Page.Title = "当前位置:消费管理->旅客餐费登记"
Me.GridView1.DataSource = MyEatingTable
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()
MyEatingTable.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 = MyEatingTable.NewRow()
MyRow(0) = MyID
MyRow("入住编号") = Me.DropDownList2.SelectedValue.ToString()
MyRow("餐费编号") = Me.TextBox4.Text
MyRow("用餐时间") = Me.TextBox1.Text
MyRow("类别") = Me.DropDownList3.SelectedValue.ToString()
MyRow("金额") = Me.TextBox2.Text
MyRow("说明") = Me.TextBox3.Text
MyRow("记账时间") = Me.TextBox6.Text
MyRow("操作人员") = Me.TextBox5.Text
MyEatingTable.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(MyEatingTable)
MyEatingTable.Rows.Clear()
If (MyConnection.State = ConnectionState.Open) Then
MyConnection.Close()
End If
Button5_Click(Nothing, Nothing)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'打印旅客餐费信息
Server.Transfer("~/ConsumeManage/EatingPrint.aspx")
End Sub
'设置要传递到打印页的数据表
Public ReadOnly Property MyTable() As System.Data.DataTable
Get
Return MyEatingTable
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 + -