📄 frmjobtypecard.frm
字号:
On Error GoTo ErrHandle
' SetHelpID hwnd, 30016
Utility.LoadFormResPicture Me
mblnIsChanged = False
' SendKeys "%{C}"
' frmTpJobList.IsShowCard(0) = True
Exit Sub
ErrHandle:
edtErrReturn = Errors.ErrorsDeal
If edtErrReturn = edtResume Then
Resume
Else
On Error Resume Next
Unload Me
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim intMsgReturn As Integer, strMess As String
If UnloadMode <> vbFormControlMenu Then Exit Sub
If Trim(txtInput(0).Text & txtInput(1).Text) = "" Then Exit Sub
If mblnIsChanged Then
If mblnIsNew Then
strMess = "您要保存新增的工程类型"
If txtInput(0).Text <> "" Then
strMess = strMess & "“" & txtInput(0).Text & "”"
End If
If txtInput(1).Text <> "" Then
strMess = strMess & "“" & txtInput(1).Text & "”"
End If
strMess = strMess & "吗?"
Else
strMess = "“" & txtInput(0).Text & "”" & " " _
& "“" & txtInput(1).Text & "”工程类型已被修改,是否保存?"
End If
intMsgReturn = ShowMsg(hwnd, strMess, vbQuestion + vbYesNoCancel, Caption)
If intMsgReturn = vbYes Then
Cancel = Not SaveCard
ElseIf intMsgReturn = vbCancel Then
Cancel = True
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
' frmTpJobList.IsShowCard(0) = False
mblnIsChanged = False
Utility.UnLoadFormResPicture Me
End Sub
Private Sub Form_Paint()
FrameBox Me.hwnd, 150, 150, 4365, 1990
End Sub
Private Sub cmdOK_Click(Index As Integer)
Dim strNextCode As String
Select Case Index
Case 0 '确定
If SaveCard Then Unload Me
Case 1 '取消
Unload Me
Case 2 '下一个
If SaveCard Then
strNextCode = GetNextCode(txtInput(0).Text)
' mlngJobTypeID = 0
InitCard
txtInput(0).Text = strNextCode
txtInput(0).SetFocus
txtInput(0).SelStart = 0
txtInput(0).SelLength = Len(txtInput(0).Text)
End If
End Select
End Sub
Private Function MergeCode() As Boolean
MergeCode = DisplaceActivity("Job", "lngJobTypeID", mlngPCodeID, mlngJobTypeID)
End Function
Private Function SaveCard(Optional blnByAdd As Boolean = False) As Boolean
Dim blnMerge As Boolean 'NEW--转移业务 EDIT--合并代码
Dim intResult As Integer '编码检查结果:1--合法 -1--上级编码不存在 -2--编码已存在 -3--编码超长
Dim recJobType As rdoResultset, strSql As String
On Error GoTo ErrHandle
SaveCard = False
gclsBase.BaseWorkSpace.BeginTrans
If Trim$(txtInput(0).Text) = "" Then
ShowMsg hwnd, "工程类型编码不能为空!", vbExclamation, Caption
txtInput(0).SetFocus
GoTo ErrHandle
End If
If InStr(1, txtInput(0).Text, mstrOldCode & "-") <> 0 And Not mblnIsNew Then
ShowMsg hwnd, "工程类型不能修改为自己的下级工程类型!", vbExclamation, Caption
txtInput(0).SetFocus
GoTo ErrHandle
End If
If InStr(1, mstrOldCode, txtInput(0).Text & "-") <> 0 And Not mblnIsNew Then
ShowMsg hwnd, "工程类型不能修改为自己的上级工程类型!", vbExclamation, Caption
txtInput(0).SetFocus
GoTo ErrHandle
End If
If Trim$(txtInput(1).Text) = "" Then
ShowMsg hwnd, "工程类型名称不能为空!", vbExclamation, Caption
txtInput(1).SetFocus
GoTo ErrHandle
End If
intResult = CodeCheck("JobType", "strJobTypeCode", "lngJobTypeID", _
mblnIsNew, txtInput(0).Text, txtInput(1).Text, mstrOldCode, _
mstrOldFullName, mstrFullName, mlngPCodeID, mblnPIsDetail, mblnPIsInActive, _
mblnIsDetail)
' intResult = CodeCheck
If intResult = -1 Then
If mblnIsNew Then
If Not blnByAdd Then
ShowMsg hwnd, "“" & Trim$(txtInput(0).Text) & "“的上级工程类型" _
& "不存在,请先增加上级工程类型”" & CodePrefix(txtInput(0).Text) & "“", vbExclamation, Caption
End If
Else
ShowMsg hwnd, "“" & Trim$(txtInput(0).Text) & "“的上级工程类型" _
& "不存在,请重新修改工程类型”" _
& Trim$(txtInput(0).Text) & "“", vbExclamation, Caption
End If
txtInput(0).SetFocus
GoTo ErrHandle
ElseIf intResult = -2 Then
If mblnIsNew Then
If Not blnByAdd Then
ShowMsg hwnd, "工程类型编码“" & Trim$(txtInput(0).Text) _
& "”已经存在,请重新录入工程类型编码", vbExclamation, Caption
txtInput(0).SetFocus
End If
GoTo ErrHandle
Else
If Not mblnPIsDetail Or Not mblnIsDetail Then
ShowMsg hwnd, "工程类型“" & mstrOldCode & "”与工程类型“" _
& Trim$(txtInput(0).Text) & "”不能合并,请重新修改工程类型编码“" _
& Trim$(txtInput(0).Text) & "“", vbExclamation, Caption
mlngPCodeID = 0
txtInput(0).SetFocus
GoTo ErrHandle
Else
If ShowMsg(hwnd, "是否将工程类型“" & mstrOldCode & "”与“" _
& Trim$(txtInput(0).Text) & "”进行合并?", vbQuestion + vbYesNo, _
Caption) = vbNo Then
txtInput(0).SetFocus
GoTo ErrHandle
Else
blnMerge = True
End If
End If
End If
ElseIf intResult = -3 Then
If Not blnByAdd Then
ShowMsg hwnd, "工程类型编码太长,请重新修改编码!", vbExclamation, Caption
txtInput(0).SetFocus
End If
GoTo ErrHandle
Else
If mblnIsNew And mblnPIsDetail Then
If CodeUsed(mlngPCodeID) Then
If Not blnByAdd Then
If ShowMsg(hwnd, "工程类型“" & CodePrefix(txtInput(0).Text) & "”是一个已经发生业务的末级工程类型," _
& "是否在该工程类型下新增明细工程类型“" & Trim$(txtInput(0).Text) & "”," _
& "并将发生的所有业务转到新增的明细工程类型?", vbQuestion + vbYesNo, _
Caption) = vbNo Then
txtInput(0).SetFocus
GoTo ErrHandle
Else
blnMerge = True
End If
Else
blnMerge = True
End If
End If
End If
End If
' If CheckSameName("JobType", "strJobTypeCode", txtInput(0).Text, _
' "strJobTypeName", txtInput(1).Text, "lngJobTypeID", _
' IIf(mblnIsNew, 0, mlngJobTypeID)) Then
' If Not blnByAdd Then
' ShowMsg hWnd, "已有同级工程类型使用了" & "“" & txtInput(1).Text & "“" & _
' ",请重新录入工程类型名称!", _
' vbExclamation, Caption
' txtInput(1).SetFocus
' End If
' recJobType.Close
' GoTo ErrHandle
' End If
mstrCode = Trim(txtInput(0).Text)
mstrName = Trim(txtInput(1).Text)
mblnIsDetail = True
mstrStartDate = Format(gclsBase.BaseDate, "YYYY-MM-DD")
mintLevel = stringCount(Trim(txtInput(0).Text), "-") + 1
If mblnIsNew Then
If mblnPIsDetail Then
If blnMerge Then '上级编码是已使用的末级编码,合并业务
If Not TransActivity(mlngPCodeID) Then GoTo ErrHandle
Else
strSql = "UPDATE JobType SET blnIsDetail=0 WHERE " _
& "lngJobTypeID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
mlngJobTypeID = GetNewID("JobType")
strSql = "INSERT INTO JobType(lngJobtypeID,strJobTypeCode,strJobTypeName," _
& "strFullName,intLevel,blnIsDetail," _
& "strStartDate) VALUES (" & mlngJobTypeID & ", '" & mstrCode & "','" & mstrName _
& "','" & mstrFullName & "'," _
& mintLevel & "," & IIf(mblnIsDetail, 1, 0) & ",'" & mstrStartDate & "')" '插入数据库
gclsBase.BaseDB.Execute strSql
If blnMerge Then mlngJobTypeID = mlngPCodeID
' strSql = "SELECT * FROM JobType WHERE strJobTypeCode='" & mstrCode & "'"
' Set recJobType = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
' mlngJobTypeID = recJobType!lngJobTypeID
' recJobType.Close
Else
'进行编码合并
If blnMerge Then
If Not MergeCode Then GoTo ErrHandle
strSql = "DELETE FROM JobType WHERE lngJobTypeID=" & mlngJobTypeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
Else
strSql = "UPDATE JobType SET strJobTypeCode='" & mstrCode _
& "',strJobTypeName='" & mstrName & "',strFullName='" & mstrFullName _
& "',intLevel =" & mintLevel _
& " WHERE lngJobTypeID=" & mlngJobTypeID
gclsBase.BaseDB.Execute strSql
If Not ChangeLowerCardCodeAndFullName("JobType", "strJobTypeCode", _
"strFullName", "lngJobTypeID", mstrOldCode, mstrOldFullName, mstrCode, _
mstrFullName, mintOldLevel, mintLevel) Then GoTo ErrHandle
' If Not ChangeLowerCardCodeAndFullName("JobType", "strJobTypeCode", _
"strFullName", mstrOldCode, mstrOldName, mstrCode, mstrName, "lngJobTypeID") _
Then GoTo ErrHandle
If mblnPIsDetail Then
strSql = "UPDATE JobType SET blnIsDetail=0 WHERE lngJobTypeID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
If Not ChangeHigherCardDetail("JobType", "strJobTypeCode", mstrOldCode) Then GoTo ErrHandle
End If
gclsBase.BaseWorkSpace.CommitTrans
SaveCard = True
mblnIsChanged = False
gclsSys.SendMessage Me.hwnd, Message.msgJobType
Exit Function
ErrHandle:
gclsBase.BaseWorkSpace.RollBacktrans
If InStr(Err.Description, "违反唯一约束条件") > 0 Then
If Not blnByAdd Then
ShowMsg hwnd, "已有同级工程类型使用了" & "“" & txtInput(1).Text & "“" & _
",请重新录入工程类型名称!", vbExclamation, Caption
txtInput(1).SetFocus
End If
End If
End Function
Private Function TransActivity(ByVal lngPID As Long) As Boolean
Dim intLevel As Integer
Dim recJobType As rdoResultset
Dim strSql As String, strFullName As String
strSql = "SELECT * FROM JobType WHERE lngJobTypeID=" & lngPID
Set recJobType = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
With recJobType
mblnIsDetail = False
mintLevel = !intLevel
mstrStartDate = !strStartDate
mstrCode = !strJobTypeCode
mstrName = !strJobTypeName
strFullName = !strFullName
End With
recJobType.Close
intLevel = stringCount(Trim(txtInput(0).Text), "-") + 1
strSql = "UPDATE JobType SET strJobTypeCode='" & Trim(txtInput(0).Text) _
& "',strJobTypeName='" & Trim(txtInput(1).Text) & "',strFullName='" & mstrFullName _
& "'intLevel =" & intLevel & ",strStartDate='" & Format(Date, "YYYY-MM-DD") _
& "' WHERE lngJobTypeID=" & lngPID
TransActivity = gclsBase.ExecSQL(strSql)
If TransActivity Then mstrFullName = strFullName
End Function
Private Sub txtInput_Change(Index As Integer)
Dim strErr As String
If Index = 0 Then
strErr = "'""|?` ~!^*"
Else
strErr = "'""|?`~-!^*"
End If
If ContainErrorChar(txtInput(Index).Text, strErr) Then
BKKEY txtInput(Index).hwnd
End If
If Not mblnIsInit Then mblnIsChanged = True
End Sub
Private Sub txtInput_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 0 Then
If InStr("'""|?`~ !^*", Chr(KeyAscii)) > 0 Then KeyAscii = 0
Else
If InStr("'""|?`~-!^*", Chr(KeyAscii)) > 0 Then KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -