In Validate write of Table or Form Datasource
public boolean validateWrite()
{
boolean ret;
SCPProductPossessionCharges scpProductPossessionChargesloc;
if (SCPProductPossessionCharges.FromDate > SCPProductPossessionCharges.ToDate)
{
error("@GLS90176");
return false;
}
while select scpProductPossessionChargesloc
where scpProductPossessionChargesloc.ItemId == SCPProductPossessionCharges.ItemId
&& scpProductPossessionChargesloc.SCPPossessionCharges == SCPProductPossessionCharges.SCPPossessionCharges
&& scpProductPossessionChargesloc.RecId != SCPProductPossessionCharges.RecId
{
ret = element.checkDateOverlap(SCPProductPossessionCharges,scpProductPossessionChargesloc);
if(!ret)
{
error("@SCP353");//A record already exists for given date range
return ret;
}
}
ret = super();
return ret;
}
one public method checkDateOverlap(newrecord,existingRecord)
public boolean checkDateOverlap(
scpProductPossessionCharges _curVersion ,
scpProductPossessionCharges _checkAgainstVersion )
{
if ((_curVersion.ToDate >= _checkAgainstVersion.FromDate || !_curVersion.ToDate) &&
(_curVersion.FromDate <= _checkAgainstVersion.ToDate || !_checkAgainstVersion.ToDate))
{
return false;
}
if ( _checkAgainstVersion.ToDate >= _curVersion.FromDate
&& _checkAgainstVersion.FromDate <= _curVersion.ToDate)
{
return false;
}
return true;
}
public boolean validateWrite()
{
boolean ret;
SCPProductPossessionCharges scpProductPossessionChargesloc;
if (SCPProductPossessionCharges.FromDate > SCPProductPossessionCharges.ToDate)
{
error("@GLS90176");
return false;
}
while select scpProductPossessionChargesloc
where scpProductPossessionChargesloc.ItemId == SCPProductPossessionCharges.ItemId
&& scpProductPossessionChargesloc.SCPPossessionCharges == SCPProductPossessionCharges.SCPPossessionCharges
&& scpProductPossessionChargesloc.RecId != SCPProductPossessionCharges.RecId
{
ret = element.checkDateOverlap(SCPProductPossessionCharges,scpProductPossessionChargesloc);
if(!ret)
{
error("@SCP353");//A record already exists for given date range
return ret;
}
}
ret = super();
return ret;
}
one public method checkDateOverlap(newrecord,existingRecord)
public boolean checkDateOverlap(
scpProductPossessionCharges _curVersion ,
scpProductPossessionCharges _checkAgainstVersion )
{
if ((_curVersion.ToDate >= _checkAgainstVersion.FromDate || !_curVersion.ToDate) &&
(_curVersion.FromDate <= _checkAgainstVersion.ToDate || !_checkAgainstVersion.ToDate))
{
return false;
}
if ( _checkAgainstVersion.ToDate >= _curVersion.FromDate
&& _checkAgainstVersion.FromDate <= _curVersion.ToDate)
{
return false;
}
return true;
}