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

📄 frmsite.vb

📁 本系统利用vb.net做为前台开发工具
💻 VB
📖 第 1 页 / 共 3 页
字号:
    Me.btnCancel.Size = New System.Drawing.Size(80, 32)
    Me.btnCancel.TabIndex = 4
    Me.btnCancel.Text = "取    消"
    Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.BottomCenter
    '
    'btnOK
    '
    Me.btnOK.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
    Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Popup
    Me.btnOK.Font = New System.Drawing.Font("新宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
    Me.btnOK.ForeColor = System.Drawing.Color.Blue
    Me.btnOK.Location = New System.Drawing.Point(42, 352)
    Me.btnOK.Name = "btnOK"
    Me.btnOK.Size = New System.Drawing.Size(80, 32)
    Me.btnOK.TabIndex = 3
    Me.btnOK.Text = "完    成"
    Me.btnOK.TextAlign = System.Drawing.ContentAlignment.BottomCenter
    '
    'frmSite
    '
    Me.AcceptButton = Me.btnOK
    Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
    Me.BackColor = System.Drawing.Color.Khaki
    Me.CancelButton = Me.btnCancel
    Me.ClientSize = New System.Drawing.Size(664, 448)
    Me.Controls.Add(Me.palSiteOpre)
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
    Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
    Me.MaximizeBox = False
    Me.Name = "frmSite"
    Me.Text = "餐位管理"
    Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
    Me.palSiteOpre.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region
    '数据库连接对象
    Dim odb As New DB.DB
    '数据表对象
    Dim myTab As New DataTable
    '数据表操作字符串
    Dim strSQL As String
    '餐厅中餐位的列数
    Dim xNum As Integer
    '餐厅中餐位的行数
    Dim yNum As Integer
    '图片框数组
    Dim ImgArr() As PictureBox
    '餐位的初始状态
    Dim OrigStatus As String




    Private Sub frmSite_Load(ByVal sender As System.Object, ByVal e As _
                System.EventArgs) Handles MyBase.Load
        '记录窗体的最大宽度和高度
        Dim m, n As Integer
        '获取窗体最大高度和宽度
        Me.WindowState = FormWindowState.Maximized
        m = Me.Height
        n = Me.Width
        '将窗体的高度和宽度设置到最大
        Me.WindowState = FormWindowState.Normal
        Me.Width = n
        Me.Height = m
        Me.Top = 0
        Me.Left = 0
        '假设餐位为四行六列
        xNum = 6
        yNum = 4
        '设置窗体中各个餐位的状态信息
        LayoutFrm(xNum, yNum)
    End Sub





  Private Sub LayoutFrm(ByVal xNum As Integer, ByVal yNum As Integer)
    '记录餐位的行数和列数
    Dim intN, intM As Integer
    '记录餐位的桌号
    Dim intTabID As Integer
    '记录餐位状态对应的图片名称
    Dim PicNam As String
    '确定餐位数量后重定义图片框数组
    ReDim ImgArr(xNum * yNum - 1)
    For intM = 0 To yNum - 1
      For intN = 0 To xNum - 1
        intTabID = intTabID + 1
        '得到桌号为intTabID的状态,然后设置状态对应的图片
        PicNam = GetStatus(intTabID) & ".jpg"

        '实例化图片框数组
        ImgArr(intTabID - 1) = New PictureBox
        '添加到窗体中
        Me.Controls.Add(ImgArr(intTabID - 1))
        '设置图片框属性
        ImgArr(intTabID - 1).SizeMode = PictureBoxSizeMode.StretchImage
        ImgArr(intTabID - 1).Image = New Bitmap(MyClass.GetType(), PicNam)
        ImgArr(intTabID - 1).Name = intTabID
        ImgArr(intTabID - 1).Width = (Me.Width - 185) / xNum
        ImgArr(intTabID - 1).Height = ImgArr(intTabID - 1).Width
        ImgArr(intTabID - 1).Top = (intM + 1) * 20 + _
                    intM * ImgArr(intTabID - 1).Height
        ImgArr(intTabID - 1).Left = (intN + 1) * 20 + _
                    intN * ImgArr(intTabID - 1).Width
        ImgArr(intTabID - 1).BorderStyle = BorderStyle.FixedSingle
        ImgArr(intTabID - 1).BackColor = System.Drawing.Color.Gray
        '设置图片框事件处理程序
        AddHandler CType(ImgArr(intTabID - 1), PictureBox).Click, _
                        AddressOf ClickPic
        AddHandler CType(ImgArr(intTabID - 1), PictureBox).MouseEnter, _
                        AddressOf MouseEnterPic
        AddHandler CType(ImgArr(intTabID - 1), PictureBox).MouseLeave, _
                        AddressOf MouseLeavePic
      Next intN
    Next intM
  End Sub


  Private Function GetStatus(ByVal IDNum As Integer) As String
    '根据桌号得到餐位状态
    strSQL = "select Status from Site where TableID=" & IDNum
    Try
      myTab = odb.CreateDataTable(strSQL)
      '返回餐位的状态
      Return myTab.Rows(0).Item(0)
    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Exclamation)
    End Try
  End Function



  Private Sub MouseEnterPic(ByVal sender As System.Object, ByVal e _
              As System.EventArgs)
    '鼠标进入图片框区域时
    CType(sender, PictureBox).BorderStyle = BorderStyle.Fixed3D
  End Sub

  Private Sub MouseLeavePic(ByVal sender As System.Object, ByVal e _
              As System.EventArgs)
    '鼠标离开图片框区域时
    CType(sender, PictureBox).BorderStyle = BorderStyle.FixedSingle
  End Sub

  Private Sub ClickPic(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '单击图片框后对此图片框表示的餐位进行操作
    SiteOpreate(CType(sender, PictureBox).Name)
  End Sub


  Private Sub SiteOpreate(ByVal TableID As Integer)
    '对palSiteOpre属性进行设置
    palSiteOpre.Height = 400
    palSiteOpre.Top = (Me.Height - palSiteOpre.Height) / 2
    palSiteOpre.Width = 600
    palSiteOpre.Left = (Me.Width - palSiteOpre.Width) / 2
    palSiteOpre.Visible = True
    '对palSiteOpre面板中控件属性进行设置
    '初始时控件都为可读,不能进行编辑
    txtID.Text = TableID
    txtPer.ReadOnly = True
    txtDish.ReadOnly = True
    txtDiscount.ReadOnly = True
    '以桌号为关键字从数据库中检索餐位信息
    strSQL = "select status,numperson,totalconsu,numdish,discount from site where " & _
            " tableid='" & TableID & "'"
    Try
      myTab = odb.CreateDataTable(strSQL)
      If myTab.Rows.Count > 0 Then
        '记录此餐位的初始状态供全局使用
        OrigStatus = myTab.Rows(0).Item(0)
        '使用中和结帐中的餐位的消费金额和菜数需要统计得到
        If OrigStatus = "U" Or OrigStatus = "B" Then
          txtDiscount.Text = myTab.Rows(0).Item(4) & "元"
          cmbStatus.Text = ConvertStatus(myTab.Rows(0).Item(0))
          txtPer.Text = myTab.Rows(0).Item(1) & "人"
          '以桌号为关键字从BillofSite数据表中统计菜数
          '以桌号为关键字从BillofSite和Menu数据表中统计消费金额
          Dim strSql1 As String = "select billofsite.tableid ,count(billofsite.id)" & _
                  " as NumofDish,sum(price) as TotalMoney from billofsite,menu " & _
                  " where menu.id=billofsite.id and tableid=" & TableID & _
                  "  group by billofsite.tableid"
          Dim myTab1 As DataTable
          myTab1 = odb.CreateDataTable(strSql1)
          If myTab1.Rows.Count > 0 Then
            txtMoney.Text = myTab1.Rows(0).Item(2) & "元"
            txtDish.Text = myTab1.Rows(0).Item(1) & "道"
          End If
          '对于结帐中的餐位,可以编辑优惠金额
          If OrigStatus = "B" Then
            txtDiscount.ReadOnly = False
          End If
        Else
          '停用、预订和空闲餐位直接读取数据表即可
          cmbStatus.Text = ConvertStatus(OrigStatus)
          txtPer.Text = myTab.Rows(0).Item(1) & "人"
          txtMoney.Text = myTab.Rows(0).Item(2) & "元"
          txtDish.Text = myTab.Rows(0).Item(3) & "道"
          txtDiscount.Text = myTab.Rows(0).Item(4) & "元"
        End If
      End If
    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Exclamation)
      Exit Sub
    End Try
    '设置palSiteOpre面板右侧的点菜列表视图和菜单列表视图
    '初始状态下点菜视图不可见
    lvwGetDish.Visible = False
    '菜单视图可见
    lvwSiteOpre.Visible = True
    '设置菜单视图属性
    lvwSiteOpre.Top = 0
    lvwSiteOpre.Left = palSiteOpre.Width / 2
    lvwSiteOpre.Width = palSiteOpre.Width / 2
    lvwSiteOpre.Height = palSiteOpre.Height
    lvwSiteOpre.Columns.Add("菜  名", lvwSiteOpre.Width / 3, HorizontalAlignment.Center)
    lvwSiteOpre.Columns.Add("价  格", lvwSiteOpre.Width / 3, HorizontalAlignment.Center)
    lvwSiteOpre.Columns.Add("类  型", lvwSiteOpre.Width / 3, HorizontalAlignment.Center)
    '填充lvwSiteOpre,即显示所点菜单
    '以桌号为关键字从BillofSite数据表得到菜肴编号
    '根据菜肴编号从Menu数据表得到菜肴详细信息
    strSQL = "select name as 菜名,price as 价格,type as 类型 from billofsite,menu where " & _
            "billofsite.id=menu.id and tableid='" & TableID & "'"
    Dim i As Integer
    Dim str(3) As String
    Dim itm As ListViewItem
    Try
      myTab = odb.CreateDataTable(strSQL)
      lvwSiteOpre.Items.Clear()
      '检索有结果即有菜单,添加到菜单视图中
      If myTab.Rows.Count > 0 Then
        For i = 0 To myTab.Rows.Count - 1
          str(0) = myTab.Rows(i).Item(0)
          str(1) = myTab.Rows(i).Item(1)
          str(2) = myTab.Rows(i).Item(2)
          itm = New ListViewItem(str)
          lvwSiteOpre.Items.Add(itm)
        Next
      End If
    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Exclamation)
      Exit Sub
    End Try
  End Sub





  Private Function ConvertStatus(ByVal strOri As String) As String
    '将组合框中状态字段和数据库中状态字段相互转换
    Dim strRe As String
    Select Case strOri
      Case "U"
        strRe = "使用"
      Case "B"
        strRe = "结帐"
      Case "F"
        strRe = "空闲"
      Case "O"
        strRe = "预订"
      Case "T"

⌨️ 快捷键说明

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