【VB开源代码栏目提醒】:网学会员,鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“frmCounter.frm”一文,供大家参考学习!
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmCounter
BorderStyle = 3 'Fixed Dialog
Caption = "计费"
ClientHeight = 5205
ClientLeft = 45
ClientTop = 435
ClientWidth = 7020
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5205
ScaleWidth = 7020
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin TabDlg.SSTab SSTab1
Height = 4455
Left = 240
TabIndex = 1
Top = 240
Width = 6135
_ExtentX = 10821
_ExtentY = 7858
_Version = 393216
Tabs = 2
Tab = 1
TabsPerRow = 2
TabHeight = 520
TabCaption(0) = "普通用户"
TabPicture(0) = "frmCounter.frx":0000
Tab(0).ControlEnabled= 0 'False
Tab(0).Control(0)= "Frame1"
Tab(0).Control(1)= "Frame2"
Tab(0).Control(2)= "cmdcounter"
Tab(0).Control(3)= "cmdexit"
Tab(0).ControlCount= 4
TabCaption(1) = "
会员"
TabPicture(1) = "frmCounter.frx":001C
Tab(1).ControlEnabled= -1 'True
Tab(1).Control(0)= "Frame3"
Tab(1).Control(0).Enabled= 0 'False
Tab(1).Control(1)= "Frame4"
Tab(1).Control(1).Enabled= 0 'False
Tab(1).Control(2)= "cmdvipcounter"
Tab(1).Control(2).Enabled= 0 'False
Tab(1).Control(3)= "cmdvipexit"
Tab(1).Control(3).Enabled= 0 'False
Tab(1).ControlCount= 4
Begin VB.CommandButton cmdvipexit
Caption = "关 闭"
Height = 375
Left = 4560
TabIndex = 17
Top = 3720
Width = 1095
End
Begin VB.CommandButton cmdvipcounter
Caption = "计 费"
Height = 375
Left = 3000
TabIndex = 16
Top = 3720
Width = 1095
End
Begin VB.Frame Frame4
Caption = "应付费用:"
Height = 2895
Left = 3120
TabIndex = 11
Top = 480
Width = 2775
Begin VB.TextBox txtvipmoney
Height = 375
Left = 600
TabIndex = 15
Top = 1320
Width = 1095
End
Begin VB.Label Label4
Caption = "元"
Height = 375
Left = 1920
TabIndex = 14
Top = 1440
Width = 495
End
End
Begin VB.Frame Frame3
Caption = "所用时间:"
Height = 2895
Left = 240
TabIndex = 10
Top = 480
Width = 2535
Begin VB.TextBox txtviptime
Enabled = 0 'False
Height = 375
Left = 960
TabIndex = 13
Top = 1320
Width = 1095
End
Begin VB.Label Label3
Caption = "小时"
Height = 255
Left = 360
TabIndex = 12
Top = 1440
Width = 375
End
End
Begin VB.CommandButton cmdexit
Caption = "关 闭"
Height = 375
Left = -70440
TabIndex = 9
Top = 3720
Width = 1095
End
Begin
VB.CommandButton cmdcounter
Caption = "计 费"
Height = 375
Left = -72000
TabIndex = 6
Top = 3720
Width = 1095
End
Begin VB.Frame Frame2
Caption = "应付费用:"
Height = 2895
Left = -71880
TabIndex = 2
Top = 480
Width = 2775
Begin VB.TextBox txtmoney
Height = 375
Left = 600
TabIndex = 7
Top = 1320
Width = 1095
End
Begin VB.Label Label1
Caption = "元"
Height = 255
Left = 1920
TabIndex = 8
Top = 1440
Width = 255
End
End
Begin VB.Frame Frame1
Caption = "所用时间:"
Height = 2895
Left = -74760
TabIndex = 0
Top = 480
Width = 2535
Begin VB.TextBox txttime
Enabled = 0 'False
Height = 375
Left = 960
TabIndex = 4
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 3240
TabIndex = 3
Top = 2040
Width = 1215
End
Begin VB.Label Label2
Caption = "小时"
Height = 375
Left = 360
TabIndex = 5
Top = 1440
Width = 735
End
End
End
End
Attribute VB_Name = "frmCounter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdcounter_Click()
Dim cn As ADODB.Connection
Dim i As Integer
Dim rst As ADODB.Recordset
Dim strsql As String
Set cn = New Connection
Set rst = New ADODB.Recordset
cn.Open concn
'往 history 表中添加记录
frmManager.Adodc1.Recordset!endtime = Now()
txtmoney.Text = frmManager.Adodc1.Recordset!Time * frmManager.Adodc1.Recordset!uprice
'注意时间字段的添加方法,#
strsql = "insert into history (pcid,starttime,endtime,pay) values (" & frmManager.Adodc1.Recordset!Mid & ",#" & frmManager.Adodc1.Recordset!stime & "#,#" & frmManager.Adodc1.Recordset!endtime & "#," & txtmoney.Text & ")"
Debug.Print strsql
cn.Execute str
sql ' 收费成功,数据初始化
With frmManager.Adodc1
.Recordset!mstate = 0
.Recordset![stime] = 0
.Recordset![jstate] = "未计费"
.Recordset![Money] = 0
.Recordset![endtime] = 0
.Recordset![Time] = 0
.Recordset![lTime] = 0
.Recordset![userID] = ""
On Error GoTo error_proc
.Recordset.Save
End With
frmManager.Refresh '使数据同步显示
MsgBox "收费成功"
Unload Me
Exit Sub
error_proc:
MsgBox Err.Description, vbCritical, "重试"
Unload Me
End Sub
Private Sub cmdvipexit_Click(