using System.Data;
using System.Linq;
using MercatorUi.Engine.Gescom;
using MercatorUi.ICustomizers;
using MercatorApi;
namespace Billing
{
public class Customizer :
IBillingEngineCreated,
IBillingEngineClosed
{
public void BillingEngineCreated(BillingEngine billingEngine)
{
billingEngine.BeforeTransform += BillingEngine_BeforeTransform;
if (billingEngine.PiedsVRecord.NIVEAU_BO > 0) //Pour que Mercator ne modifie plus les prix alors que le document a été transformé partiellement.
billingEngine.LignesVRecords.Where(l => !string.IsNullOrWhiteSpace(l.ID_ARTICLE)).ToList().ForEach(l => Api.SmartReplace(l.DataRow, "NON_MOD_PRIX", true));
}
public void BillingEngineClosed(BillingEngine billingEngine)
{
billingEngine.BeforeTransform -= BillingEngine_BeforeTransform;
}
private void BillingEngine_BeforeTransform(object sender, BillingEngine.BeforeTransformEventArgs e)
{
BillingEngine billingEngine = (BillingEngine)sender;
if ((e.Direction == BillingEngine.TransformDirection.Up) && (billingEngine.Type == 3))
billingEngine.LignesVRecords.Where(l => !string.IsNullOrWhiteSpace(l.ID_ARTICLE)).ToList().ForEach(l => l.NON_MOD_PRIX = true);
}
}
}