📄 tsjz.vb
字号:
Imports System.Data.SqlClient
Public Class tsjz
Inherits System.Windows.Forms.Form
Dim constr As String = "server=.;database=RoomManager;integrated security=true"
Dim con As New SqlConnection(constr)
Dim com As SqlCommand
Dim dr As SqlDataReader
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.Label8 = New System.Windows.Forms.Label
Me.Label9 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.Panel1.SuspendLayout()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.SystemColors.AppWorkspace
Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.ComboBox1)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(48, 32)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(384, 56)
Me.Panel1.TabIndex = 0
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox1.Location = New System.Drawing.Point(208, 16)
Me.TextBox1.MaxLength = 10
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(336, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(32, 23)
Me.Button1.TabIndex = 2
Me.Button1.Text = "GO"
'
'ComboBox1
'
Me.ComboBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.ComboBox1.Items.AddRange(New Object() {"ID", "姓名", "房间ID"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 16)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(80, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "房间ID"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 23)
Me.Label1.TabIndex = 2
Me.Label1.Text = "检索类别"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(392, 240)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 2
Me.Button2.Text = "退 出"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(288, 240)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 1
Me.Button3.Text = "确 定"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label2.Location = New System.Drawing.Point(48, 112)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 23)
Me.Label2.TabIndex = 6
Me.Label2.Text = "客户ID"
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox2.Location = New System.Drawing.Point(120, 112)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.ReadOnly = True
Me.TextBox2.Size = New System.Drawing.Size(80, 23)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label3.Location = New System.Drawing.Point(48, 144)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 23)
Me.Label3.TabIndex = 8
Me.Label3.Text = "房间ID"
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox3.Location = New System.Drawing.Point(120, 144)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.ReadOnly = True
Me.TextBox3.Size = New System.Drawing.Size(80, 23)
Me.TextBox3.TabIndex = 4
Me.TextBox3.Text = ""
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label4.Location = New System.Drawing.Point(48, 176)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(56, 23)
Me.Label4.TabIndex = 10
Me.Label4.Text = "姓名"
'
'TextBox4
'
Me.TextBox4.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox4.Location = New System.Drawing.Point(120, 176)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.ReadOnly = True
Me.TextBox4.Size = New System.Drawing.Size(80, 23)
Me.TextBox4.TabIndex = 5
Me.TextBox4.Text = ""
'
'Label5
'
Me.Label5.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label5.Location = New System.Drawing.Point(48, 208)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(56, 23)
Me.Label5.TabIndex = 12
Me.Label5.Text = "宿费"
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label6.Location = New System.Drawing.Point(48, 240)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(56, 23)
Me.Label6.TabIndex = 13
Me.Label6.Text = "押金"
'
'TextBox5
'
Me.TextBox5.Font = New System.Drawing.Font("宋体", 10.0!, System.Drawing.FontStyle.Bold)
Me.TextBox5.Location = New System.Drawing.Point(120, 208)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.ReadOnly = True
Me.TextBox5.TabIndex = 6
Me.TextBox5.Text = ""
Me.TextBox5.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'TextBox6
'
Me.TextBox6.Font = New System.Drawing.Font("宋体", 10.0!, System.Drawing.FontStyle.Bold)
Me.TextBox6.Location = New System.Drawing.Point(120, 240)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.ReadOnly = True
Me.TextBox6.TabIndex = 7
Me.TextBox6.Text = ""
Me.TextBox6.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Label8
'
Me.Label8.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold)
Me.Label8.Location = New System.Drawing.Point(96, 40)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(64, 23)
Me.Label8.TabIndex = 17
Me.Label8.Text = "0.00"
Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label9
'
Me.Label9.Font = New System.Drawing.Font("Verdana", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label9.Location = New System.Drawing.Point(16, 40)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(80, 23)
Me.Label9.TabIndex = 18
Me.Label9.Text = "RMB:"
Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.SystemColors.Control
Me.GroupBox1.Controls.Add(Me.Label8)
Me.GroupBox1.Controls.Add(Me.Label9)
Me.GroupBox1.Font = New System.Drawing.Font("楷体_GB2312", 16.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox1.Location = New System.Drawing.Point(264, 128)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(184, 88)
Me.GroupBox1.TabIndex = 19
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "找 零"
'
'tsjz
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(488, 294)
Me.ControlBox = False
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Panel1)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "tsjz"
Me.Text = "退宿结账"
Me.Panel1.ResumeLayout(False)
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con.Open()
Dim sql As String = "select ID,房间ID,姓名,住宿金额,押金,可用状态 from 客户信息 where " + Trim(ComboBox1.Text) + "='" + Trim(TextBox1.Text) + "'"
com = New SqlCommand(sql, con)
dr = com.ExecuteReader
If dr.Read Then
If dr(5) = "退房" Then
MsgBox("该顾客已退房!")
Exit Sub
End If
TextBox2.Text = dr(0)
TextBox3.Text = dr(1)
TextBox4.Text = dr(2)
TextBox5.Text = dr(3)
TextBox6.Text = dr(4)
Label8.Text = dr(4) - dr(3)
Else
MsgBox("未找到相关信息!")
Exit Sub
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
TextBox1.SelectAll()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
con.Open()
Dim sql As String = "update 客户信息 set 退房时间='" + Now.Today + "'," + "可用状态='退房'" + " where " + Trim(ComboBox1.Text) + "='" + Trim(TextBox1.Text) + "'"
com = New SqlCommand(sql, con)
Dim i As Int32 = com.ExecuteNonQuery()
If i > 0 Then
con.Close()
con.Open()
MsgBox("退房成功,谢谢您的光临!")
Dim sql1 As String = "update 房间信息 set 房间状态='空闲' where 房间ID=" + Trim(TextBox3.Text) + ""
MsgBox(sql1)
Dim com2 As SqlCommand
com2 = New SqlCommand(sql1, con)
Dim ii As Int32 = com.ExecuteNonQuery
If ii > 0 Then
MsgBox("对房间信息已更新!")
Exit Sub
Else
MsgBox("对房间信息更新有误,此房间还在使用中!")
con.Close()
Exit Sub
End If
Else
con.Close()
MsgBox("退房不成功,请检查!")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -