?? frmcustomer1.frm
字號:
VERSION 5.00
Begin VB.Form frmCustomer1
BorderStyle = 3 'Fixed Dialog
Caption = "客戶信息"
ClientHeight = 3516
ClientLeft = 48
ClientTop = 336
ClientWidth = 6384
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3516
ScaleWidth = 6384
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.TextBox txtNo
Height = 270
Left = 600
TabIndex = 15
TabStop = 0 'False
Top = 3000
Visible = 0 'False
Width = 735
End
Begin VB.Frame Frame1
Caption = "客戶信息:"
Height = 2772
Left = 120
TabIndex = 8
Top = 120
Width = 6132
Begin VB.ComboBox Combo1
Height = 288
Index = 1
Left = 1320
Style = 2 'Dropdown List
TabIndex = 4
Top = 1080
Width = 1572
End
Begin VB.ComboBox Combo1
Height = 288
Index = 0
Left = 4200
Style = 2 'Dropdown List
TabIndex = 1
Top = 360
Width = 1572
End
Begin VB.TextBox txtItem
Height = 1200
Index = 3
Left = 1320
MaxLength = 80
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 1440
Width = 4452
End
Begin VB.TextBox txtItem
Height = 270
Index = 2
Left = 4200
MaxLength = 20
TabIndex = 3
Top = 720
Width = 1572
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1320
MaxLength = 8
TabIndex = 0
Top = 360
Width = 1572
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1320
MaxLength = 20
TabIndex = 2
Top = 720
Width = 1572
End
Begin VB.Label Label2
Caption = "備 注 信 息:"
Height = 252
Index = 10
Left = 360
TabIndex = 14
Top = 1440
Width = 1212
End
Begin VB.Label Label2
Caption = "客 戶 類 型:"
Height = 252
Index = 7
Left = 360
TabIndex = 13
Top = 1080
Width = 1212
End
Begin VB.Label Label2
Caption = "聯 系 電 話:"
Height = 252
Index = 6
Left = 3120
TabIndex = 12
Top = 720
Width = 1212
End
Begin VB.Label Label2
Caption = "身份證號碼:"
Height = 252
Index = 5
Left = 360
TabIndex = 11
Top = 720
Width = 1212
End
Begin VB.Label Label2
Caption = "客 戶 姓 名:"
Height = 252
Index = 0
Left = 360
TabIndex = 10
Top = 360
Width = 1212
End
Begin VB.Label Label2
Caption = "客 戶 性 別:"
Height = 252
Index = 1
Left = 3120
TabIndex = 9
Top = 360
Width = 1212
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 3000
TabIndex = 7
Top = 3000
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 1560
TabIndex = 6
Top = 3000
Width = 1215
End
End
Attribute VB_Name = "frmCustomer1"
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 2
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "客戶姓名"
Case 1
sMeg = "身份證號碼"
Case 2
sMeg = "聯系電話"
End Select
sMeg = sMeg & "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
For intCount = 0 To 1
If Trim(Combo1(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "客戶性別"
Case 1
sMeg = "客戶類型"
End Select
sMeg = sMeg & "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Combo1(intCount).SetFocus
Exit Sub
End If
Next intCount
'判斷是否有相同內容的記錄
txtSQL = "select * from customerInfo where customerNO<>'" & Trim(txtNo) & "' and customerName='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已經存在相同客戶的記錄!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
'先刪除已有記錄
txtSQL = "delete from customerInfo where customerNO='" & Trim(txtNo) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新記錄
txtSQL = "select * from customerInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtNo)
mrc.Fields(1) = Trim(txtItem(0))
mrc.Fields(2) = Trim(Combo1(0))
For intCount = 1 To 2
mrc.Fields(intCount + 2) = Trim(txtItem(intCount))
Next intCount
mrc.Fields(5) = Trim(Combo1(1))
mrc.Fields(6) = Trim(txtItem(3))
mrc.Update
mrc.Close
If gintCmode = 1 Then
MsgBox "添加記錄成功!", vbOKOnly + vbExclamation, "添加記錄"
For intCount = 0 To 3
txtItem(intCount) = ""
Next intCount
mblChange = False
Unload frmCustomer
frmCustomer.txtSQL = "select * from customerInfo"
frmCustomer.Show
ElseIf gintCmode = 2 Then
Unload Me
Unload frmCustomer
frmCustomer.txtSQL = "select * from customerInfo"
frmCustomer.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 gintCmode = 1 Then
Me.Caption = Me.Caption & "添加"
txtNo = GetRkno()
ElseIf gintCmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
txtNo = .Fields(0)
txtItem(0) = .Fields(1)
For intCount = 1 To 2
txtItem(intCount) = .Fields(intCount + 2)
Next intCount
txtItem(3) = .Fields(6)
End With
End If
Me.Caption = Me.Caption & "修改"
End If
For intCount = 0 To 1
Combo1(intCount).Clear
Next intCount
Combo1(0).AddItem "男"
Combo1(0).AddItem "女"
txtSQL = "select DISTINCT ctypeName from customerType"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(1).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
mrcc.Close
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintCmode = 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 + -