📄 checkbill.vb
字号:
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Data.SqlClient
Public Class Form5
Inherits System.Windows.Forms.Form
Dim sum As Double
Dim num As Double
Dim dis As Double
#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 Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form5))
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.TextBox6 = New System.Windows.Forms.TextBox()
Me.TextBox5 = New System.Windows.Forms.TextBox()
Me.Label8 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.CheckBox1 = New System.Windows.Forms.CheckBox()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox6, Me.TextBox5, Me.Label8, Me.Label7, Me.Label6, Me.CheckBox1, Me.TextBox4, Me.Label5, Me.TextBox3, Me.Label4, Me.Label3, Me.TextBox2, Me.Button2, Me.TextBox1, Me.ComboBox1, Me.Label2, Me.Label1})
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(288, 272)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "结账信息"
'
'TextBox6
'
Me.TextBox6.BackColor = System.Drawing.SystemColors.Info
Me.TextBox6.ForeColor = System.Drawing.Color.Red
Me.TextBox6.Location = New System.Drawing.Point(88, 216)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.ReadOnly = True
Me.TextBox6.Size = New System.Drawing.Size(184, 21)
Me.TextBox6.TabIndex = 16
Me.TextBox6.Text = ""
Me.TextBox6.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'TextBox5
'
Me.TextBox5.ForeColor = System.Drawing.SystemColors.HotTrack
Me.TextBox5.Location = New System.Drawing.Point(88, 184)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(184, 21)
Me.TextBox5.TabIndex = 15
Me.TextBox5.Text = ""
Me.TextBox5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label8
'
Me.Label8.ForeColor = System.Drawing.Color.Blue
Me.Label8.Location = New System.Drawing.Point(40, 216)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(48, 21)
Me.Label8.TabIndex = 14
Me.Label8.Text = "找零"
Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label7
'
Me.Label7.ForeColor = System.Drawing.Color.Blue
Me.Label7.Location = New System.Drawing.Point(24, 184)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(56, 21)
Me.Label7.TabIndex = 13
Me.Label7.Text = "实际支付"
Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Label6
'
Me.Label6.ForeColor = System.Drawing.Color.Navy
Me.Label6.Location = New System.Drawing.Point(168, 240)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(104, 24)
Me.Label6.TabIndex = 12
Me.Label6.Text = "加收 5% 的票据税"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'CheckBox1
'
Me.CheckBox1.Location = New System.Drawing.Point(80, 240)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.Size = New System.Drawing.Size(80, 24)
Me.CheckBox1.TabIndex = 11
Me.CheckBox1.Text = "开具发票"
Me.CheckBox1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox4
'
Me.TextBox4.BackColor = System.Drawing.SystemColors.Info
Me.TextBox4.ForeColor = System.Drawing.Color.Red
Me.TextBox4.Location = New System.Drawing.Point(88, 152)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.ReadOnly = True
Me.TextBox4.Size = New System.Drawing.Size(184, 21)
Me.TextBox4.TabIndex = 10
Me.TextBox4.Text = ""
Me.TextBox4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 152)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(64, 21)
Me.Label5.TabIndex = 9
Me.Label5.Text = "应付金额"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(88, 120)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(184, 21)
Me.TextBox3.TabIndex = 8
Me.TextBox3.Text = "0"
Me.TextBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 120)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 21)
Me.Label4.TabIndex = 7
Me.Label4.Text = "优惠折扣"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 21)
Me.Label3.TabIndex = 6
Me.Label3.Text = "支票号/卡号"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox2
'
Me.TextBox2.BackColor = System.Drawing.SystemColors.Info
Me.TextBox2.Location = New System.Drawing.Point(88, 88)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.ReadOnly = True
Me.TextBox2.Size = New System.Drawing.Size(184, 21)
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = ""
Me.TextBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.ForeColor = System.Drawing.Color.Navy
Me.Button2.Location = New System.Drawing.Point(224, 21)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(48, 24)
Me.Button2.TabIndex = 4
Me.Button2.Text = "确定"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(88, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(128, 21)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {"现金", "支票", "信用卡"})
Me.ComboBox1.Location = New System.Drawing.Point(88, 56)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(184, 20)
Me.ComboBox1.TabIndex = 2
Me.ComboBox1.Text = "现金"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 55)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 21)
Me.Label2.TabIndex = 1
Me.Label2.Text = "支付方式"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.Color.Blue
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "账单编码"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(240, 288)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "结账"
'
'Form5
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(304, 319)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.GroupBox1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form5"
Me.Text = "结账台"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.ComboBox1.SelectedIndex = 0 Then
Me.TextBox2.ReadOnly = True
Else
Me.TextBox2.ReadOnly = False
End If
End Sub
Private Sub Form5_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.ComboBox1.SelectedIndex = 0
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If Me.CheckBox1.Checked = True Then
Me.TextBox4.Text = Format(Val(Me.TextBox4.Text) * 1.05, "###,###,###.##")
Else
Me.TextBox4.Text = Format(Val(Me.TextBox4.Text) / 1.05, "###,###,###.##")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If Trim(Me.TextBox1.Text) = "" Then
Exit Sub
End If
sum = 0
GetMenuList()
Me.TextBox4.Text = sum
End Sub
Public Sub GetMenuList()
Dim sqlstr As String
Dim temp As String
sqlstr = "SELECT svcitem FROM EnOrder WHERE orderid=" & _
" '" & Trim(TextBox1.Text) & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
temp = Trim(ds.Tables(0).Rows(0)("svcitem").ToString)
Dim str As String
Do While temp.Length > 0
str = temp.Substring(0, temp.IndexOf("\"))
temp = temp.Remove(0, str.Length + 1)
Compute(str)
Loop
End Sub
Public Function Compute(ByVal menuid As String) As Double
Dim sqlstr As String
sqlstr = "SELECT menu_name,menu_price,menu_discount " & _
"FROM MenuInfo WHERE menu_id='" & menuid & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
num = CDbl(ds.Tables(0).Rows(0)("menu_price"))
dis = CDbl(ds.Tables(0).Rows(0)("menu_discount"))
num = num * (1 - dis)
sum += num
Return sum
End Function
Private Sub TextBox3_TextChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Dim temp As Double
Dim sum1 As Double
If Me.TextBox3.Text = "" Then
temp = 0
Else
temp = CDbl(Me.TextBox3.Text)
End If
sum1 = sum * (1 - temp)
Me.TextBox4.Text = Format(sum1, "##########.##")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim check As Double
If Me.TextBox5.Text = "" Then
check = 0
Else
check = CDbl(Me.TextBox5.Text)
End If
Me.TextBox6.Text = check - CDbl(Me.TextBox4.Text)
If CDbl(Me.TextBox6.Text) < 0 Then
Me.TextBox6.ForeColor = Color.Red
Else
Me.TextBox6.ForeColor = Color.Blue
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -