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

📄 roomandtablecontrol.vb

📁 单机版餐饮服务系统,结合了SqlServer数据库
💻 VB
字号:
Imports System
Imports System.IO
Imports System.Data
Imports System.Drawing
Imports System.Collections

Namespace HZC.DinningService

    Public Class RoomAndTableControl
        Inherits System.Windows.Forms.UserControl

#Region " Windows 窗体设计器生成的代码 "

        Public Sub New()
            MyBase.New()

            '该调用是 Windows 窗体设计器所必需的。
            InitializeComponent()
            Dim m_path As String = Application.StartupPath & "\"
            If m_RoomOrTable.Count > 0 Then
            Else
                m_RoomOrTable.Add(UseStatus.修缮中, New Icon(m_path & "Repairing.ico"))
                m_RoomOrTable.Add(UseStatus.已空闲, New Icon(m_path & "CanUseing.ico"))
                m_RoomOrTable.Add(UseStatus.已预定, New Icon(m_path & "IsOrdered.ico"))
                m_RoomOrTable.Add(UseStatus.进餐中, New Icon(m_path & "InUseing.ico"))
            End If

            '在 InitializeComponent() 调用之后添加任何初始化

        End Sub

        'UserControl 重写 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 lbTitle As System.Windows.Forms.Label
        Friend WithEvents lbStatus As System.Windows.Forms.Label
        Friend WithEvents UserControlTip As System.Windows.Forms.ToolTip
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.components = New System.ComponentModel.Container
            Me.lbTitle = New System.Windows.Forms.Label
            Me.lbStatus = New System.Windows.Forms.Label
            Me.UserControlTip = New System.Windows.Forms.ToolTip(Me.components)
            Me.SuspendLayout()
            '
            'lbTitle
            '
            Me.lbTitle.BackColor = System.Drawing.Color.Cornsilk
            Me.lbTitle.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
            Me.lbTitle.Dock = System.Windows.Forms.DockStyle.Bottom
            Me.lbTitle.ForeColor = System.Drawing.Color.Navy
            Me.lbTitle.Location = New System.Drawing.Point(2, 130)
            Me.lbTitle.Name = "lbTitle"
            Me.lbTitle.Size = New System.Drawing.Size(108, 16)
            Me.lbTitle.TabIndex = 0
            Me.lbTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            '
            'lbStatus
            '
            Me.lbStatus.BackColor = System.Drawing.SystemColors.Control
            Me.lbStatus.ForeColor = System.Drawing.Color.Navy
            Me.lbStatus.Location = New System.Drawing.Point(0, 112)
            Me.lbStatus.Name = "lbStatus"
            Me.lbStatus.Size = New System.Drawing.Size(112, 16)
            Me.lbStatus.TabIndex = 1
            Me.lbStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            '
            'UserControlTip
            '
            Me.UserControlTip.AutoPopDelay = 5000
            Me.UserControlTip.InitialDelay = 200
            Me.UserControlTip.ReshowDelay = 100
            '
            'RoomAndTableControl
            '
            Me.BackColor = System.Drawing.SystemColors.Control
            Me.Controls.Add(Me.lbStatus)
            Me.Controls.Add(Me.lbTitle)
            Me.DockPadding.All = 2
            Me.Name = "RoomAndTableControl"
            Me.Size = New System.Drawing.Size(112, 148)
            Me.ResumeLayout(False)

        End Sub

#End Region

        Private _Status As UseStatus
        Private _RoomName As String
        Private _TableNum As String
        Private _Persons As Integer
        Private _TableName As String
        Private Const FixedHeight As Integer = 148
        Private Const FixedWidth As Integer = 112
        Private _CurrentStatus As UseStatus
        Private Shared m_RoomOrTable As New SortedList

        Public Enum UseStatus
            进餐中
            修缮中
            已空闲
            已预定
        End Enum

        Public Property TableName() As String
            Get
                Return _TableName
            End Get
            Set(ByVal Value As String)
                _TableName = Value
            End Set
        End Property

        Public Property Status() As UseStatus
            Get
                Return _Status
            End Get
            Set(ByVal Value As UseStatus)
                _Status = Value
            End Set
        End Property

        Public Property TableNum() As String
            Get
                Return _TableNum
            End Get
            Set(ByVal Value As String)
                _TableNum = Value
            End Set
        End Property

        Public Property RoomName() As String
            Get
                Return _RoomName
            End Get
            Set(ByVal Value As String)
                _RoomName = Value
            End Set
        End Property

        Public Property ContainPersons() As Integer
            Get
                Return _Persons
            End Get
            Set(ByVal Value As Integer)
                _Persons = Value
            End Set
        End Property

        Private Sub RoomAndTableControl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
            Me.Size = New Size(FixedWidth, FixedHeight)
        End Sub

        Private Sub RoomAndTableControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            lbStatus.Text = Me.Status.ToString
            lbTitle.Text = Me.TableName
            UserControlTip.SetToolTip(Me, "最多可容纳 " & Me.ContainPersons & " 人")
            UserControlTip.SetToolTip(Me.lbStatus, "最多可容纳 " & Me.ContainPersons & " 人")
            UserControlTip.SetToolTip(Me.lbTitle, "最多可容纳 " & Me.ContainPersons & " 人")
        End Sub

        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            Dim mIcon As Icon
            Dim g As Graphics = e.Graphics
            mIcon = CType(m_RoomOrTable.Item(Me.Status), Icon)
            g.DrawIcon(mIcon, CInt(0.5 * (Me.Width - mIcon.Width)), CInt(0.5 * (Me.lbStatus.Top - mIcon.Height)))
            g.Dispose()
        End Sub

        Private Sub RoomAndTableControl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click, lbStatus.Click, lbTitle.Click
            Me.lbStatus.Focus()
            Me.lbTitle.Focus()
        End Sub

        Private Sub RoomAndTableControl_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.LostFocus, lbStatus.LostFocus, lbTitle.LostFocus
            Me.BackColor = Color.FromName("Control")
            Me.lbStatus.BackColor = Color.FromName("Control")
            Me.lbTitle.BackColor = Color.Cornsilk
            Me.lbStatus.ForeColor = Color.Navy
            Me.lbTitle.ForeColor = Color.Navy
        End Sub

    End Class

End Namespace

⌨️ 快捷键说明

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