📄 form_zhk.frm
字号:
VERSION 5.00
Begin VB.Form Form_zhk
BorderStyle = 1 'Fixed Single
Caption = "折扣"
ClientHeight = 5640
ClientLeft = 45
ClientTop = 435
ClientWidth = 10515
LinkTopic = "Form4"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5640
ScaleWidth = 10515
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command6
Caption = "放弃"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 5400
TabIndex = 8
Top = 4680
Width = 1335
End
Begin VB.ListBox List1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4335
Left = 240
TabIndex = 7
Top = 720
Width = 4935
End
Begin VB.CommandButton Command5
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 8760
TabIndex = 6
Top = 4680
Width = 1335
End
Begin VB.CommandButton Command4
Caption = "确 定"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 7080
TabIndex = 5
Top = 4680
Width = 1335
End
Begin VB.Frame Frame1
Caption = "折扣"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3735
Left = 5400
TabIndex = 0
Top = 600
Width = 4695
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1680
Locked = -1 'True
TabIndex = 10
Top = 840
Width = 1815
End
Begin VB.CommandButton Command3
Caption = "删 除"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 3240
TabIndex = 4
Top = 2760
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "修 改"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1800
TabIndex = 3
Top = 2760
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "增 加"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 360
TabIndex = 2
Top = 2760
Width = 1095
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1680
Locked = -1 'True
TabIndex = 1
Top = 1440
Width = 1815
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "折扣"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 840
TabIndex = 12
Top = 1560
Width = 600
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "开始金额"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 240
TabIndex = 11
Top = 960
Width = 1200
End
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "折扣"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 240
TabIndex = 9
Top = 240
Width = 600
End
End
Attribute VB_Name = "Form_zhk"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim lianjie As New Connection
Dim cl As Recordset
Private Sub Command1_Click()
Text1.Locked = False
Text1 = ""
Text2.Locked = False
Text2 = ""
Text2.SetFocus
Command1.Enabled = False
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
List1.Enabled = False
End Sub
Private Sub Command2_Click()
If Text2.Text = "" Then
MsgBox "不能修改!请选择折扣。", vbInformation, "提示"
Else
Text1.Locked = False
Text2.Locked = False
Command2.Enabled = False
Text2.SetFocus
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
List1.Enabled = False
End If
End Sub
Private Sub Command3_Click()
If Text2.Text = "" Then
MsgBox "不能删除!请选择折扣。", vbInformation, "提示"
Else
Command3.Enabled = False
Command4.SetFocus
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
List1.Enabled = False
End If
End Sub
Private Sub Command4_Click()
If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" Then
If Command1.Enabled Then
Else
cl.AddNew
cl.Fields("开始金额") = CDbl(Text1.Text)
cl.Fields("折扣") = CDbl(Text2.Text)
cl.Update
Call cyy
MsgBox "增加成功!", vbInformation, "提示"
End If
If Command2.Enabled Then
Else
cl.Fields("开始金额") = CDbl(Text1.Text)
cl.Fields("折扣") = CDbl(Text2.Text)
cl.Update
Call cyy
MsgBox "修改成功!", vbInformation, "提示"
End If
If Command3.Enabled Then
Else
cl.Delete
cl.Update
Call cyy
MsgBox "删除成功!", vbInformation, "提示"
End If
Text1.Locked = True
Text1.Text = ""
Text2.Locked = True
Text2.Text = ""
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command1.Visible = True
Command2.Visible = True
Command3.Visible = True
List1.Enabled = True
MsgBox "重新启动程序后生效!", vbInformation, "提示"
End If
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Command6_Click()
Text1.Locked = True
Text1.Text = ""
Text2.Locked = True
Text2.Text = ""
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command1.Visible = True
Command2.Visible = True
Command3.Visible = True
List1.Enabled = True
End Sub
Private Sub Form_Load()
With lianjie
.ConnectionString = dblianjie
.Open
End With
Call cyy
End Sub
Private Sub cyy()
Set cl = New Recordset
cl.CursorLocation = adUseClient
cl.CursorType = adOpenDynamic
cl.LockType = adLockOptimistic
cl.Open "select * from 折扣 ", lianjie
cl.Sort = "编号"
List1.Clear
If cl.RecordCount > 0 Then
cl.MoveFirst
Do Until cl.EOF
List1.AddItem Format(cl.Fields("编号"), "0000") & " " & Format(cl.Fields("开始金额"), "0.00") & "元以上优惠" & CDbl(cl.Fields("折扣")) * 100 & "%"
cl.MoveNext
Loop
End If
Text1 = ""
Text2 = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
lianjie.Close
Set lianjie = Nothing
End Sub
Private Sub List1_Click()
cl.MoveFirst
cl.Find "编号='" & Trim(Left(Trim(List1.List(List1.ListIndex)), 5)) & "'"
Text1.Text = Format(cl.Fields("开始金额"), "0.00")
Text2.Text = Format(cl.Fields("折扣"), "0.00")
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not (Chr(KeyAscii) Like "[0-9]" Or Chr(KeyAscii) = "." Or KeyAscii = vbKeyBack Or KeyAscii = 13) Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_GotFocus()
Text2.SelStart = 0
Text2.SelLength = Len(Text2)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not (Chr(KeyAscii) Like "[0-9]" Or Chr(KeyAscii) = "." Or KeyAscii = vbKeyBack Or KeyAscii = 13) Then
KeyAscii = 0
End If
If KeyAscii = 13 Then
Command4.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -