Skip to content

clsEmployeeLeave

clsEmployeeLeave is a public class in SAIF.Business that inherits clsBusinessBase, implements ILoadable, and models an employee-leave record with leave-type, date-range, employee, and audit fields.

Purpose

  • Represents a single employee-leave row identified by EMPLOYEE_LEAVE_SEQ_NUM.
  • Creates new leave records with generated sequence numbers and system-type context.
  • Retrieves existing leave data and exposes related employee information and leave-type mappings.
  • Enforces required-field and date-range business rules before save operations.

Context

  • Namespace: SAIF.Business
  • Assembly/package: SAIF.Business

Public members

Member Signature Purpose
EmployeeLeaveSeqNum Public Property EmployeeLeaveSeqNum() As Decimal Gets or sets the employee-leave sequence number.
EmployeeEmplid Public Property EmployeeEmplid() As String Gets or sets the employee ID and clears the cached employee object when the value changes.
Employee Public ReadOnly Property Employee As clsEmployeeData Lazily retrieves and returns the related clsEmployeeData for EmployeeEmplid.
EmployeeName Public ReadOnly Property EmployeeName As String Returns the employee's formatted name when the employee is valid and active; otherwise returns the employee ID.
LeaveTypeCode Public Property LeaveTypeCode() As String Gets or sets the stored leave-type code.
LeaveType Public ReadOnly Property LeaveType As LeaveTypes Returns the mapped LeaveTypes enum value for LeaveTypeCode, defaulting to LeaveTypes.Leave when the code is empty.
LeaveDescription Public ReadOnly Property LeaveDescription() As String Returns the string form of the mapped leave type, or an empty string when no leave code is set.
BeginDate Public Property BeginDate() As Date Gets or sets the leave begin date through the backing clsSmartDate.
EndDate Public Property EndDate() As Date Gets or sets the leave end date through the backing clsSmartDate.
OriginalBeignDate Public ReadOnly Property OriginalBeignDate As Date Returns the original value captured by the begin-date clsSmartDate.
OriginalEndDate Public ReadOnly Property OriginalEndDate As Date Returns the original value captured by the end-date clsSmartDate.
SystemTypeCode Public ReadOnly Property SystemTypeCode() As String Returns the system-type code associated with the leave record.
CreateDate Public Property CreateDate() As Date Gets or sets the create date stored on the leave record.
CreateUser Public Property CreateUser() As String Gets or sets the create user stored on the leave record.
UpdateDate Public Property UpdateDate() As Date Gets or sets the update date through the backing clsSmartDate.
UpdateUser Public Property UpdateUser() As String Gets or sets the update user through the backing clsSmartString.
NewEmployeeLeave Public Shared Function NewEmployeeLeave(ByVal inDataportal As IDataPortalInfo, ByVal inSystemTypeCode As String) As clsEmployeeLeave Creates a new clsEmployeeLeave through the data-access layer using the supplied system type code.
GetEmployeeLeave Public Shared Function GetEmployeeLeave(ByVal inDataportal As IDataPortalInfo, ByVal inEmployeeLeaveSeqNum As Decimal, ByVal inEmployeeEmplid As String) As clsEmployeeLeave Retrieves an existing leave record through the data-access layer.

Behavioral notes

  • Employee lazy-loads clsEmployeeData with clsEmployeeData.GetDataByEmployeeID(MyCriteria.DataPortalInfo, _EmployeeEmplid, , True) and caches the result until EmployeeEmplid changes.
  • EmployeeName returns Employee.FormattedName only when the related employee is both valid and active.
  • Create assigns a new sequence from EMPLOYEE_LEAVE_SEQ, copies SystemTypeCode from criteria, stamps CreateDate with Today, and stores an uppercase trimmed CreateUser from the data portal user ID.
  • Insert and update operations call AddInsertUpdateParms, which sends EmployeeLeaveSeqNum, EmployeeEmplid, LeaveTypeCode, SystemTypeCode, BeginDate, and EndDate as request parameters.
  • AfterInsert, AfterUpdate, and AfterDelete all expect exactly one affected row; otherwise the object records an error message instead of marking itself old or new.
  • GetEmployeeLeave(ByVal inDataportal As IDataPortalInfo, ByVal inEmployeeLeaveSeqNum As Decimal, ByVal inEmployeeEmplid As String) accepts both sequence number and employee ID, but BeforeRetrieve adds only EmployeeLeaveSeqNum to the request.
  • Business rules require nonblank EmployeeEmplid and LeaveTypeCode, require both dates, require each date to be later than 01/01/1900 and no later than two years from today, require EndDate >= BeginDate, and require EndDate >= Today.

Constraints and usage notes

  • Instances are created through NewEmployeeLeave or retrieved through GetEmployeeLeave; the class's constructor is Protected Friend.
  • SystemTypeCode is read-only on the public surface and is set during create/load operations.
  • The request parameter lengths baked into this class are 11 for EmployeeEmplid, 5 for LeaveTypeCode, 5 for SystemTypeCode, and 30 for CreateUser/UpdateUser.
  • The property name is spelled OriginalBeignDate in source and documentation because that is the public member declared by the class.

Sources

  • Business\SAIF.Business\clsEmployeeLeave.vb