📄 frmkhsetup1.frm
字号:
Index = 4
Left = 2880
TabIndex = 16
Top = 2520
Width = 1092
End
Begin VB.Label Label2
Caption = "车主姓名:"
Height = 252
Index = 9
Left = 240
TabIndex = 15
Top = 2160
Width = 1092
End
Begin VB.Label Label2
Caption = "备 注 信 息:"
Height = 252
Index = 10
Left = 240
TabIndex = 14
Top = 3600
Width = 1092
End
Begin VB.Label Label2
Caption = "开 户 银 行:"
Height = 252
Index = 11
Left = 240
TabIndex = 13
Top = 2880
Width = 1092
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 3120
TabIndex = 1
Top = 4920
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 1680
TabIndex = 0
Top = 4920
Width = 1215
End
End
Attribute VB_Name = "frmKHSetup1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
For intCount = 0 To 12
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "车牌号码"
Case 1
sMeg = "汽车型号"
Case 2
sMeg = "地址"
Case 3
sMeg = "邮政编码"
Case 4
sMeg = "电话号码"
Case 5
sMeg = "网址"
Case 6
sMeg = "车主姓名"
Case 7
sMeg = "电子邮件"
Case 8
sMeg = "税号"
Case 9
sMeg = "账号"
Case 10
sMeg = "开户银行"
Case 11
sMeg = "会员卡号"
Case 12
sMeg = "折扣比例"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Not IsNumeric(Trim(txtItem(12))) Then
sMeg = "这口比例"
sMeg = sMeg & "请输入数字!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(12).SetFocus
Exit Sub
End If
'添加判断是否有相同的ID记录
If gintKHSmode = 1 Then
txtSQL = "select * from dm_kh where dm ='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此车牌号码的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
'先删除已有记录
txtSQL = "delete from dm_kh where dm ='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "execute kh_setup '"
For intCount = 0 To 1
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
txtSQL = txtSQL & Trim(Combo1) & "','"
For intCount = 2 To 12
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
txtSQL = txtSQL & Trim(txtItem(13)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If gintKHSmode = 1 Then
MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
For intCount = 0 To 13
txtItem(intCount) = ""
Next intCount
mblChange = False
Unload frmKHSetup
frmKHSetup.txtSQL = "select * from dm_kh"
frmKHSetup.Show
ElseIf gintKHSmode = 2 Then
Unload Me
Unload frmKHSetup
frmKHSetup.txtSQL = "select * from dm_kh"
frmKHSetup.Show
End If
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim MsgText As String
Dim i As Integer
Dim mrcc As ADODB.Recordset
Combo1.Clear
If gintKHSmode = 1 Then
Me.Caption = Me.Caption & "添加"
For i = 0 To 13
txtItem(i).Text = ""
Next i
ElseIf gintKHSmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 1
txtItem(intCount) = .Fields(intCount)
Next intCount
Combo1.AddItem .Fields(2)
Combo1.ListIndex = 0
For intCount = 2 To 13
txtItem(intCount) = .Fields(intCount + 1)
Next intCount
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
End If
txtSQL = "select lb1 from dm_wzlb where lbcode <> 'r'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
If Trim(Combo1) <> "" Then
Do While Not mrcc.EOF
If Trim(Combo1) <> mrcc.Fields(0) Then
Combo1.AddItem mrcc.Fields(0)
End If
mrcc.MoveNext
Loop
Else
Do While Not mrcc.EOF
Combo1.AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
End If
mrcc.Close
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintGFSmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -