?? orderwr.vb
字號:
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Data.SqlClient
Public Class Form4
Inherits System.Windows.Forms.Form
#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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form4))
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(152, 208)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "登記"
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.ForeColor = System.Drawing.Color.Navy
Me.Button2.Location = New System.Drawing.Point(216, 208)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(48, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "取消"
'
'GroupBox1
'
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label6, Me.TextBox3, Me.Label5, Me.Label4, Me.ComboBox1, Me.Label3, Me.TextBox2, Me.Label2, Me.TextBox1, Me.Label1})
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(256, 192)
Me.GroupBox1.TabIndex = 2
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "賬單信息"
'
'Label6
'
Me.Label6.BackColor = System.Drawing.SystemColors.Info
Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label6.Location = New System.Drawing.Point(88, 152)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(144, 24)
Me.Label6.TabIndex = 10
Me.Label6.Text = "Label6"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(88, 120)
Me.TextBox3.MaxLength = 6
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(144, 21)
Me.TextBox3.TabIndex = 9
Me.TextBox3.Text = ""
'
'Label5
'
Me.Label5.ForeColor = System.Drawing.Color.Navy
Me.Label5.Location = New System.Drawing.Point(16, 120)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(72, 21)
Me.Label5.TabIndex = 8
Me.Label5.Text = "服務員編碼*"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Label4
'
Me.Label4.ForeColor = System.Drawing.Color.Navy
Me.Label4.Location = New System.Drawing.Point(16, 152)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 21)
Me.Label4.TabIndex = 6
Me.Label4.Text = "登記時間"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {"前臺服務"})
Me.ComboBox1.Location = New System.Drawing.Point(88, 88)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(144, 20)
Me.ComboBox1.TabIndex = 5
Me.ComboBox1.Text = "前臺服務"
'
'Label3
'
Me.Label3.ForeColor = System.Drawing.Color.Navy
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 21)
Me.Label3.TabIndex = 4
Me.Label3.Text = "服務類型"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(88, 56)
Me.TextBox2.MaxLength = 6
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(144, 21)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'Label2
'
Me.Label2.ForeColor = System.Drawing.Color.Navy
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 21)
Me.Label2.TabIndex = 2
Me.Label2.Text = "服務桌號*"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(88, 24)
Me.TextBox1.MaxLength = 6
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(144, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.Color.Navy
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "賬單編碼*"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Timer1
'
Me.Timer1.Interval = 1000
'
'Form4
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(274, 239)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.Button2, Me.Button1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form4"
Me.Text = "賬單登記表"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlstr As String
Dim myorder As OrderInfo
Dim ds As New DataSet()
myorder = GetDataFromForm()
If myorder.OrderID = "" Then
MsgBox("賬單號不能為空!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "賬單號為空")
Exit Sub
End If
If IsNumeric(myorder.TbNum) = False Then
MsgBox("桌號必須是數字,請輸入正確的數字!", MsgBoxStyle.OKOnly _
+ MsgBoxStyle.Exclamation, "桌號不是數字")
Exit Sub
End If
sqlstr = "SELECT status FROM TableInfo WHERE tablenum='" & myorder.TbNum & "'"
ds.Clear()
ds = GetDataFromDB(sqlstr)
If ds.Tables(0).Rows.Count = 0 Then
MsgBox("找不到該桌號,請重新輸入。", MsgBoxStyle.Exclamation + _
MsgBoxStyle.OKOnly, "桌號錯誤")
Me.TextBox2.Text = ""
Exit Sub
End If
If Trim(ds.Tables(0).Rows(0)("status")) <> "空閑" Then
MsgBox("該桌正在使用或者已經被預定。", MsgBoxStyle.Exclamation + _
MsgBoxStyle.OKOnly, "使用中")
Exit Sub
End If
If myorder.SvcNum = "" Then
MsgBox("服務員編號不能為空!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "服務員編號為空")
Exit Sub
End If
sqlstr = "INSERT INTO EnOrder (orderid,tbnum,svctype,svcnum,svcdate)" & _
" VALUES ('" & myorder.OrderID & "','" & myorder.TbNum & "'," & _
"'" & myorder.SvcType & "','" & myorder.SvcNum & "','" & myorder.SvcDate & "')"
If UpdateData(sqlstr) = True Then
MsgBox("賬單登記成功。", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "登記成功")
Else
MsgBox("該賬單號已經存在,此次登記失敗。", _
MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "登記失敗")
Exit Sub
End If
Me.Timer1.Enabled = False
sqlstr = "UPDATE TableInfo SET status='使用中' WHERE tablenum='" & myorder.TbNum & "'"
UpdateData(sqlstr)
End Sub
Public Function GetDataFromForm() As OrderInfo
Dim myorder As New OrderInfo()
myorder.OrderID = Trim(Me.TextBox1.Text)
myorder.TbNum = CInt(Val(Trim(Me.TextBox2.Text)))
myorder.SvcType = Trim(Me.ComboBox1.SelectedItem)
myorder.SvcNum = Trim(Me.TextBox3.Text)
myorder.SvcDate = CDate(Me.Label6.Text.Trim)
Return myorder
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Timer1.Enabled = False
Me.Close()
End Sub
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Label6.Text = Now.ToShortDateString
End Sub
End Class
Public Class OrderInfo
Public OrderID As String
Public TbNum As Integer
Public SvcType As String
Public SvcNum As String
Public SvcDate As Date
Public SvcItems As String
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -