📄 zsdj.vb
字号:
'查找可用房间
con.Close()
con.Open()
Dim com2 As SqlCommand
Dim dr As SqlDataReader
Dim sql2 As String = "select 房间ID from 房间信息 where 房间状态 = '空闲 'and 房间属性= '" + ComboBox4.Text + "'"
com2 = New SqlCommand(sql2, con)
dr = com2.ExecuteReader
If dr.Read Then '判断房间是否可用
TextBox4.Text = dr(0) '取出找到的房间号码
con.Close()
con.Open()
Dim sql As String = "insert into 客户信息 values('" + TextBox1.Text + "','" + TextBox4.Text + "','" + ComboBox1.Text + "','" + TextBox3.Text + "','" + TextBox2.Text _
+ "','" + ComboBox2.Text + "','" + ComboBox3.Text + "','" + TextBox5.Text + "','" + ComboBox4.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + _
TextBox11.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + ComboBox5.Text + "','" + TextBox8.Text + "')"
com = New SqlCommand(sql, con)
com.ExecuteNonQuery()
Dim com3 As SqlCommand
Dim sql3 As String = "update 房间信息 set 房间状态='使用' where 房间ID='" + state + "'"
com3 = New SqlCommand(sql3, con)
com3.ExecuteNonQuery()
Dim i As Int32 = com3.ExecuteNonQuery()
If i > 0 Then
MsgBox("欢迎光临,登记成功!")
'将预定的房间删除
If ComboBox1.Text = "是" Then
Try
Dim sql6 As String = "delete 房间预定 where 预定码=" + Trim(TextBox3.Text)
com = New SqlCommand(sql6, con)
Dim ii As Int32 = com.ExecuteNonQuery()
If ii > 0 Then
MsgBox("已成功将预定激活!")
con.Close()
Else
con.Close()
MsgBox("对房间预定表更新发生错误,表未更新!")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End If
con.Close()
con.Open()
'查找编号记录
Dim sql4 As String = "select * from 编号记录"
Dim com4 As New SqlCommand
Dim dr4 As SqlDataReader
com4 = New SqlCommand(sql4, con)
dr4 = com4.ExecuteReader()
'修改编号记录
Dim sql5 As String = "update 编号记录 set PK=dr4(0)+1,GK=dr4(1)+1,预定记录码=dr4(2)+1"
Dim com5 As New SqlCommand
com5 = New SqlCommand(sql5, con)
com5.ExecuteNonQuery()
Exit Sub
Else
MsgBox("登记有误,请检查信息!")
Exit Sub
End If
Else
con.Close()
MsgBox("您所要的房间已售完,请选择其它属性的房间!")
Exit Sub
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
Dim pktext, gktext As Integer
Try
con.Close()
con.Open()
Dim com1 As SqlCommand
Dim dr1 As SqlDataReader
Dim sql As String = "select PK,GK from 编号记录"
com1 = New SqlCommand(sql, con)
dr1 = com1.ExecuteReader
If dr1.Read Then
pktext = dr1(0)
gktext = dr1(1)
End If
If ComboBox4.Text = "贵宾单间" Or ComboBox4.Text = "贵宾双间" Then
'用于生成客户ID=客户类型+月份+日期+客户编码
If Now().Month > 10 Then
If Now.Day > 10 Then
Select Case Len(CStr(gktext))
Case Is = 1
TextBox1.Text = "GK" & Now().Month & Now().Day & "000" & CStr(gktext + 1)
Case Is = 2
TextBox1.Text = "GK" & Now().Month & Now().Day & "00" & CStr(gktext + 1)
Case Is = 3
TextBox1.Text = "GK" & Now().Month & Now().Day & "0" & CStr(gktext + 1)
Case Is = 4
TextBox1.Text = "GK" & Now().Month & Now().Day & CStr(gktext + 1)
End Select
Else
Select Case Len(CStr(gktext))
Case Is = 1
TextBox1.Text = "GK" & Now().Month & "0" & Now().Day & "000" & CStr(gktext + 1)
Case Is = 2
TextBox1.Text = "GK" & Now().Month & "0" & Now().Day & "00" & CStr(gktext + 1)
Case Is = 3
TextBox1.Text = "GK" & Now().Month & "0" & Now().Day & "0" & CStr(gktext + 1)
Case Is = 4
TextBox1.Text = "GK" & Now().Month & "0" & Now().Day & CStr(gktext + 1)
End Select
End If
Else
If Now.Day > 10 Then
Select Case Len(CStr(gktext))
Case Is = 1
TextBox1.Text = "GK" & "0" & Now().Month & Now().Day & "000" & CStr(gktext + 1)
Case Is = 2
TextBox1.Text = "GK" & "0" & Now().Month & Now().Day & "00" & CStr(gktext + 1)
Case Is = 3
TextBox1.Text = "GK" & "0" & Now().Month & Now().Day & "0" & CStr(gktext + 1)
Case Is = 4
TextBox1.Text = "GK" & "0" & Now().Month & Now().Day & CStr(gktext + 1)
End Select
Else
Select Case Len(CStr(gktext))
Case Is = 1
TextBox1.Text = "GK" & "0" & Now().Month & "0" & Now().Day & "000" & CStr(gktext + 1)
Case Is = 2
TextBox1.Text = "GK" & "0" & Now().Month & "0" & Now().Day & "00" & CStr(gktext + 1)
Case Is = 3
TextBox1.Text = "GK" & "0" & Now().Month & "0" & Now().Day & "0" & CStr(gktext + 1)
Case Is = 4
TextBox1.Text = "GK" & "0" & Now().Month & "0" & Now().Day & CStr(gktext + 1)
End Select
End If
End If
Else
If Now().Month > 10 Then
If Now.Day > 10 Then
Select Case Len(CStr(pktext))
Case Is = 1
TextBox1.Text = "PK" & Now().Month & Now().Day & "000" & CStr(pktext + 1)
Case Is = 2
TextBox1.Text = "PK" & Now().Month & Now().Day & "00" & CStr(pktext + 1)
Case Is = 3
TextBox1.Text = "PK" & Now().Month & Now().Day & "0" & CStr(pktext + 1)
Case Is = 4
TextBox1.Text = "PK" & Now().Month & Now().Day & CStr(pktext + 1)
End Select
Else
Select Case Len(CStr(pktext))
Case Is = 1
TextBox1.Text = "PK" & Now().Month & "0" & Now().Day & "000" & CStr(pktext + 1)
Case Is = 2
TextBox1.Text = "PK" & Now().Month & "0" & Now().Day & "00" & CStr(pktext + 1)
Case Is = 3
TextBox1.Text = "PK" & Now().Month & "0" & Now().Day & "0" & CStr(pktext + 1)
Case Is = 4
TextBox1.Text = "PK" & Now().Month & "0" & Now().Day & CStr(pktext + 1)
End Select
End If
Else
If Now.Day > 10 Then
Select Case Len(CStr(pktext))
Case Is = 1
TextBox1.Text = "PK" & "0" & Now().Month & Now().Day & "000" & CStr(pktext + 1)
Case Is = 2
TextBox1.Text = "PK" & "0" & Now().Month & Now().Day & "00" & CStr(pktext + 1)
Case Is = 3
TextBox1.Text = "PK" & "0" & Now().Month & Now().Day & "0" & CStr(pktext + 1)
Case Is = 4
TextBox1.Text = "PK" & "0" & Now().Month & Now().Day & CStr(pktext + 1)
End Select
Else
Select Case Len(CStr(pktext))
Case Is = 1
TextBox1.Text = "PK" & "0" & Now().Month & "0" & Now().Day & "000" & CStr(pktext + 1)
Case Is = 2
TextBox1.Text = "PK" & "0" & Now().Month & "0" & Now().Day & "00" & CStr(pktext + 1)
Case Is = 3
TextBox1.Text = "PK" & "0" & Now().Month & "0" & Now().Day & "0" & CStr(pktext + 1)
Case Is = 4
TextBox1.Text = "PK" & "0" & Now().Month & "0" & Now().Day & CStr(pktext + 1)
End Select
End If
End If
End If
con.Close()
'查找可用房间
If ComboBox1.Text = "是" Then '判断是否为预定客户
con.Close()
con.Open()
Dim com2 As SqlCommand
Dim dr2 As SqlDataReader
Dim sql2 As String = "select * from 房间预定 where 预定码='" + TextBox3.Text + "'"
com2 = New SqlCommand(sql2, con)
dr2 = com2.ExecuteReader()
If dr2.Read Then
con.Close()
con.Open()
Dim com3 As SqlCommand
Dim sql3 As String = "update 房间信息 set 房间状态='使用' where 房间ID='" + TextBox4.Text + "'"
com3 = New SqlCommand(sql3, con)
com3.ExecuteNonQuery()
End If
Else
con.Close()
con.Open()
Dim com3 As SqlCommand
Dim dr3 As SqlDataReader
Dim sql1 As String = "select 房间ID from 房间信息 where 房间状态 = '空闲 'and 房间属性= '" + ComboBox4.Text + "'"
com3 = New SqlCommand(sql1, con)
dr3 = com3.ExecuteReader
If dr3.Read Then '判断房间是否可用
TextBox4.Text = dr3(0) '取出找到的房间号码
state = dr3(0)
Else
con.Close()
MsgBox("您所要的房间已售完,请选择其它属性的房间!")
Exit Sub
End If
End If
Catch ex As Exception
con.Close()
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
'用于单击后选定文本内容
Private Sub TextBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Click, TextBox5.Click, TextBox9.Click, TextBox10.Click, TextBox11.Click, TextBox3.Click
Select Case sender.tabindex
Case 0
TextBox2.SelectAll()
Case 4
TextBox5.SelectAll()
Case 6
TextBox9.SelectAll()
Case 7
TextBox10.SelectAll()
Case 8
TextBox11.SelectAll()
Case 23
TextBox3.SelectAll()
End Select
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Trim(ComboBox1.Text) = "是" Then
TextBox3.ReadOnly = False
TextBox3.Text = ""
Else
TextBox3.ReadOnly = True
TextBox3.Text = "否"
End If
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
'用于查找已预定客户的信息
Dim con As New SqlConnection(constr)
Dim com5 As SqlCommand
Dim dr5 As SqlDataReader
Try
If Len(Trim(TextBox3.Text)) = 10 Then
con.Close()
con.Open()
Dim sql As String = "select 客户ID,姓名,性别,预定房间,房间属性 from 房间预定 where 预定码='" + Trim(TextBox3.Text) + "'"
com5 = New SqlCommand(sql, con)
dr5 = com5.ExecuteReader
If dr5.Read Then
TextBox1.Text = dr5(0)
TextBox2.Text = dr5(1)
ComboBox2.Text = dr5(2)
TextBox4.Text = dr5(3)
ComboBox4.Text = dr5(4)
Else
MsgBox("对不起您尚未预定房间,或者预定码有错!")
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
Try
TextBox6.Text = Now.Today
TextBox7.Text = DateAdd(DateInterval.Day, CDec(Trim(TextBox9.Text)), Now.Today)
Catch ex As Exception
End Try
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
TextBox8.Text = Mid(TextBox4.Text, 3, 3) + "楼" + Mid(TextBox4.Text, 8, 3) + "房"
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -