?? frmdefinecard.frm
字號:
End If
intResult = CodeCheck(mstrTableName, "strCustomCode", "lngCustomID", _
mblnIsNew, txtInput(0).Text, txtInput(1).Text, mstrLastCode, _
mstrOldFullName, mstrFullName, mlngPCodeID, mblnPIsDetail, mblnPIsInActive, _
mblnIsDetail)
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 (mblnIsInActive <> mblnPIsInActive) Or Not mblnIsDetail Then
ShowMsg hwnd, "自定項目“" & mstrLastCode & "”與自定項目“" _
& Trim$(txtInput(0).Text) & "”不能合并,請重新修改自定項目編碼“" _
& Trim$(txtInput(0).Text) & "“", vbExclamation, Caption
mlngPCodeID = 0
txtInput(0).SetFocus
GoTo ErrHandle
Else
If ShowMsg(hwnd, "是否將自定項目“" & mstrLastCode & "”與“" _
& 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 CodeIsUsed(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(mstrTableName, "strCustomCode", txtInput(0).Text, _
' "strCustomName", txtInput(1).Text, "lngCustomID", _
' IIf(mblnIsNew, 0, mlngCustomID)) Then
' If Not blnByAdd Then
' ShowMsg hWnd, "已有同級自定項目使用了" & "“" & txtInput(1).Text & "“" & _
' ",請重新錄入自定項目名稱!", vbExclamation, Caption
' txtInput(1).SetFocus
' End If
' recCustom.Close
' GoTo ErrHandle
' End If
mstrCode = Trim(txtInput(0).Text)
mstrName = Trim(txtInput(1).Text)
mblnIsInActive = (chkStop.Value = vbChecked)
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 " & mstrTableName & " SET blnIsDetail=0 WHERE " _
& "lngCustomID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
If Not mblnIsInActive And mblnPIsInActive And mlngPCodeID <> 0 Then
If Not blnByAdd Then
If ShowMsg(hwnd, "上級自定義項目已經被停用,是否啟用上級自定義項目?", _
vbQuestion + vbYesNo, Caption) = vbNo Then
mblnIsInActive = True
strSql = "UPDATE " & mstrTableName & " SET blnIsInActive=1 WHERE " _
& "lngCustomID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
Else
mblnIsInActive = False
End If
Else
mblnIsInActive = False
End If
End If
mlngCustomID = GetNewID(mstrTableName)
strSql = "INSERT INTO " & mstrTableName & "(lngCustomID,strCustomCode,strCustomName," _
& "strFullName,blnIsInActive,intLevel,blnIsDetail," _
& "strStartDate) VALUES(" & mlngCustomID & ",'" & mstrCode & "','" & mstrName _
& "','" & mstrFullName & "'," & IIf(mblnIsInActive, 1, 0) & "," _
& mintLevel & "," & IIf(mblnIsDetail, 1, 0) & ",'" & mstrStartDate & "')" '插入數據庫
gclsBase.BaseDB.Execute strSql
If blnMerge Then mlngCustomID = mlngPCodeID
' If Not mblnIsInActive Then
' strSql = "SELECT * FROM " & mstrTableName & " WHERE strCustomCode='" & Trim(txtInput(0).Text) & "'"
' Set recCustom = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
' mlngCustomID = recCustom!lngCustomID
' recCustom.Close
' End If
Else
'進行編碼合并
If blnMerge Then
If Not MergeCode Then GoTo ErrHandle
strSql = "DELETE FROM " & mstrTableName & " WHERE lngCustomID=" & mlngCustomID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
Else
strSql = "UPDATE " & mstrTableName & " SET strCustomCode='" & mstrCode _
& "',strCustomName='" & mstrName & "',strFullName='" & mstrFullName _
& "',blnIsInActive=" & IIf(mblnIsInActive, 1, 0) & ",intLevel =" & mintLevel _
& " WHERE lngCustomID=" & mlngCustomID
gclsBase.BaseDB.Execute strSql
If Not ChangeLowerCardCodeAndFullName(mstrTableName, "strCustomCode", _
"strFullName", "lngCustomID", mstrLastCode, mstrOldFullName, mstrCode, _
mstrFullName, mintOldLevel, mintLevel) Then GoTo ErrHandle
' If Not ChangeLowerCardCodeAndFullName("Custom", "strCustomCode", _
"strFullName", mstrLastCode, mstrLastName, mstrCode, mstrName, "lngCustomID") _
Then GoTo ErrHandle
If mblnIsInActive Then '本級停用時改變下級的停用屬性
If Not ChangeLowerActive(mstrTableName, "strCustomCode", mstrCode) _
Then GoTo ErrHandle
End If
If mblnPIsDetail Then
strSql = "UPDATE " & mstrTableName & " SET blnIsDetail=0 WHERE lngCustomID=" _
& mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
If Not ChangeHigherCardDetail(mstrTableName, "strCustomCode", mstrLastCode) Then GoTo ErrHandle
End If
If Not mblnIsInActive And mblnPIsInActive Then '本級是活動時改變上級的停用屬性
If Not ChangeHigherActive(mstrTableName, "strCustomCode", mstrCode) _
Then GoTo ErrHandle
End If
gclsBase.BaseWorkSpace.CommitTrans
SaveCard = True
mblnIsChanged = False
Select Case CInt(mintCustomIndex)
Case 0
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom1
Case 1
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom2
Case 2
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom3
Case 3
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom4
Case 4
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom5
Case 5
gclsSys.SendMessage CStr(Me.hwnd), Message.msgCustom6
End Select
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 SelectTable(strTitleName As String) As Boolean
Dim strSql As String
Dim recSelect As rdoResultset
strSql = "SELECT strKey FROM Setting WHERE lngModuleID=8 AND strSetting='" _
& strTitleName & "'"
Set recSelect = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
If Not recSelect.EOF Then
mintCustomIndex = Mid(recSelect!strKey, 5, 1)
mstrTableName = "Custom" & mintCustomIndex
SelectTable = True
Else
SelectTable = False
End If
recSelect.Close
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 Function TransActivity(ByVal lngPID As Long) As Boolean
Dim intLevel As Integer
Dim recCustom As rdoResultset
Dim strSql As String, strFullName As String, strNotes As String
strSql = "SELECT * FROM " & mstrTableName & " WHERE lngCustomID=" & lngPID
Set recCustom = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
With recCustom
mblnIsDetail = False
' mblnIsInActive = !blnIsInActive
mintLevel = !intLevel
mstrStartDate = !strStartDate
mstrCode = !strCustomCode
mstrName = !strCustomName
strFullName = !strFullName
strNotes = !strNotes
End With
recCustom.Close
intLevel = stringCount(Trim(txtInput(0).Text), "-") + 1
strSql = "UPDATE " & mstrTableName & " SET strCustomCode='" & Trim(txtInput(0).Text) _
& "',strCustomName='" & Trim(txtInput(1).Text) & "',strFullName='" & mstrFullName _
& "',blnIsInActive=" & (chkStop.Value = vbChecked) & ",intLevel =" & intLevel _
& ",strNotes='" & mstrNotes & "',strStartDate='" _
& Format(Date, "YYYY-MM-DD") & "' WHERE lngCustomID=" & lngPID
TransActivity = gclsBase.ExecSQL(strSql)
If TransActivity Then
mstrFullName = strFullName
mstrNotes = strNotes
End If
End Function
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 + -