📄 menu.vb
字号:
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Data.SqlClient
Public Class Form13
Inherits System.Windows.Forms.Form
Dim myDS As New Data.DataSet()
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form13))
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.ListBox2 = New System.Windows.Forms.ListBox()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.Button4 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Label3 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.Label2, Me.Label1, Me.ListBox2, Me.ListBox1})
Me.GroupBox1.Location = New System.Drawing.Point(8, 0)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(392, 264)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.ForeColor = System.Drawing.Color.Navy
Me.Button2.Location = New System.Drawing.Point(176, 232)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 24)
Me.Button2.TabIndex = 5
Me.Button2.Text = "<<"
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(176, 200)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 24)
Me.Button1.TabIndex = 4
Me.Button1.Text = ">>"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(232, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(88, 16)
Me.Label2.TabIndex = 3
Me.Label2.Text = "您的菜单:"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "菜单目录:"
'
'ListBox2
'
Me.ListBox2.ItemHeight = 12
Me.ListBox2.Location = New System.Drawing.Point(240, 48)
Me.ListBox2.Name = "ListBox2"
Me.ListBox2.Size = New System.Drawing.Size(144, 208)
Me.ListBox2.TabIndex = 1
'
'ListBox1
'
Me.ListBox1.ItemHeight = 12
Me.ListBox1.Location = New System.Drawing.Point(16, 48)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(152, 208)
Me.ListBox1.TabIndex = 0
'
'Button4
'
Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button4.ForeColor = System.Drawing.Color.Navy
Me.Button4.Location = New System.Drawing.Point(280, 272)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(56, 24)
Me.Button4.TabIndex = 6
Me.Button4.Text = "确定"
'
'Button3
'
Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button3.ForeColor = System.Drawing.Color.Navy
Me.Button3.Location = New System.Drawing.Point(344, 272)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(56, 24)
Me.Button3.TabIndex = 1
Me.Button3.Text = "取消"
'
'Label3
'
Me.Label3.ForeColor = System.Drawing.Color.Red
Me.Label3.Location = New System.Drawing.Point(16, 272)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(64, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "账单号:"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(72, 272)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 21)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'Form13
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(410, 303)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1, Me.Label3, Me.Button3, Me.GroupBox1, Me.Button4})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form13"
Me.Text = "点菜菜单目录"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form13_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim strSQL As String
strSQL = "SELECT menu_id ,menu_name FROM MenuInfo"
myDS.Clear()
myDS = GetDataFromDB(strSQL)
Dim strTemp As String
Dim count, i As Integer
count = myDS.Tables(0).Rows.Count
If count <= 0 Then
Exit Sub
End If
For i = 0 To count - 1
strTemp = Trim(myDS.Tables(0).Rows(i)("menu_id"))
strTemp = strTemp & " — " & myDS.Tables(0).Rows(i)("menu_name")
Me.ListBox1.Items.Add(strTemp)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim strtemp As String
strtemp = Me.ListBox1.SelectedItem
If strtemp Is Nothing Then Exit Sub
strtemp = strtemp.Substring(0, strtemp.IndexOf(" — "))
Me.ListBox2.Items.Add(strtemp)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Me.ListBox2.Items.Remove(Me.ListBox2.SelectedItem)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
If Me.ListBox2.Items.Count = 0 Then
MsgBox("还没有点菜,请先点菜。", MsgBoxStyle.Exclamation + _
MsgBoxStyle.OKOnly, "未点菜")
Exit Sub
End If
If Trim(Me.TextBox1.Text) = "" Then
MsgBox("请输入相应的账单号。", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "账单号为空")
Exit Sub
End If
Dim sqlstr As String = "SELECT * FROM EnOrder WHERE orderid=" & _
"'" & Trim(TextBox1.Text) & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
If ds.Tables(0).Rows.Count = 0 Then
MsgBox("还没有登记该账单,请先登记账单号。", MsgBoxStyle.Exclamation _
+ MsgBoxStyle.OKOnly, "未登记账单")
Exit Sub
End If
Dim temp As String = ""
If ds.Tables(0).Rows(0)("svcitem").GetType.ToString <> "System.DBNull" Then
temp = Trim(ds.Tables(0).Rows(0)("svcitem").ToString)
Else
temp = ""
End If
Dim i As Integer
For i = 0 To Me.ListBox2.Items.Count - 1
temp += Me.ListBox2.Items(i).ToString.Trim & "\"
Next
sqlstr = "UPDATE EnOrder SET svcitem ='" & temp & "' " & _
"WHERE orderid='" & TextBox1.Text.Trim & "'"
If UpdateData(sqlstr) = True Then
Me.Close()
End If
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Button1_Click(Nothing, Nothing)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -