📄 dlgusemoneycard.frm
字号:
VERSION 5.00
Object = "{0B81E4A9-BE4E-4AEF-9272-33AB5B51C6FC}#1.0#0"; "XPControls.ocx"
Begin VB.Form dlgUseMoneyCard
BackColor = &H80000018&
BorderStyle = 3 'Fixed Dialog
Caption = "使用代金卡"
ClientHeight = 3090
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 4500
Icon = "dlgUseMoneyCard.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3090
ScaleWidth = 4500
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
BackColor = &H80000018&
Caption = "代金卡信息"
Height = 2235
Left = 150
TabIndex = 2
Top = 120
Width = 4185
Begin VB.TextBox txtConsume
ForeColor = &H000000FF&
Height = 285
Left = 2190
TabIndex = 8
Top = 1710
Width = 1125
End
Begin VB.TextBox txtCardID
Height = 285
Left = 990
TabIndex = 4
Top = 660
Width = 2505
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "本次消费金额(元):"
Height = 255
Left = 390
TabIndex = 7
Top = 1740
Width = 1725
End
Begin VB.Label lblBalance
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 255
Left = 2190
TabIndex = 6
Top = 1320
Width = 1125
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "当前余额(元):"
Height = 255
Left = 660
TabIndex = 5
Top = 1320
Width = 1455
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请输入卡号或刷卡:"
Height = 285
Left = 420
TabIndex = 3
Top = 270
Width = 2085
End
End
Begin XPControls.XPCommandButton cmdCancel
Cancel = -1 'True
Height = 405
Left = 2520
TabIndex = 0
Top = 2490
Width = 1035
_ExtentX = 1826
_ExtentY = 714
Caption = "取消(&C)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOK
Height = 405
Left = 960
TabIndex = 1
Top = 2490
Width = 1035
_ExtentX = 1826
_ExtentY = 714
Caption = "确定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "dlgUseMoneyCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim m_curConsume As Currency
Dim m_strCardID As String
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim curConsume As Currency
curConsume = CCur(Val(txtConsume.Text))
'消费金额是否超过了余额
If curConsume > CCur(Val(lblBalance.Caption)) Then
MsgBox "您输入的消费金额超过了该卡的余额,请核对后重新输入!", vbExclamation, "提示"
txtConsume.SetFocus
GoTo ExitLab
End If
'不能小于等于零
If curConsume <= 0 Then
MsgBox "消费金额必须大于零!", vbInformation, "提示"
txtConsume.SetFocus
GoTo ExitLab
End If
'返回
m_curConsume = curConsume
m_strCardID = Trim(txtCardID.Text)
Unload Me
GoTo ExitLab
ExitLab:
'
End Sub
Private Sub Form_Activate()
txtCardID.SetFocus
End Sub
Private Sub txtCardID_GotFocus()
txtCardID.SelStart = 0
txtCardID.SelLength = Len(txtCardID.Text)
End Sub
Private Sub txtCardID_KeyPress(KeyAscii As Integer)
On Error GoTo ErrMsg
Dim Status
Dim strSQL As String
Dim rstemp As ADODB.Recordset
Dim strCardID As String
Me.MousePointer = vbHourglass
'是否回车
If KeyAscii <> vbKeyReturn Then
GoTo ExitLab
End If
'检查卡号是否为空
strCardID = Trim(txtCardID.Text)
txtCardID.Text = strCardID
If strCardID = "" Then
MsgBox "请输入代金卡号或刷卡!", vbInformation, "提示"
txtCardID.SetFocus
GoTo ExitLab
End If
'检查卡号是否存在
strSQL = "select CardBalance from SET_MONEYCARD" _
& " where CardID='" & strCardID & "'"
Set rstemp = New ADODB.Recordset
rstemp.Open strSQL, GCon, adOpenForwardOnly, adLockReadOnly
If rstemp.EOF Then
'卡号不存在
MsgBox "您输入的卡号 “" & strCardID & "” 不存在,请确认该卡已经发放!", _
vbInformation, "提示"
txtCardID.SetFocus
GoTo ExitLab
End If
'显示余额
lblBalance.Caption = CStr(rstemp(0) & "")
'跳转焦点
txtConsume.SetFocus
'关闭记录集
rstemp.Close
GoTo ExitLab
ErrMsg:
Status = SetError(Err.Number, Err.Description, Err.Source)
ErrMsg Status
ExitLab:
Me.MousePointer = vbDefault
End Sub
Private Sub txtConsume_GotFocus()
txtConsume.SelStart = 0
txtConsume.SelLength = Len(txtConsume.Text)
End Sub
Private Sub txtConsume_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
cmdOK_Click
End If
End Sub
Private Sub txtConsume_LostFocus()
txtConsume.Text = CStr(CCur(Val(txtConsume.Text)))
End Sub
'被调函数
'参数1:用于返回消费的卡号
'返回值:消费的金额。如果为零,表示用户单击了取消
Public Function ShowMoneyCard(ByRef strCardID As String) As Currency
Me.Show vbModal
strCardID = m_strCardID
ShowMoneyCard = m_curConsume
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -