public PXAction<FSEquipment> UpdateHours;
[PXUIField(DisplayName = Messages.UpdateHours, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(DisplayOnMainToolbar = false)]
public IEnumerable updateHours(PXAdapter adapter)
{
if (MaintenanceLogInfo.AskExt(UpdateHoursSetVisible, true) == WebDialogResult.OK)
{
DateTime date = MaintenanceLogInfo.Current.Date.GetValueOrDefault();
decimal hours = MaintenanceLogInfo.Current.Hours.GetValueOrDefault();
if (date == null)
{
// Acuminator disable once PX1051 NonLocalizableString [Justification]
MaintenanceLogInfo.Cache.RaiseExceptionHandling<FSMaintenanceLogInfo.date>(
MaintenanceLogInfo.Current,
date,
new PXSetPropertyException(Messages.DateCannotBeEmpty)
);
return adapter.Get();
}
if (hours < 0)
{
// Acuminator disable once PX1051 NonLocalizableString [Justification]
MaintenanceLogInfo.Cache.RaiseExceptionHandling<FSMaintenanceLogInfo.hours>(
MaintenanceLogInfo.Current,
hours,
new PXSetPropertyException(Messages.HoursMustBeGreaterThanZero)
);
return adapter.Get();
}
AddOrUpdateMaintenanceLog(date, hours, false);
}
return adapter.Get();
}
When I enter a value < 0 in the Hours field, keep focus on that field, and click OK, the dialog closes without showing the validation error, even though I confirmed with debugging that the if (hours < 0) block is executed.
How can I prevent the dialog from closing and properly display the validation error when the value is invalid?