标题: QC10 Demo 工作流定制实例 [打印本页] 作者: lq1107 时间: 2009-7-29 17:42 标题: QC10 Demo 工作流定制实例 ' Set UI properties of the given field
' Arguments:
' FieldName (string) - the name of the field
' fldIsRequired (boolean) - value of IsRequired property of the field
' fldIsVisible (boolean) - value of IsVisible property of the field
' fldPageNo (number) - value of PageNo property of the field
' fldViewOrder (number) - value of ViewOrder property of the field
Sub SetFieldProperties(FieldName, fldIsRequired, fldIsVisible, fldPageNo, fldViewOrder)
' Verify the Severity and Priority values correspondance to defect Category
Function Verify_PriorityByCategory
Select Case Fields("BG_USER_05").Value
' The 'Functionality Suggestion' must have the Severity and Priority <= 3 - High
Case "Functionality Suggestion"
If Not Fields("BG_SEVERITY").IsNull And _
Fields("BG_SEVERITY").Value <> "3-High" And _
Fields("BG_SEVERITY").Value <> "2-Medium" And _
Fields("BG_SEVERITY").Value <> "1-Low" Then
ReportError "The 'Functionality Suggestion' <Severity> should be '3-High' or lower."
Verify_PriorityByCategory = False
Exit Function
End If
If Not Fields("BG_PRIORITY").IsNull And _
Fields("BG_PRIORITY").Value <> "3-High" And _
Fields("BG_PRIORITY").Value <> "2-Medium" And _
Fields("BG_PRIORITY").Value <> "1-Low" Then
ReportError "The 'Functionality Suggestion' <Priority> should be '3-High' or lower."
Verify_PriorityByCategory = False
Exit Function
End If
Case "UI Suggestion"
If Not Fields("BG_SEVERITY").IsNull And _
Fields("BG_SEVERITY").Value <> "2-Medium" And _
Fields("BG_SEVERITY").Value <> "1-Low" Then
ReportError "The 'UI Suggestion' <Severity> should be '2-Medium' or lower."
Verify_PriorityByCategory = False
Exit Function
End If
If Not Fields("BG_PRIORITY").IsNull And _
Fields("BG_PRIORITY").Value <> "2-Medium" And _
Fields("BG_PRIORITY").Value <> "1-Low" Then
ReportError "The 'UI Suggestion' <Priority> should be '2-Medium' or lower."
Verify_PriorityByCategory = False
Exit Function
End If
Case "Security Issue"
If Not Fields("BG_SEVERITY").IsNull And _
Fields("BG_SEVERITY").Value <> "3-High" And _
Fields("BG_SEVERITY").Value <> "4-Very High" And _
Fields("BG_SEVERITY").Value <> "5-Urgent" Then
ReportError "The 'Security Issue' <Severity> should be '3-High' or higher."
Verify_PriorityByCategory = False
Exit Function
End If
If Not Fields("BG_PRIORITY").IsNull And _
Fields("BG_PRIORITY").Value <> "3-High" And _
Fields("BG_PRIORITY").Value <> "4-Very High" And _
Fields("BG_PRIORITY").Value <> "5-Urgent" Then
ReportError "The 'Security Issue' <Priority> should be '3-High' or higher."
Verify_PriorityByCategory = False
Exit Function
End If
Case Else
End Select
Verify_PriorityByCategory = True
End Function
' Report error (message box) to the user
Sub ReportError(Msg)
MsgBox Msg, vbCritical + vbOKOnly, "Workflow Error"
End Sub
'**********************************************************
Sub Bug_New
Fields = Bug_Fields
'********************************************
'Enter code to be executed before opening a new bug form
' Set fields layout in the Add Defect form
AddDefect_SetFieldsLayout
' Set default values for the fields
AddDefect_SetDefaultValues
'********************************************
End Sub
Sub Bug_FieldChange(FieldName)
Fields = Bug_Fields
'********************************************
'Enter code to be executed after a bug field is changed
' Set RDComments_IsChanged flag if the R&D Comments field was changed
If FieldName = "BG_DEV_COMMENTS" Then
RDComments_IsChanged = True
' Set Status_IsChanged flag if the Status was changed to 'Rejected' or 'Reopen'
ElseIf FieldName = "BG_STATUS" Then
If Fields("BG_STATUS").Value = "Rejected" Or Fields("BG_STATUS").Value = "Reopen" Then
Status_IsChanged = True
Else
Status_IsChanged = False
End If
End If
'********************************************
WizardListCust ' Added by wizard
End Sub
Sub Bug_MoveTo
Fields = Bug_Fields
'********************************************
'Enter code to be executed after another bug receives focus
DefectDetails_SetFieldsLayout
' When moving to the defect, its R&D Comments and Status fields were not changed yet
RDComments_IsChanged = False
Status_IsChanged = False
'********************************************
WizardListCust ' Added by wizard
End Sub
Function Bug_CanPost
Fields = Bug_Fields
Bug_CanPost = True
'********************************************
'Enter code to be executed before current bug is posted
'if you want to abort posting, use Bug_CanPost = False
' For new defect (that was not submited yet, BG_BUG_ID is always Null
' This can be used to perform diferent verifications for defects
If Fields("BG_BUG_ID").IsNull Then
' Verify the constrains for the new defect before submit
Bug_CanPost = AddDefect_VerifyConstrains
Else
If Status_IsChanged And Not RDComments_IsChanged Then
ReportError "You must provide the explanation in <R&D Comments>" & _
" when defect <Status> is changed to '" & Fields("BG_STATUS").Value & "'"
Bug_CanPost = False
End If
End If
' Verify the Severity and Priority accordance to defect Category
If Bug_CanPost Then
Bug_CanPost = Verify_PriorityByCategory
End If
'********************************************
If Not Bug_CanPost Then
Bug_CanPost = False
Exit Function
End If
'**********************************************************作者: 愤怒的黄瓜 时间: 2009-7-31 11:35
辛苦,从帮助里抠下来并都放在一起的实例……
呵呵,有参考价值。作者: 橙子 时间: 2009-8-5 15:37
辛苦作者: peterz 时间: 2009-8-5 16:22
不错。有机会学习下。