📄 frmmembertype.frm
字号:
VERSION 5.00
Begin VB.Form frmMemberType
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
BorderStyle = 1 'Fixed Single
Caption = "会员类型设置"
ClientHeight = 3840
ClientLeft = 45
ClientTop = 330
ClientWidth = 3330
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3840
ScaleWidth = 3330
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 5
Left = 1320
TabIndex = 5
Top = 2520
Width = 1815
End
Begin VB.CommandButton cmdExit
Appearance = 0 'Flat
Height = 435
Left = 1800
Picture = "frmMemberType.frx":0000
Style = 1 'Graphical
TabIndex = 12
Top = 3240
Width = 960
End
Begin VB.CommandButton cmdSave
Appearance = 0 'Flat
Height = 435
Left = 480
Picture = "frmMemberType.frx":14E4
Style = 1 'Graphical
TabIndex = 6
Top = 3240
Width = 945
End
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 4
Left = 1320
TabIndex = 4
Top = 2040
Width = 1815
End
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 3
Left = 1320
TabIndex = 3
Top = 1560
Width = 1815
End
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 2
Left = 1320
TabIndex = 2
Top = 1080
Width = 1815
End
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 1
Left = 1320
TabIndex = 1
Top = 600
Width = 1815
End
Begin VB.TextBox TxtFields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 0
Left = 1320
TabIndex = 0
Top = 120
Width = 1815
End
Begin VB.Label Label6
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "最多可借天数"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 13
Top = 2640
Width = 1095
End
Begin VB.Label Label5
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "最大借书数"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 0
TabIndex = 11
Top = 2160
Width = 1455
End
Begin VB.Label Label4
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "押金"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 10
Top = 1680
Width = 615
End
Begin VB.Label Label3
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "会费"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 9
Top = 1200
Width = 615
End
Begin VB.Label Label2
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "类型名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 8
Top = 720
Width = 735
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "类型"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 7
Top = 120
Width = 735
End
End
Attribute VB_Name = "frmMemberType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public blnAddNew As Boolean
Public intFlag As Integer
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub CmdSave_Click()
Dim i As Integer
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
On Error GoTo SaveErr
For i = 2 To 5
If Trim(TxtFields(i).Text) = "" Then
MsgBox "请输入数据!", vbInformation
Call setselect(TxtFields(i))
Exit Sub
End If
Next
If blnAddNew Then
If Trim(TxtFields(0).Text) = "" Or Trim(TxtFields(1).Text) = "" Or Trim(TxtFields(2).Text) = "" Or Trim(TxtFields(3).Text) = "" Then
MsgBox "编码、名称不能为空!", vbInformation
Exit Sub
End If
If CheckExist Then
MsgBox "此编码已存在,请修改。", vbInformation + vbOKOnly
Call setselect(TxtFields(0))
Exit Sub
End If
sqlstring = "Insert into MemberType (ChrType,ChrTypeName,DecTax,DecDeposit,IntMaxBorrow,IntMaxDay) values ('" & TxtFields(0).Text & "','" & (TxtFields(1).Text) & _
"'," & CDbl(TxtFields(2).Text) & "," & CDbl(TxtFields(3).Text) & "," & CInt(TxtFields(4).Text) & "," & CInt(TxtFields(5).Text) & ")"
cN.BeginTrans
cN.Execute (sqlstring)
cN.CommitTrans
Unload Me
Call frmFields.cmdRefresh_Click
Else
If Trim(TxtFields(0).Text) = "" Or Trim(TxtFields(1).Text) = "" Or Trim(TxtFields(2).Text) = "" Or Trim(TxtFields(3).Text) = "" Or Trim(TxtFields(3).Text) = "" Then
MsgBox "编码、名称不能为空!", vbInformation
Exit Sub
End If
sqlstring = "Update MemberType set ChrTypeName='" & TxtFields(1).Text & "', " & _
" DecTax=" & CDbl(TxtFields(2).Text) & ",DecDeposit=" & CDbl(TxtFields(3).Text) & ",IntMaxBorrow=" & CInt(TxtFields(4).Text) & ",IntMaxDay=" & CInt(TxtFields(5).Text) & " where ChrType='" & Trim(TxtFields(0).Text) & "'"
cN.BeginTrans
cN.Execute (sqlstring)
cN.CommitTrans
Unload Me
Call frmFields.cmdRefresh_Click
End If
Exit Sub
SaveErr:
cN.RollbackTrans
MsgBox "保存记录失败:" & err.Description, vbInformation
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call autoreturn(KeyCode)
End Sub
Private Function CheckExist() As Boolean
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
On Error GoTo err
sqlstring = "select * from MemberType where ChrType='" & Trim(TxtFields(0).Text) & "'"
rstmp.Open sqlstring, cN, adOpenKeyset, adLockReadOnly
If rstmp.EOF Then
CheckExist = False
Else
CheckExist = True
End If
Exit Function
err:
MsgBox "打开记录失败:" & err.Description, vbInformation
End Function
Private Sub TxtFields_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{TAB}"
Exit Sub
End If
End Sub
Private Sub txtFields_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case Index
Case 2, 3
KeyAscii = ValiText(KeyAscii, vbExpDecimal, "", TxtFields(Index).Text)
Case 4, 5
KeyAscii = ValiText(KeyAscii, vbExpInteger, "", TxtFields(Index).Text)
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -