Example Object Event Script: Quota Names
The following script generates a name for each quota for each contract product, using the format yyyy-MM, where:
- yyyy = 4-digit year (based on quota start date)
- MM = 2-digit month (based on quota start date)
For example, 2015-01 is the name of the first quota generated in the year 2015.
Copy
using System;
using Mincom.MineMarket.DAL;
using Mincom.MineMarket;
/// <summary>
/// Exposes events for Quota Events business objects
/// Version 1.0
/// Description: Sets the name of quota based on the start date on save
///
///* Modification date : 16/07/2015
///* Modified by : Datamine
///* Changes :
///* Support cases addressed : None
/// </summary>
public class QuotaEvents : IObjectEvents
{
public QuotaEvents() { }
public void ObjectPropertyChange(IEventsObject obj,
ObjectPropertyChangeEventArgs e)
{
}
public void ObjectBeforeSave(IEventsObject obj,
ObjectBeforeSaveEventArgs e)
{
Quota objQ = (Quota)obj;
if (!objQ.NameGenerated)
{
objQ.Name = objQ.StartDate.ToString("yyyy-MM");
objQ.NameGenerated = true;
}
}
public void ObjectBeforeDelete(IEventsObject obj,
ObjectBeforeDeleteEventArgs e)
{
}
}