📄 frmywygl_input.frm
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmYWYGL_Input
Caption = "业务员信息-新增"
ClientHeight = 3540
ClientLeft = 60
ClientTop = 345
ClientWidth = 5415
Icon = "frmYWYGL_Input.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3540
ScaleWidth = 5415
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
Height = 2715
Left = 150
TabIndex = 7
Top = 105
Width = 5070
Begin VB.TextBox txtEID
Height = 330
Left = 1260
MaxLength = 3
TabIndex = 0
Top = 300
Width = 1560
End
Begin VB.CheckBox chkQu
Caption = "Check1"
Height = 225
Left = 225
TabIndex = 13
Top = 2130
Value = 1 'Checked
Width = 210
End
Begin VB.CheckBox chkPian
Caption = "Check1"
Height = 195
Left = 225
TabIndex = 12
Top = 1665
Value = 1 'Checked
Width = 210
End
Begin MSDataListLib.DataCombo cboPost
Height = 330
Left = 1275
TabIndex = 2
Top = 1155
Width = 2325
_ExtentX = 4101
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin VB.TextBox txtName
Height = 330
Left = 1275
MaxLength = 8
TabIndex = 1
Top = 720
Width = 1560
End
Begin MSDataListLib.DataCombo cboPian
Height = 330
Left = 1275
TabIndex = 3
Top = 1605
Width = 2325
_ExtentX = 4101
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin MSDataListLib.DataCombo cboQu
Height = 330
Left = 1275
TabIndex = 4
Top = 2055
Width = 2325
_ExtentX = 4101
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin VB.Label lblPrompt
Caption = "编号:"
Height = 210
Index = 4
Left = 525
TabIndex = 14
Top = 360
Width = 540
End
Begin VB.Label lblPrompt
Caption = "管辖区:"
Height = 210
Index = 3
Left = 525
TabIndex = 11
Top = 2130
Width = 780
End
Begin VB.Label lblPrompt
Caption = "管辖片:"
Height = 210
Index = 2
Left = 525
TabIndex = 10
Top = 1680
Width = 780
End
Begin VB.Label lblPrompt
Caption = "岗位:"
Height = 210
Index = 1
Left = 525
TabIndex = 9
Top = 1245
Width = 540
End
Begin VB.Label lblPrompt
Caption = "姓名:"
Height = 210
Index = 0
Left = 525
TabIndex = 8
Top = 780
Width = 540
End
End
Begin VB.CommandButton cmdArray
Caption = "放弃"
Height = 360
Index = 1
Left = 1140
TabIndex = 6
Top = 2910
Width = 945
End
Begin VB.CommandButton cmdArray
Caption = "确定"
Height = 360
Index = 0
Left = 165
TabIndex = 5
Top = 2910
Width = 945
End
End
Attribute VB_Name = "frmYWYGL_Input"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public strTitle As String '标题参数
Public strEID As String '编号
Public strName As String '姓名
Public strPostID As String '岗位编号
Public strPID As String '片号
Public strQID As String '区号
Public blnIsEdit As Boolean '标志父窗体在调用本程序时是编辑还是新增
Dim blnEditFlag As Boolean '编辑标志,当对内容做任何改动时,该变量置为True
Dim adoPostRS As ADODB.Recordset '岗位记录集
Dim adoPianRS As ADODB.Recordset '片记录集
Dim adoQuRS As ADODB.Recordset '区记录集
Private Sub cboPian_Change()
blnEditFlag = True
Call FillQu(Me.cboPian.BoundText)
End Sub
Private Sub cboPian_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub cboPost_Change()
blnEditFlag = True
End Sub
Private Sub cboPost_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub cboQu_Change()
blnEditFlag = True
End Sub
Private Sub cboQu_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub chkPian_Click()
If chkPian.value = 0 Then
Me.cboPian.ListField = ""
Me.cboPian.BoundColumn = ""
Me.cboPian.Text = ""
Me.cboPian.Enabled = False
chkQu.value = 0
chkQu.Enabled = False
ElseIf chkPian.value = 1 Then
Set Me.cboPian.RowSource = adoPianRS
Me.cboPian.ListField = "PName"
Me.cboPian.BoundColumn = "PID"
Me.cboPian.Enabled = True
chkQu.Enabled = True
End If
Call chkQu_Click
End Sub
Private Sub chkQu_Click()
If chkQu.value = 0 Then
Me.cboQu.ListField = ""
Me.cboQu.BoundColumn = ""
Me.cboQu.Text = ""
Me.cboQu.Enabled = False
ElseIf chkQu.value = 1 Then
Set Me.cboQu.RowSource = adoQuRS
Me.cboQu.ListField = "QName"
Me.cboQu.BoundColumn = "QID"
Me.cboQu.Enabled = True
End If
End Sub
Private Sub cmdArray_Click(Index As Integer)
Select Case Index
Case 0 '确定
If Trim(Me.txtEID.Text) = "" Then
Warning "编号不能为空!!!"
Me.txtEID.SetFocus
Exit Sub
End If
If Trim(Me.txtName.Text) = "" Then
Warning "姓名不能为空!!!"
Me.txtName.SetFocus
Exit Sub
End If
If Trim(Me.cboPost.Text) = "" Then
Warning "岗位不能为空!!!"
Me.cboPost.SetFocus
Exit Sub
End If
If blnEditFlag Then '数据改动过
If Not blnIsEdit Then
If FindEID(Trim(Me.txtEID.Text)) Then
Warning "该编号已经存在,请重新选择一个!"
Me.txtEID.SetFocus
Exit Sub
End If
End If
strEID = Trim(Me.txtEID.Text)
strName = Trim(Me.txtName.Text)
strPostID = Me.cboPost.BoundText
strPID = Me.cboPian.BoundText
strQID = Me.cboQu.BoundText
End If
Case 1 '放弃
strEID = ""
strName = ""
strPostID = ""
strPID = ""
strQID = ""
Case Else
Warning "按扭功能未定义"
End Select
Unload Me
End Sub
Private Sub Form_Load()
'打开记录集
On Error GoTo errHandleOpen
Set adoPostRS = New ADODB.Recordset
Set adoPostRS.ActiveConnection = gConnect
adoPostRS.CursorLocation = adUseClient
adoPostRS.CursorType = adOpenForwardOnly
adoPostRS.LockType = adLockOptimistic
adoPostRS.Open "select PostID,PostName from Post"
Set adoPianRS = New ADODB.Recordset
Set adoPianRS.ActiveConnection = gConnect
adoPianRS.CursorLocation = adUseClient
adoPianRS.CursorType = adOpenForwardOnly
adoPianRS.LockType = adLockOptimistic
adoPianRS.Open "select PID,PName from Pian"
Set adoQuRS = New ADODB.Recordset
Set adoQuRS.ActiveConnection = gConnect
adoQuRS.CursorLocation = adUseClient
adoQuRS.CursorType = adOpenForwardOnly
adoQuRS.LockType = adLockOptimistic
adoQuRS.Open "select QID,QName from Qu where PID=''"
On Error GoTo 0
'设置控件关联
Set Me.cboPost.RowSource = adoPostRS
Me.cboPost.ListField = "PostName"
Me.cboPost.BoundColumn = "PostID"
Set Me.cboPian.RowSource = adoPianRS
Me.cboPian.ListField = "PName"
Me.cboPian.BoundColumn = "PID"
Set Me.cboQu.RowSource = adoQuRS
Me.cboQu.ListField = "QName"
Me.cboQu.BoundColumn = "QID"
'参数传递
Me.Caption = Trim(strTitle)
Me.txtEID.Text = strEID
Me.txtName.Text = strName
Me.cboPost.BoundText = strPostID
Me.cboPian.BoundText = strPID
Call FillQu(strPID)
Me.cboQu.BoundText = strQID
If blnIsEdit Then
Me.txtEID.Enabled = False
Else
Me.txtEID.Enabled = True
End If
'复位参数
strEID = ""
strName = ""
strPostID = ""
strPID = ""
strQID = ""
Me.txtEID.MaxLength = gEIDLen
Me.txtName.MaxLength = 8
blnEditFlag = False
Exit Sub
'-------错误处理---------
errHandleOpen:
Warning "记录集打开失败!" & Chr(13) & Err.Description
On Error GoTo 0
End Sub
Private Function FindEID(ByVal strTmpEID As String) As Boolean
Dim strSQL As String
Dim intNum As Integer
strSQL = "select count(*) from Employee where EID='" & strTmpEID & "'"
On Error GoTo ErrHandleExe
intNum = gConnect.Execute(strSQL).Fields(0)
On Error GoTo 0
If intNum > 0 Then
FindEID = True
Else
FindEID = False
End If
Exit Function
ErrHandleExe:
FindEID = True
Warning "对比已有编号时失败!" & Chr(13) & Err.Description
On Error GoTo 0
End Function
Private Sub txtEID_Change()
blnEditFlag = True
End Sub
Private Sub txtEID_GotFocus()
Call AutoSelectText(Me.txtEID)
End Sub
Private Sub txtEID_KeyPress(KeyAscii As Integer)
'只接收"0"--"9" , "<-" 键
Call IfEnterKeyMoveNext(KeyAscii)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
KeyAscii = 0
Beep
Exit Sub
End If
End Sub
Private Sub txtEID_LostFocus()
If Trim(Me.txtEID.Text) = "" Then Exit Sub
Me.txtEID.Text = String(gEIDLen - Len(Trim(Me.txtEID.Text)), "0") & Trim(Me.txtEID.Text)
End Sub
Private Sub txtName_Change()
blnEditFlag = True
End Sub
Private Sub txtName_GotFocus()
Call AutoSelectText(txtName)
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub FillQu(ByVal strPID As String)
'根据指定的片号,填充区列表框
On Error Resume Next
adoQuRS.Close
adoQuRS.Open "select QID,QName from Qu where PID='" & strPID & "'" & "order by QID"
On Error GoTo 0
Set Me.cboQu.RowSource = adoQuRS
Me.cboQu.ListField = "QName"
Me.cboQu.BoundColumn = "QID"
Me.cboQu.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -