?? frmkhlb1.frm
字號:
VERSION 5.00
Begin VB.Form frmKHLB1
BorderStyle = 3 'Fixed Dialog
Caption = "會員類別設置信息"
ClientHeight = 2220
ClientLeft = 45
ClientTop = 330
ClientWidth = 5880
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2220
ScaleWidth = 5880
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame1
Caption = "會員類別設置:"
Height = 1455
Left = 120
TabIndex = 4
Top = 120
Width = 5655
Begin VB.TextBox txtItem
Height = 270
Index = 3
Left = 960
MaxLength = 80
ScrollBars = 2 'Vertical
TabIndex = 11
Top = 960
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 315
Index = 0
Left = 960
Style = 2 'Dropdown List
TabIndex = 9
Top = 600
Width = 1575
End
Begin VB.TextBox txtItem
Height = 270
Index = 2
Left = 3480
MaxLength = 80
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 600
Width = 2055
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 960
MaxLength = 8
TabIndex = 0
Top = 240
Width = 1572
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 3480
MaxLength = 20
TabIndex = 1
Top = 240
Width = 2052
End
Begin VB.Label Label2
Caption = "折扣比例:"
Height = 255
Index = 3
Left = 120
TabIndex = 12
Top = 960
Width = 1095
End
Begin VB.Label Label2
Caption = "類 別:"
Height = 255
Index = 2
Left = 120
TabIndex = 10
Top = 600
Width = 1095
End
Begin VB.Label Label2
Caption = "最少金額:"
Height = 255
Index = 10
Left = 2640
TabIndex = 8
Top = 600
Width = 1095
End
Begin VB.Label Label2
Caption = "類別編號:"
Height = 252
Index = 0
Left = 120
TabIndex = 6
Top = 240
Width = 1092
End
Begin VB.Label Label2
Caption = "類別名稱:"
Height = 252
Index = 1
Left = 2640
TabIndex = 5
Top = 240
Width = 1092
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 3000
TabIndex = 3
Top = 1680
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 1560
TabIndex = 2
Top = 1680
Width = 1215
End
End
Attribute VB_Name = "frmKHLB1"
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 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "類別編號"
Case 1
sMeg = "類別名稱"
Case 2
sMeg = "最少金額"
Case 3
sMeg = "折扣比例"
End Select
sMeg = sMeg & "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Trim(Combo1(0)) = "" Then
MsgBox "請選擇種類!", vbOKOnly + vbExclamation, "警告"
Combo1(0).SetFocus
Exit Sub
End If
For intCount = 2 To 3
If Not IsNumeric(Trim(txtItem(intCount))) Then
MsgBox "請輸入數字!", vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
'添加判斷是否有相同的ID記錄
If gintKHLBmode = 1 Then
txtSQL = "select * from dm_khlb where lbcode ='" & 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_khlb where lbcode ='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新記錄
txtSQL = "insert dm_khlb values ('"
For intCount = 0 To 3
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
txtSQL = txtSQL & Trim(Combo1(0).ItemData(Combo1(0).ListIndex)) & "')"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If gintKHLBmode = 1 Then
MsgBox "添加記錄成功!", vbOKOnly + vbExclamation, "添加記錄"
For intCount = 0 To 3
txtItem(intCount) = ""
Next intCount
mblChange = False
Unload frmKHLB
frmKHLB.txtSQL = "select * from dm_khlb"
frmKHLB.Show
ElseIf gintKHLBmode = 2 Then
Unload Me
Unload frmKHLB
frmKHLB.txtSQL = "select * from dm_khlb"
frmKHLB.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
If gintKHLBmode = 1 Then
Me.Caption = Me.Caption & "添加"
For i = 0 To 3
txtItem(i).Text = ""
Next i
Combo1(0).Clear
ElseIf gintKHLBmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 3
txtItem(intCount) = .Fields(intCount)
Next intCount
If .Fields(4) = 1 Then
Combo1(0).AddItem "團體客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = .Fields(4)
Combo1(0).ListIndex = 0
ElseIf .Fields(4) = 2 Then
Combo1(0).AddItem "個人客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = .Fields(4)
Combo1(0).ListIndex = 0
End If
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
End If
If Trim(Combo1(0)) = "團體客戶" Then
Combo1(0).AddItem "個人客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = 2
ElseIf Trim(Combo1(0)) = "個人客戶" Then
Combo1(0).AddItem "團體客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = 1
Else
Combo1(0).AddItem "團體客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = 1
Combo1(0).AddItem "個人客戶"
Combo1(0).ItemData(Combo1(0).NewIndex) = 2
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintWZLBSmode = 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 + -