📄 frmaddshopingcar.frm
字号:
VERSION 5.00
Begin VB.Form AddShopingCar
BorderStyle = 1 'Fixed Single
Caption = "创建购物车"
ClientHeight = 1920
ClientLeft = 45
ClientTop = 330
ClientWidth = 4110
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 1920
ScaleWidth = 4110
Begin VB.CommandButton cmdRefresh
Caption = "刷新"
Height = 300
Left = 1755
TabIndex = 3
Top = 1215
Width = 615
End
Begin VB.CommandButton cmdOk
Caption = "确定"
Default = -1 'True
Height = 300
Left = 705
TabIndex = 2
Top = 1215
Width = 615
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "关闭"
Height = 300
Left = 2760
TabIndex = 4
Top = 1215
Width = 615
End
Begin VB.TextBox txtUser
Height = 270
Left = 945
MaxLength = 11
TabIndex = 0
Top = 735
Width = 2490
End
Begin VB.TextBox txtNumber
Height = 270
Left = 945
Locked = -1 'True
MaxLength = 12
TabIndex = 1
Top = 285
Width = 2490
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "客户"
Height = 180
Left = 495
TabIndex = 6
Top = 780
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "编号"
Height = 180
Left = 495
TabIndex = 5
Top = 330
Width = 360
End
End
Attribute VB_Name = "AddShopingCar"
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 cmdOk_Click()
On Error GoTo DoError
Dim strSQL As String, objCom As Command
If Trim(txtUser) = "" Then
MsgBox "请输入客户姓名!", vbCritical, "创建购物车"
txtUser = ""
txtUser.SetFocus
Else
With Drug_Store.rsShoppingCars
.AddNew
.Fields("编号") = txtNumber
.Fields("客户名") = txtUser
.Fields("日期") = Date & " " & Format(Time, "hh:nn")
.Update
strSQL = "Create Table " & txtNumber _
& "( 编号 nchar(6) primary key, 数量 Smallmoney not null)"
Set objCom = New Command
Set objCom.ActiveConnection = Drug_Store.DataCon
objCom.CommandText = strSQL
objCom.CommandType = adCmdText
objCom.Execute
MsgBox txtUser & "购物车创建成功!编号:" & txtNumber, _
vbInformation, "创建购物车"
Set objCom = Nothing
End With
End If
Exit Sub
DoError:
MsgBox Err.Description
End Sub
Private Sub cmdRefresh_Click()
Dim strNum As String
With Drug_Store.rsShoppingCars
If .State = adStateClosed Then .Open
If .RecordCount < 1 Then
strNum = Format(Date, "yymmdd") & "00001"
Else
.MoveLast
strNum = Right(.Fields("编号"), 5)
strNum = Format(Val(strNum) + 1, "00000")
strNum = Format(Date, "yymmdd") & strNum
End If
End With
txtNumber = "T" & strNum
txtUser = ""
txtUser.SetFocus
End Sub
Private Sub Form_Load()
Dim strNum As String
With Drug_Store.rsShoppingCars
If .State = adStateClosed Then .Open
.Requery
.Filter = "日期 Like '" & Date & "%'"
If .EOF Then
strNum = Format(Date, "yymmdd") & "00001"
Else
.MoveLast
strNum = Right(.Fields("编号"), 5)
strNum = Format(Val(strNum) + 1, "00000")
strNum = Format(Date, "yymmdd") & strNum
End If
End With
txtNumber = "T" & strNum
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -