VERSION 5.00
Begin VB.Form frmYWYSetup1
BorderStyle = 3 'Fixed Dialog
Caption = "业务员设置信息"
ClientHeight = 4140
ClientLeft = 45
ClientTop = 330
ClientWidth = 5790
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4140
ScaleWidth = 5790
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame1
Caption = "业务员设置:"
Height = 3372
Left = 120
TabIndex = 4
Top = 120
Width = 5532
Begin VB.TextBox txtItem
Height = 1440
Index = 6
Left = 1200
MaxLength = 80
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 17
Top = 1800
Width = 4092
End
Begin VB.TextBox txtItem
Height = 276
Index = 5
Left = 240
MaxLength = 10
ScrollBars = 2 'Vertical
TabIndex = 16
Top = 2400
Visible = 0 'False
Width = 732
End
Begin VB.TextBox txtItem
Height = 276
Index = 4
Left = 1200
MaxLength = 18
ScrollBars = 2 'Vertical
TabIndex = 15
Top = 1440
Width = 4092
End
Begin VB.TextBox txtItem
Height = 276
Index = 3
Left = 1200
MaxLength = 40
ScrollBars = 2 'Vertical
TabIndex = 14
Top = 1080
Width = 4092
End
Begin VB.TextBox txtItem
Height = 276
Index = 2
Left = 3720
MaxLength = 20
ScrollBars = 2 'Vertical
TabIndex = 12
Top = 720
Width = 1572
End
Begin VB.ComboBox Combo1
Height = 288
Index = 0
Left = 1200
Style = 2 'Dropdown List
TabIndex = 10
Top = 720
Width = 1572
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1200
MaxLength = 8
TabIndex = 0
Top = 360
Width = 1572
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 3720
MaxLength = 20
TabIndex = 1
Top = 360
Width = 1572
End
Begin VB.Label Label2
Caption = "备注信息:"
Height = 252
Index = 10
Left = 360
TabIndex = 13
Top = 1800
Width = 1092
End
Begin VB.Label Label2
Caption = "身份证号码:"
Height = 252
Index = 8
Left = 360
TabIndex = 11
Top = 1440
Width = 1092
End
Begin VB.Label Label2
Caption = "家庭住址:"
Height = 252
Index = 7
Left = 360
TabIndex = 9
Top = 1080
Width = 1092
End
Begin VB.Label Label2
Caption = "联系电话:"
Height = 252
Index = 6
Left = 2880
TabIndex = 8
Top = 720
Width = 1092
End
Begin VB.Label Label2
Caption = "业务员类别:"
Height = 252
Index = 5
Left = 360
TabIndex = 7
Top = 720
Width = 1092
End
Begin VB.Label Label2
Caption = "业务员编号:"
Height = 252
Index = 0
Left = 360
TabIndex = 6
Top = 360
Width = 1092
End
Begin VB.Label Label2
Caption = "业务员姓名:"
Height = 252
Index = 1
Left = 2880
TabIndex = 5
Top = 360
Width = 1092
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 3000
TabIndex = 3
Top = 3600
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 1560
TabIndex = 2
Top = 3600
Width = 1215
End
End
Attribute VB_Name = "frmYWYSetup1"
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 4
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "业务员编号"
Case 1
sMeg = "业务员姓名"
Case 2
sMeg = "联系电话"
Case 3
sMeg = "家庭住址"
Case 4
sMeg = "身份证号码"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Not IsNumeric(Trim(txtItem(4))) Then
sMeg = "身份证号码"
sMeg = sMeg & "请输入数字!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(4).SetFocus
Exit Sub
End If
If Trim(Combo1(0)) = "" Then
sMeg = "请选择业务员类别"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Combo1(0).SetFocus
Exit Sub
End If
'添加判断是否有相同的ID记录
If gintYWYSmode = 1 Then
txtSQL = "select * from dm_ywy 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_ywy where dm ='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "execute ywy_setup '"
For intCount = 0 To 1
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
txtSQL = txtSQL & Trim(Combo1(0)) & "','"
For intCount = 2 To 5
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
txtSQL = txtSQL & Trim(txtItem(6)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If gintYWYSmode = 1 Then
MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
For intCount = 0 To 6
txtItem(intCount) = ""
Next intCount
mblChange = False
Unload frmYWYSetup
frmYWYSetup.txtSQL = "select * from dm_ywy"
frmYWYSetup.Show
ElseIf gintYWYSmode = 2 Then
Unload Me
Unload frmYWYSetup
frmYWYSetup.txtSQL = "select * from dm_ywy"
frmYWYSetup.Show
End If
End Sub
Private Sub Combo1_Change(Index As Integer)
mblChange = True
End Sub
Private Sub Combo1_Click(Index As Integer)
Dim mrcd As ADODB.Recordset
Dim MsgText As String
If Index = 0 Then
If Not (Trim(Combo1(0) = "")) Then
txtSQL = "select * from dm_ywylb where lb = '" & Trim(Combo1(0)) & "'"
Set mrcd = ExecuteSQL(txtSQL, MsgText)
If Not mrcd.EOF Then
txtItem(5) = mrcd.Fields(0)
End If
mrcd.Close
End If
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 gintYWYSmode = 1 Then
Me.Caption = Me.Caption & "添加"
For i = 0 To 6
txtItem(i).Text = ""
Next i
ElseIf gintYWYSmode = 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
For intCount = 2 To 6
txtItem(intCount) = .Fields(intCount + 1)
Next intCount
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
End If
Combo1(0).Clear
txtSQL = "select lb from dm_ywylb"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(0).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
mrcc.Close
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintYWYSmode = 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