📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form Form3
BorderStyle = 1 'Fixed Single
Caption = "添加操作框"
ClientHeight = 5025
ClientLeft = 6345
ClientTop = 3165
ClientWidth = 4965
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 4965
Begin VB.CommandButton Command2
Caption = "取消"
Height = 615
Left = 2640
TabIndex = 8
Top = 3600
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "确定"
Default = -1 'True
Height = 615
Left = 240
TabIndex = 7
Top = 3600
Width = 1575
End
Begin VB.TextBox Text3
Height = 375
Left = 1560
TabIndex = 3
Top = 2400
Width = 1815
End
Begin VB.TextBox Text2
Height = 375
Left = 1560
TabIndex = 2
Top = 1680
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 1560
TabIndex = 0
Top = 960
Width = 1815
End
Begin VB.Label Label4
Caption = "消费金额"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 6
Top = 2520
Width = 855
End
Begin VB.Label Label3
Caption = "柜组ID"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 720
TabIndex = 5
Top = 1800
Width = 735
End
Begin VB.Label Label2
Caption = "消费者名字"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 4
Top = 1080
Width = 1095
End
Begin VB.Label Label1
Caption = "请输入相关的添加信息"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 1
Top = 360
Width = 2655
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim i As Integer
Dim ct As Integer
Dim rd As Boolean
Dim j As Integer
Dim k As Integer
Dim n As Integer '200的倍数
Dim sum As Long '单个消费者在商场里的消费额
If Form1.Adodc4.Recordset.Fields.Count = 2 Then '6
MsgBox "对不起,现在商场里没有柜组!不能添加数据,添加对话框将自动关闭!", , ""
GoTo endit
End If '6
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then '1
MsgBox "信息输入不完整,请添加完整,才能录入数据库。", , "提示"
Else '1
Form1.Adodc4.Refresh
'添加消费者到数据库中,如果原来这个消费者名有了,就不添加
ct = Form1.Adodc4.Recordset.RecordCount '当前adodc4中的记录条数
If ct = 0 Then '2
For i = 2 To Form1.Adodc4.Recordset.Fields.Count - 1
If Form1.Adodc4.Recordset.Fields(i).Name = Text2.Text Then
rd = True
End If
Next i
If rd = False Then
MsgBox "数据库中没有指定编号的柜组!,无法录入销售信息。", , "提示"
MsgBox "请根据树形结构中存在的柜组添加相应的销售信息。", , "温馨提示"
GoTo endit
End If
rd = False
Form1.Adodc4.Recordset.AddNew
'--------------------------
For i = 1 To Form1.Adodc4.Recordset.Fields.Count - 1
Form1.Adodc4.Recordset.Fields(i) = 0
Next i
'--------------------------
Form1.Adodc4.Recordset.Fields("customer") = Text1.Text
Else '2
'---------------------------------------------------------------------
For i = 2 To Form1.Adodc4.Recordset.Fields.Count - 1
If Form1.Adodc4.Recordset.Fields(i).Name = Text2.Text Then
rd = True
Exit For
End If
Next i
If rd = False Then
MsgBox "数据库中没有指定编号的柜组!,无法录入销售信息。", , "提示"
MsgBox "请根据树形结构中存在的柜组添加相应的销售信息。", , "温馨提示"
GoTo endit
End If
'----------------------------------------------------------------------
rd = False
Form1.Adodc4.Recordset.MoveFirst
For i = 1 To ct
If Form1.Adodc4.Recordset.Fields("customer") = Text1.Text Then '4
rd = True
End If '4
Form1.Adodc4.Recordset.MoveNext
Next i
If rd = False Then '5
Form1.Adodc4.Recordset.AddNew
'------------------------------
For i = 1 To Form1.Adodc4.Recordset.Fields.Count - 1
Form1.Adodc4.Recordset.Fields(i) = 0
Next i
'------------------------------
Form1.Adodc4.Recordset.Fields("customer") = Text1.Text
Form1.Adodc4.Recordset.Update
End If '5
End If '2
'添加这个消费者在相应的柜组的消费金额
rd = False
ct = Form1.Adodc4.Recordset.Fields.Count '当前adodc4中柜组的个数的两倍+2
For i = 2 To ct - 1 'fields是从0开始的
If Form1.Adodc4.Recordset.Fields(i).Name = Text2.Text Then '3
Form1.Adodc4.Recordset.MoveFirst
For j = 1 To Form1.Adodc4.Recordset.RecordCount
If Form1.Adodc4.Recordset.Fields("customer") = Text1.Text Then '9
If Form1.Adodc4.Recordset.Fields(i) <> 0 Then '10
k = MsgBox("这个消费者在这个柜组的消费信息已经存在,你是否要修改此信息?", vbOKCancel, "提示")
If k = 1 Then '11
Form1.Adodc4.Recordset.Fields(i) = CInt(Text3.Text)
End If '11
Else '10
Form1.Adodc4.Recordset.Fields(i) = CInt(Text3.Text)
End If '10
Exit For
Else
Form1.Adodc4.Recordset.MoveNext
End If '9
Next j
End If '3
Next i
'-------------------------------------------------------------------------------
'以下是摊派金额
Form1.Adodc4.Recordset.MoveFirst
ct = Form1.Adodc4.Recordset.Fields.Count
For j = 1 To Form1.Adodc4.Recordset.RecordCount
sum = 0
For i = 2 To ct - 2 Step 2
If Form1.Adodc4.Recordset.Fields(i) <> 0 Then '11
sum = sum + Form1.Adodc4.Recordset.Fields(i)
End If '11
Next i
Form1.Adodc4.Recordset.Fields("spend") = sum
For i = 2 To ct - 2 Step 2
If Form1.Adodc4.Recordset.Fields(i) <> 0 Then '12
Form1.Adodc4.Recordset.Fields(i + 1) = Form1.Adodc4.Recordset.Fields(i) / sum * 30 * (sum \ 200)
End If '12
Next i
Form1.Adodc4.Recordset.MoveNext
Next j
'-------------------------------------------------------------------------------
endit:
Unload Me
End If '1
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -