📄 frmsellopen.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmSellOpen
Caption = "销售"
ClientHeight = 8070
ClientLeft = 60
ClientTop = 450
ClientWidth = 8640
LinkTopic = "Form1"
ScaleHeight = 8070
ScaleWidth = 8640
StartUpPosition = 2 'CenterScreen
WindowState = 2 'Maximized
Begin VB.PictureBox Picture1
Height = 3615
Left = 0
ScaleHeight = 3555
ScaleWidth = 8580
TabIndex = 1
Top = 4440
Width = 8640
Begin VB.CommandButton Command1
Caption = "下一客户"
Height = 495
Left = 7200
TabIndex = 18
Top = 2760
Width = 1095
End
Begin VB.TextBox txtR
Alignment = 2 'Center
Height = 285
Left = 6240
TabIndex = 17
Top = 1920
Width = 1335
End
Begin VB.TextBox txtGive
Alignment = 2 'Center
Height = 285
Left = 6240
TabIndex = 16
Top = 1560
Width = 1335
End
Begin VB.CommandButton cmdAll
Caption = "结账"
Height = 495
Left = 5520
TabIndex = 13
Top = 2760
Width = 1455
End
Begin VB.TextBox txtAllValue
Alignment = 2 'Center
BackColor = &H80000000&
BorderStyle = 0 'None
Height = 375
Left = 1800
TabIndex = 12
Text = "0"
Top = 0
Width = 1455
End
Begin VB.CommandButton cmdModify
Caption = "修改"
Height = 495
Left = 3840
TabIndex = 10
Top = 2760
Width = 1455
End
Begin VB.CommandButton cmdDel
Caption = "删除"
Height = 495
Left = 2160
TabIndex = 9
Top = 2760
Width = 1455
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 495
Left = 480
TabIndex = 8
Top = 2760
Width = 1455
End
Begin VB.TextBox txtSum
Alignment = 2 'Center
Height = 375
Left = 2640
TabIndex = 7
Top = 1920
Width = 1935
End
Begin VB.TextBox txtValue
Alignment = 2 'Center
Height = 375
Left = 2640
Locked = -1 'True
TabIndex = 6
Top = 1440
Width = 1935
End
Begin VB.TextBox txtNo
Alignment = 2 'Center
Height = 375
Left = 2640
TabIndex = 3
Top = 960
Width = 1935
End
Begin VB.Label Label5
Caption = "应找金额(元):"
Height = 255
Index = 1
Left = 5160
TabIndex = 15
Top = 1920
Width = 1095
End
Begin VB.Label Label5
Caption = "实付金额(元):"
Height = 255
Index = 0
Left = 5160
TabIndex = 14
Top = 1560
Width = 1095
End
Begin VB.Label Label4
Caption = "当前总价格(元)"
Height = 255
Left = 480
TabIndex = 11
Top = 120
Width = 1215
End
Begin VB.Label Label3
Caption = "商品数量*"
Height = 255
Left = 1560
TabIndex = 5
Top = 2040
Width = 855
End
Begin VB.Label Label2
Caption = "商品价格"
Height = 255
Left = 1560
TabIndex = 4
Top = 1560
Width = 855
End
Begin VB.Label Label1
Caption = "商品编号*"
Height = 255
Left = 1560
TabIndex = 2
Top = 1080
Width = 855
End
End
Begin MSComctlLib.ListView ListView1
Height = 3975
Left = 0
TabIndex = 0
Top = 0
Width = 8535
_ExtentX = 15055
_ExtentY = 7011
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "商品编号"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "商品名称"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "单价"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "数量"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "单位"
Object.Width = 2540
EndProperty
End
End
Attribute VB_Name = "frmSellOpen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ltmW As ListItem
Dim Sql As String
Dim RS As ADODB.Recordset
Private Sub cmdAdd_Click()
'添加
Dim i As Integer
If Trim(Me.txtNo.Text) <> "" And Trim(Me.txtSum.Text) <> "" Then
Sql = "select 商品名称,单价,单位 from 商品表 where 商品编号= " & Trim(Me.txtNo.Text)
Set RS = dbSelect(Sql)
If RS.EOF Then
MsgBox "库中无此商品!"
Else
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
MsgBox "列表中已有!"
Exit Sub
End If
Next i
Set ltmW = Me.ListView1.ListItems.Add
ltmW.Text = Trim(Me.txtNo.Text)
ltmW.ListSubItems.Add , , RS.Fields(0)
ltmW.ListSubItems.Add , , RS.Fields(1)
ltmW.ListSubItems.Add , , Trim(Me.txtSum.Text)
ltmW.ListSubItems.Add , , RS.Fields(2)
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Trim(Me.txtSum.Text)) * RS.Fields(1)
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
End If
RS.Close
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdAll_Click()
'结账数据入库
Dim i As Integer
For i = 1 To Me.ListView1.ListItems.Count
Sql = "insert into 销售表 values(" & Me.ListView1.ListItems(i).Text
Sql = Sql & ",'" & Date
Sql = Sql & "'," & Me.ListView1.ListItems(i).ListSubItems(3).Text
Sql = Sql & ",'" & Time
Sql = Sql & "')"
dbOperateW Sql
Next i
Me.txtR.Text = Str((Val(Trim(Me.txtGive.Text)) - Val(Trim(Me.txtAllValue.Text))))
Me.txtR.Text = Format(Me.txtR.Text, "#.##")
MsgBox "操作成功!总金额为" & Trim(Me.txtAllValue.Text) & "元,应找金额为" & Me.txtR.Text & "元"
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Me.txtAllValue.Text = ""
End Sub
Private Sub cmdDel_Click()
'删除
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) - Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
Val(Me.ListView1.ListItems(i).ListSubItems(3))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems.Remove (i)
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdModify_Click()
'修改
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
(Val(Trim(txtSum.Text)) - Val(Me.ListView1.ListItems(i).ListSubItems(3)))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems(i).ListSubItems(3).Text = Trim(txtSum.Text)
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub Command1_Click()
Me.ListView1.ListItems.Clear
End Sub
Private Sub Form_Resize()
'控件大小的动态调整
Dim i As Integer
Me.ListView1.Width = Me.ScaleWidth
For i = 1 To 5
Me.ListView1.ColumnHeaders(i).Width = Me.ListView1.Width / 5
Next i
Me.ListView1.Top = 0
Me.ListView1.Height = Me.ScaleHeight - Me.Picture1.Height
Me.Picture1.Top = Me.ScaleHeight - Me.Picture1.Height
Me.Picture1.Width = Me.ScaleWidth
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Me.txtNo.Text = Item.Text
Me.txtValue.Text = Item.ListSubItems(2).Text
Me.txtSum.Text = Item.ListSubItems(3).Text
End Sub
Private Sub txtGive_KeyPress(KeyAscii As Integer)
'实付金额
If Not IsNumeric(Trim(Me.txtGive.Text)) And Trim(Me.txtGive.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtNo_KeyPress(KeyAscii As Integer)
'商品编号
If Not IsNumeric(Trim(Me.txtNo.Text)) And Trim(Me.txtNo.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtR_KeyPress(KeyAscii As Integer)
'应找金额
If Not IsNumeric(Trim(Me.txtR.Text)) And Trim(Me.txtR.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtSum_KeyPress(KeyAscii As Integer)
'数量
If Not IsNumeric(Trim(Me.txtSum.Text)) And Trim(Me.txtSum.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtValue_KeyPress(KeyAscii As Integer)
'单价
If Not IsNumeric(Trim(Me.txtValue.Text)) And Trim(Me.txtValue.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -