📄 frmcustomertypelistcard.frm
字号:
SetHelpID hwnd, 30006
frmCustomerList.IsShowCard(1) = True
Set mclsMainControl = gclsSys.MainControls.Add(Me)
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)
frmCustomerList.IsShowCard(1) = False
mblnIsChanged = False
gclsSys.MainControls.Remove Me
Set mclsMainControl = Nothing
End Sub
Private Sub Form_Paint()
FrameBox Me.hwnd, 180, 180, 4335, 2000
End Sub
Private Sub cmdokcancel_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)
' mlngCustomerTypeID = 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("Customer", "lngCustomerTypeID", mlngPCodeID, mlngCustomerTypeID)
End Function
Private Function SaveCard() As Boolean
Dim blnMerge As Boolean 'NEW--转移业务 EDIT--合并代码
Dim intResult As Integer '编码检查结果:1--合法 -1--上级编码不存在 -2--编码已存在 -3--编码超长
'Dim recCustomerType As rdoResultset, strSql As String
Dim recCustomerType As rdoResultset, strSql As String
Dim intIsDetail As Integer, intIsInActive As Integer
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("CustomerType", "strCustomerTypeCode", "lngCustomerTypeID", _
mblnIsNew, txtInput(0).Text, txtInput(1).Text, mstrOldCode, _
mstrOldFullName, mstrFullName, mlngPCodeID, mblnPIsDetail, mblnPIsInActive, _
mblnIsDetail)
If intResult = -1 Then
If mblnIsNew Then
ShowMsg hwnd, "“" & Trim$(txtInput(0).Text) & "“的上级单位类型" _
& "不存在,请先增加上级单位类型”" & CodePrefix(txtInput(0).Text) & "“", _
vbExclamation, Caption
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
ShowMsg hwnd, "单位类型编码“" & Trim$(txtInput(0).Text) _
& "”已经存在,请重新录入单位类型编码", vbExclamation, Caption
txtInput(0).SetFocus
GoTo ErrHandle
Else
If Not mblnPIsDetail Or (mblnIsInActive <> mblnPIsInActive) Or Not mblnIsDetail Then
ShowMsg hwnd, "单位类型“" & mstrOldCode & "”与单位类型“" _
& Trim$(txtInput(0).Text) & "”不能合并,请重新修改单位类型编码“" _
& Trim$(txtInput(0).Text) & "“", vbExclamation, Caption
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
ShowMsg hwnd, "单位类型编码太长,请重新修改编码!", vbExclamation, Caption
txtInput(0).SetFocus
GoTo ErrHandle
Else
If mblnIsNew And mblnPIsDetail Then
If CodeUsed(mlngPCodeID) 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
End If
End If
End If
If CheckSameName("CustomerType", "strCustomerTypeCode", txtInput(0).Text, _
"strCustomerTypeName", txtInput(1).Text, "lngCustomerTypeID", _
IIf(mblnIsNew, 0, mlngCustomerTypeID)) Then
ShowMsg hwnd, "已有同级单位类型使用了" & "“" & txtInput(1).Text & "“" & _
",请重新录入单位类型名称!", vbExclamation, Caption
txtInput(1).SetFocus
recCustomerType.Close
GoTo ErrHandle
End If
mstrCode = txtInput(0).Text
mstrName = txtInput(1).Text
mblnIsInActive = (chkPause.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 CustomerType SET blnIsDetail = 0 WHERE " _
& "lngCustomerTypeID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
If Not mblnIsInActive And mblnPIsInActive And mlngPCodeID <> 0 Then
If ShowMsg(hwnd, "上级单位类型已经被停用,是否启用上级单位类型?", _
vbQuestion + vbYesNo, Caption) = vbNo Then
mblnIsInActive = True
strSql = "UPDATE CustomerType SET blnIsInActive = 1 WHERE " _
& "lngCustomerTypeID=" & mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
Else
mblnIsInActive = False
End If
End If
intIsDetail = IIf(mblnIsDetail, 1, 0)
intIsInActive = IIf(mblnIsInActive, 1, 0)
strSql = "INSERT INTO CustomerType(lngCustomerTypeID,strCustomerTypeCode,strCustomerTypeName," _
& "strFullName,blnIsInActive,intLevel,blnIsDetail," _
& "strStartDate) VALUES ( " & GetNewID("CustomerType") & ",'" & mstrCode & "','" & mstrName _
& "','" & mstrFullName & "'," & intIsInActive & "," _
& mintLevel & "," & intIsDetail & ",'" & mstrStartDate & "')" '插入数据库
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
strSql = "SELECT * FROM CustomerType WHERE strCustomerTypeCode='" & txtInput(0).Text & "'"
Set recCustomerType = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
mlngCustomerTypeID = recCustomerType!lngCustomerTypeID
recCustomerType.Close
Else
'进行编码合并
If blnMerge Then
If Not MergeCode Then GoTo ErrHandle
strSql = "DELETE FROM CustomerType WHERE lngCustomerTypeID=" & mlngCustomerTypeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
Else
intIsInActive = IIf(mblnIsInActive, 1, 0)
strSql = "UPDATE CustomerType SET strCustomerTypeCode='" & mstrCode _
& "',strCustomerTypeName='" & mstrName & "',strFullName='" & mstrFullName _
& "',blnIsInActive=" & intIsInActive & ",intLevel =" & mintLevel _
& " WHERE lngCustomerTypeID=" & mlngCustomerTypeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
If Not ChangeLowerCardCodeAndFullName("CustomerType", "strCustomerTypeCode", _
"strFullName", "lngCustomerTypeID", mstrOldCode, mstrOldFullName, mstrCode, _
mstrFullName, mintOldLevel, mintLevel) Then GoTo ErrHandle
If mblnIsInActive Then '本级停用时改变下级的停用属性
If Not ChangeLowerActive("CustomerType", "strCustomerTypeCode", mstrCode) _
Then GoTo ErrHandle
End If
If mblnPIsDetail Then
strSql = "UPDATE CustomerType SET blnIsDetail = 0 WHERE lngCustomerTypeID=" _
& mlngPCodeID
If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
End If
End If
If Not ChangeHigherCardDetail("CustomerType", "strCustomerTypeCode", mstrOldCode) Then GoTo ErrHandle
End If
If Not mblnIsInActive And mblnPIsInActive Then '本级是活动时改变上级的停用属性
If Not ChangeHigherActive("CustomerType", "strCustomerTypeCode", mstrCode) _
Then GoTo ErrHandle
End If
gclsBase.BaseWorkSpace.CommitTrans
SaveCard = True
mblnIsChanged = False
gclsSys.SendMessage Me.hwnd, Message.msgCustomerType
Exit Function
ErrHandle:
gclsBase.BaseWorkSpace.RollbackTrans
End Function
Private Function TransActivity(ByVal lngPID As Long) As Boolean
Dim intLevel As Integer
'Dim recCustomerType As Recordset
Dim recCustomerType As rdoResultset
Dim strSql As String, strFullName As String
strSql = "SELECT * FROM CustomerType WHERE lngCustomerTypeID=" & lngPID
'Set recCustomerType = gclsBase.BaseDB.OpenRecordset(strSql, dbOpenForwardOnly)
Set recCustomerType = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
With recCustomerType
mblnIsDetail = False
' mblnIsInActive = !blnIsInActive
mintLevel = !intLevel
mstrStartDate = !strStartDate
mstrCode = !strCustomerTypeCode
mstrName = !strCustomerTypeName
strFullName = !strFullName
End With
recCustomerType.Close
intLevel = stringCount(Trim(txtInput(0).Text), "-") + 1
strSql = "UPDATE CustomerType SET strCustomerTypeCode='" & txtInput(0).Text _
& "',strCustomerTypeName='" & txtInput(1).Text & "',strFullName='" & mstrFullName _
& "',blnIsInActive=" & chkPause.Value = vbChecked & ",intLevel =" & intLevel _
& ",strStartDate='" & Format(Date, "YYYY-MM-DD") _
& "' WHERE lngCustomerTypeID=" & 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 Function IsContinue() As Boolean
Dim lngResult As Long
IsContinue = True
If mblnIsChanged Then
Me.ZOrder 0
lngResult = ShowMsg(Me.hwnd, "上一次编辑的单位类型还未保存,是否继续编辑它?", vbYesNoCancel + vbQuestion, "单位类型卡片提示信息")
If lngResult = vbYes Then '继续编辑上一次的单位类型
SendKeys "%{C}"
Exit Function
Else
lngResult = ShowMsg(Me.hwnd, "是否保存上一次编辑的单位类型?", vbYesNoCancel + vbQuestion, "单位类型卡片提示信息")
If lngResult = vbYes Then '保存上一次编辑的单位类型
If Not SaveCard Then '保存失败
lngResult = ShowMsg(Me.hwnd, "上一次编辑的单位类型保存失败,是否继续编辑它?", vbYesNoCancel + vbQuestion, "单位类型卡片提示信息")
If lngResult = vbYes Then
SendKeys "%{C}"
Exit Function
End If
End If
End If
End If
End If
IsContinue = False
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -