BioloMICS logo
×
BioloMICS Web Menu

VB trigger - Before insert - Order headers

 
Imports System
Imports System.Text
 
Imports CoreBaseLibrary
Imports CoreBaseLibrary.Config
Imports SharedClasses
Imports CoreUtilities
Imports CoreUtilities.Enums
Imports DatabaseConstants
 
Imports TriggerResultEnum = CoreUtilities.Enums.TriggerResultEnum
 
Imports MongoDB.Bson
 
Public Class Triggers
 
 
     Public Shared Function BeforeInsert(ByVal p_Record As TRecord) As TriggerResultEnum
          Dim sqlCo As TConnection = p_Record.SqlCo
          ' Group 8: "Student", they get 50% off
          Dim k as Int64 = 1
          Dim group as Int64 = 8
          Dim reductionLevel as Double = 0
          If ((k << group) And sqlCo.CurrentUserGroups()) <> 0 Then         
               reductionLevel = 0.5
          End If
          ' Group 7: "Internal", they get 100% off
          group = 7
          If ((k << group) And sqlCo.CurrentUserGroups()) <> 0 Then         
               reductionLevel = 1
          End If
         
          Dim totalReductionPrice = ctype(p_Record.m_Fields(WORLDID&TOTALPRICEID1234567000000189), TDField)
          totalReductionPrice.Value = totalReductionPrice.Value * (1 - reductionLevel)
 
          Return TriggerResultEnum.NoError                '     no error
     End Function
    
     End Class