Files
Desktop_BLVStudio/BLV_Studio/FrmChangeHotel.vb
2025-12-11 10:06:44 +08:00

401 lines
14 KiB
VB.net
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Public Class FrmChangeHotel
Private _defalut As Boolean
''' <summary>
''' 客户索引
''' </summary>
''' <returns></returns>
Public Property VerderIndex As String
''' <summary>
''' 客户名称
''' </summary>
''' <returns></returns>
Public Property VerderName As String
''' <summary>
''' 客户索引
''' </summary>
''' <returns></returns>
Public Property HotelIndex As String
''' <summary>
''' 酒店四位数字代号在TBL_HOTEL_BASIC_INFO 数据表中对应 “PROJECT_NUMBER”字段
''' </summary>
''' <returns></returns>
Public Property HotelCode As String
''' <summary>
''' 酒店名称
''' </summary>
''' <returns></returns>
Public Property HotelName As String
''' <summary>
''' 账号权限
''' </summary>
''' <returns></returns>
Public Property AccountAuth As AccountAuth
''' <summary>
''' 酒店个数
''' </summary>
Private _count As Integer = 0
''' <summary>
''' 酒店信息列表
''' </summary>
Private g_Hotel_List As New List(Of Struc_HotelList) '当选定酒店组以后将该酒店组下的酒店信息保存在这个list中
''' <summary>
''' 当前选中的tree view节点信息
''' </summary>
Private g_Current_Selected_TreeView_Node As Struc_TreeView_NodeInfo
''' <summary>当前选择的酒店组</summary>
Private _selectGroup As HotelGroup
'treeview信息
Public Structure Struc_TreeView_NodeInfo
Public Node_Level As Integer
Public Node_Idx As Integer
Public Node_Text As String
Public Node_BackColor As Color
End Structure
'酒店信息
Public Structure Struc_HotelList
Public HotelId As String
Public HotelCode As String
Public HotelName As String
Public HotelGroupsId As String
Public HotelGroupsName As String
End Structure
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
VerderName = lab_CurrentHotelGroup.Text
If String.IsNullOrEmpty(VerderName) Then
MsgBox("酒店组无效")
GoTo lab_ErrHandle
End If
If String.IsNullOrEmpty(HotelCode) Then
MsgBox("HotelCode无效")
GoTo lab_ErrHandle
End If
If String.IsNullOrEmpty(HotelName) Then
MsgBox("酒店名称无效")
GoTo lab_ErrHandle
End If
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
Return
lab_ErrHandle:
VerderName = ""
HotelCode = ""
HotelName = ""
Return
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub FrmChangeHotel_Load(sender As Object, e As EventArgs) Handles Me.Load
Text = $"{Application.ProductName} {Application.ProductVersion}"
If String.IsNullOrEmpty(VerderIndex) OrElse String.IsNullOrEmpty(HotelIndex) Then
_defalut = False
Else
_defalut = True
End If
'查询所有厂商
tv_GroupList.Nodes.Clear()
tv_GroupList.Nodes.Add("所有酒店")
tv_GroupList.Nodes(0).ForeColor = Color.Blue
tv_GroupList.Nodes(0).NodeFont = New Font("幼圆", 12, FontStyle.Bold)
tv_GroupList.Nodes(0).ImageIndex = 2
Dim node As TreeNode = tv_GroupList.Nodes(0)
Dim tmpReslut As Boolean = False
For Each group As HotelGroup In AccountAuth.HotelData
'遍历所有酒店组将酒店组添加到tree view控件中
node.Nodes.Add(group.HotelGroupsName)
If _defalut AndAlso group.HotelGroupsId = VerderIndex Then
'匹配酒店组默认值
tmpReslut = MatchHotelGroup(group.HotelGroupsName, g_Current_Selected_TreeView_Node)
If tmpReslut = True Then
lab_CurrentHotelGroup.Text = group.HotelGroupsName
'匹配酒店默认值’
tmpReslut = MatchHotelName(HotelName)
If tmpReslut = True Then
lab_CurrentHotel.Text = HotelName
Else
lab_CurrentHotel.Text = ""
End If
Else
lab_CurrentHotelGroup.Text = ""
End If
End If
Next
tv_GroupList.ExpandAll()
_defalut = False
End Sub
'Private Sub CboVendor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboVendor.SelectedIndexChanged
' If CboVendor.SelectedIndex = -1 Then Return
' For Each group As HotelGroup In AccountAuth.HotelData
' If group.HotelGroupsName <> CboVendor.Text Then Continue For
' _selectGroup = group
' CboHotel.Items.Clear()
' For Each hotel As Hotel In group.Hotels
' CboHotel.Items.Add(hotel.HotelName)
' If _defalut AndAlso hotel.HotelId = HotelIndex Then CboHotel.SelectedIndex = CboHotel.Items.Count - 1
' Next
' If _defalut = False AndAlso CboHotel.Items.Count > 0 Then CboHotel.SelectedIndex = 0
' 'If CboHotel.Items.Count > 0 Then CboHotel.SelectedIndex = 0
' VerderIndex = group.HotelGroupsId
' VerderName = group.HotelGroupsName
' Exit For
' Next
'End Sub
'Private Sub CboHotel_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboHotel.SelectedIndexChanged
' If CboHotel.SelectedIndex = -1 Then Return
' If _selectGroup Is Nothing Then Return
' For Each hotel As Hotel In _selectGroup.Hotels
' If hotel.HotelName <> CboHotel.Text Then Continue For
' HotelIndex = hotel.HotelId
' HotelName = hotel.HotelName
' Exit For
' Next
'End Sub
Private Sub tv_GroupList_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles tv_GroupList.AfterSelect
Dim tmpHotelInfo As Struc_HotelList
Dim tmpStrSelectGroupName As String = e.Node.Text
Dim node As TreeNode = tv_GroupList.Nodes(0)
For Each node In node.Nodes
tv_GroupList.Nodes(0).BackColor = Color.White
tv_GroupList.Nodes(0).ForeColor = Color.Black
node.BackColor = Color.White
node.ForeColor = Color.Black
Next
e.Node.BackColor = Color.CornflowerBlue
e.Node.ForeColor = Color.White
'清空列表
g_Hotel_List.Clear()
For Each group As HotelGroup In AccountAuth.HotelData
If tv_GroupList.SelectedNode.Text = "所有酒店" Then
For Each hotel As Hotel In group.Hotels
tmpHotelInfo.HotelId = hotel.HotelId
tmpHotelInfo.HotelCode = hotel.Code
tmpHotelInfo.HotelName = hotel.HotelName
tmpHotelInfo.HotelGroupsId = group.HotelGroupsId
tmpHotelInfo.HotelGroupsName = group.HotelGroupsName
g_Hotel_List.Add(tmpHotelInfo)
Next
' Return '如果选中根节点,则退出
'todo选中“所有酒店”则将所有的酒店都列在数据表中
Else
If group.HotelGroupsName <> tmpStrSelectGroupName Then Continue For '未匹配到节点
_selectGroup = group
'Console.WriteLine($"group.Hotels================={group.Hotels.Count }")
lab_CurrentHotelGroup.Text = tmpStrSelectGroupName
For Each hotel As Hotel In group.Hotels
tmpHotelInfo.HotelId = hotel.HotelId
tmpHotelInfo.HotelCode = hotel.Code
tmpHotelInfo.HotelName = hotel.HotelName
tmpHotelInfo.HotelGroupsId = group.HotelGroupsId
tmpHotelInfo.HotelGroupsName = group.HotelGroupsName
g_Hotel_List.Add(tmpHotelInfo)
Next
VerderIndex = group.HotelGroupsId
VerderName = group.HotelGroupsName
HotelName = ""
lab_CurrentHotel.Text = HotelName
Exit For
End If
Next
Update_Grid(g_Hotel_List)
End Sub
#Region "酒店选择 "
Private Function MatchHotelName(ByVal HotelHotelName As String) As Boolean
For i = 1 To grd_HolteList.Rows - 1
If grd_HolteList.Cell(i, 3).Text = HotelHotelName Then
grd_HolteList.Range(i, 1, i, 3).BackColor = Color.LightCyan
Return True
End If
Next
HotelName = ""
Return False
End Function
Private Function MatchHotelGroup(ByVal GroupName As String, ByRef SelectedTreeNode As Struc_TreeView_NodeInfo) As Boolean
Dim node As TreeNode = tv_GroupList.Nodes(0)
Dim tmpHotelInfo As Struc_HotelList
'遍历一级子节点
For Each node In node.Nodes
'匹配到组名
If node.Text = GroupName Then
SelectedTreeNode.Node_Level = 0
SelectedTreeNode.Node_Idx = node.Index
SelectedTreeNode.Node_Text = GroupName
SelectedTreeNode.Node_BackColor = Color.CornflowerBlue
node.BackColor = Color.CornflowerBlue
'列出所有酒店
'清空列表
g_Hotel_List.Clear()
For Each group As HotelGroup In AccountAuth.HotelData
If group.HotelGroupsName <> GroupName Then Continue For '未匹配到节点
_selectGroup = group
For Each hotel As Hotel In group.Hotels
tmpHotelInfo.HotelCode = hotel.Code
tmpHotelInfo.HotelName = hotel.HotelName
tmpHotelInfo.HotelId = hotel.HotelId
tmpHotelInfo.HotelGroupsId = group.HotelGroupsId
tmpHotelInfo.HotelGroupsName = group.HotelGroupsName
g_Hotel_List.Add(tmpHotelInfo)
Next
VerderIndex = group.HotelGroupsId
VerderName = group.HotelGroupsName
Update_Grid(g_Hotel_List)
Exit For
Next
Return True
End If
Next
Return False
End Function
Private Sub Update_Grid(HotelInfoList As List(Of Struc_HotelList))
grd_HolteList.AutoRedraw = False
With grd_HolteList
.Rows = HotelInfoList.Count + 1
.Cols = 4
.DefaultRowHeight = 20
.Column(1).Width = 60
.Column(2).Width = 60
.Column(3).Width = 210
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
.Column(2).Alignment = FlexCell.AlignmentEnum.LeftCenter
.Font = New Font("Arial", 10, FontStyle.Bold)
.AllowUserResizing = FlexCell.ResizeEnum.None
.ExtendLastCol = True
End With
grd_HolteList.Cell(0, 1).Text = "ID"
grd_HolteList.Cell(0, 2).Text = "Code"
grd_HolteList.Cell(0, 3).Text = "酒店名称"
grd_HolteList.Cell(0, 2).Alignment = FlexCell.AlignmentEnum.CenterCenter
For i = 1 To HotelInfoList.Count
grd_HolteList.Range(i, 1, i, 3).BackColor = Color.White
grd_HolteList.Cell(i, 0).Text = i
grd_HolteList.Cell(i, 1).Text = HotelInfoList(i - 1).HotelId
grd_HolteList.Cell(i, 2).Text = HotelInfoList(i - 1).HotelCode
grd_HolteList.Cell(i, 3).Text = HotelInfoList(i - 1).HotelName
grd_HolteList.Cell(i, 2).Tag = HotelInfoList(i - 1).HotelGroupsId
grd_HolteList.Cell(i, 3).Tag = HotelInfoList(i - 1).HotelGroupsName
Next
grd_HolteList.Refresh()
grd_HolteList.AutoRedraw = True
End Sub
Private Sub grd_HolteList_MouseClick(sender As Object, e As MouseEventArgs) Handles grd_HolteList.MouseClick
grd_HolteList.AutoRedraw = False
grd_HolteList.Range(1, 1, grd_HolteList.Rows - 1, 3).BackColor = Color.White
grd_HolteList.Range(grd_HolteList.ActiveCell.Row, 1, grd_HolteList.ActiveCell.Row, 3).BackColor = Color.LightCyan
grd_HolteList.Refresh()
grd_HolteList.AutoRedraw = True
lab_CurrentHotel.Text = grd_HolteList.Cell(grd_HolteList.ActiveCell.Row, 3).Text
HotelName = lab_CurrentHotel.Text
HotelCode = grd_HolteList.Cell(grd_HolteList.ActiveCell.Row, 2).Text
HotelIndex = grd_HolteList.Cell(grd_HolteList.ActiveCell.Row, 1).Text
VerderIndex = grd_HolteList.Cell(grd_HolteList.ActiveCell.Row, 2).Tag
VerderName = grd_HolteList.Cell(grd_HolteList.ActiveCell.Row, 3).Tag
lab_CurrentHotelGroup.Text = VerderName
'tmpHotelInfo.HotelGroupsId = group.HotelGroupsId
'tmpHotelInfo.HotelGroupsName = group.HotelGroupsName
'HotelName = ""
'lab_CurrentHotel.Text = HotelName
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If IsNothing(grd_HolteList) AndAlso grd_HolteList.Rows < 1 AndAlso String.IsNullOrEmptyTextBox1.Text.Trim Then Return
Dim tabstr As String
For index As Integer = 1 To grd_HolteList.Rows - 1
tabstr = grd_HolteList.Cell(index, 2).Text.Trim & grd_HolteList.Cell(index, 3).Text.Trim
If tabstr.Contains(TextBox1.Text.Trim) Then
grd_HolteList.Row(index).Position = 1
End If
Next
End Sub
#End Region
End Class