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

📄 form6.vb

📁 是一个酒店管理信息系统。 用VB.NET以及SQL开发 包括程序
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Button3.Location = New System.Drawing.Point(248, 64)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(80, 32)
        Me.Button3.TabIndex = 6
        Me.Button3.Text = "<"
        '
        'ListBox1
        '
        Me.ListBox1.BackColor = System.Drawing.SystemColors.Info
        Me.ListBox1.ItemHeight = 14
        Me.ListBox1.Location = New System.Drawing.Point(368, 48)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(168, 256)
        Me.ListBox1.TabIndex = 5
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(136, 15)
        Me.Label3.TabIndex = 4
        Me.Label3.Text = "点菜列表如下:"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(288, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(136, 15)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "您点了以下酒菜:"
        '
        'Label4
        '
        Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(576, 56)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(32, 304)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "感谢您对本店的厚爱,谢谢您的光临!"
        '
        'Form6
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 17)
        Me.BackColor = System.Drawing.Color.LightSteelBlue
        Me.ClientSize = New System.Drawing.Size(616, 376)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Panel1)
        Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MaximizeBox = False
        Me.Name = "Form6"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "点菜菜单"
        Me.Panel1.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim cn As New SqlConnection("data source=(local);initial catalog=酒店管理系统;uid=sa;pwd=;")
    Dim cm As New SqlCommand("select * from 酒菜信息", cn)
    Dim da As New SqlDataAdapter(cm)
    Dim indexda As New SqlDataAdapter(cm)
    Dim ds As New DataSet
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button4.Click
        Try
            If ComboBox2.Text = "" Then
                MsgBox("请选择您的帐号,该选项不能为空!", MsgBoxStyle.Exclamation)
            Else
                If Not IsNothing(TreeView1.SelectedNode.Parent) Then
                    ListBox1.Items.Add(TreeView1.SelectedNode.Text)
                End If
                End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button3.Click
        If ComboBox2.Text = "" Then
            MsgBox("请先选择您的帐号!", MsgBoxStyle.Exclamation)
        Else
            If ListBox1.SelectedIndex = -1 Then
                MsgBox("您没有在您已经选择的菜单中选中您要删除的项!", MsgBoxStyle.Information, "警告")
            Else
                ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
            End If
        End If

    End Sub


    Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            cn.Open()
            da.Fill(ds, "酒菜信息")
            indexda.SelectCommand.CommandText = "select 流水帐号 from 开台 where 结帐日期 is null"
            indexda.Fill(ds, "开台")
            cn.Close()
            ''填充帐号下拉列表框
            Dim rowindex As Integer
            For rowindex = 0 To ds.Tables("开台").Rows.Count - 1
                ComboBox2.Items.Add(ds.Tables("开台").Rows(rowindex).Item(0).ToString)
            Next
            ''填充treeview添加酒菜信息
            If ds.Tables("酒菜信息").Rows.Count <> 0 Then
                Dim temp As New DataView
                Dim i, j, z As Integer
                Dim group As DataView
                '循环查找类别里面没有重复的个数然后传入数列
                Dim count As Integer = 1
                Dim str As String
                Dim values As New ArrayList
                values.Add(ds.Tables("酒菜信息").DefaultView.Item(0).Item(1).ToString())
                ds.Tables("酒菜信息").DefaultView.Sort = "类别 asc"
                str = ds.Tables("酒菜信息").DefaultView.Item(0).Item(1).ToString()
                For z = 0 To ds.Tables("酒菜信息").DefaultView.Count - 1
                    If str <> ds.Tables("酒菜信息").DefaultView.Item(z).Item(1).ToString() Then
                        count += 1
                        values.Add(ds.Tables("酒菜信息").DefaultView.Item(z).Item(1).ToString())
                    End If

                    str = ds.Tables("酒菜信息").DefaultView.Item(z).Item(1).ToString()
                Next
                '在数列中检索数据对应类别下再填充数据
                temp.Table = ds.Tables("酒菜信息")
                For i = 0 To count - 1
                    TreeView1.Nodes.Add(values.Item(i).ToString)
                    temp.RowFilter = "类别='" & values.Item(i).ToString & "'"
                    For j = 0 To temp.Count - 1
                        TreeView1.Nodes(i).Nodes.Add(temp.Item(j).Item(0).ToString)
                    Next
                Next
                TreeView1.ExpandAll()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try


    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim i As Integer
        For i = 0 To ds.Tables("酒菜信息").Rows.Count - 1
            ListBox1.Items.Add(ds.Tables("酒菜信息").Rows(i).Item("酒菜名").ToString)
        Next
    End Sub


    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If MsgBox("您确定要删除所有点过的菜单吗?", MsgBoxStyle.Information) = MsgBoxResult.OK Then
            ListBox1.Items.Clear()
        End If
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            If ListBox1.Items.Count = 0 Then
                Exit Sub
            Else
                cn.Open()
                Dim da As New SqlDataAdapter("select * from 点菜", cn)
                Dim cb As New SqlCommandBuilder(da)
                da.Fill(ds, "点菜")
                Dim i As Integer
                For i = 0 To ListBox1.Items.Count - 1
                    Dim row As DataRow = ds.Tables("点菜").NewRow
                    row(1) = Trim(ComboBox2.Text)
                    row(2) = Trim(ListBox1.Items(i).ToString)
                    If ComboBox1.Text <> "" Then
                        row(4) = Trim(ComboBox1.SelectedItem)
                    End If
                    ds.Tables("点菜").Rows.Add(row)
                Next
                If ds.HasChanges = True Then
                    MsgBox("您已经点菜成功!")
                End If
                da.Update(ds.Tables("点菜"))
                cn.Close()
            End If
            ListBox1.Items.Clear()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub
End Class

⌨️ 快捷键说明

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