Hi,
I add following code in my project to validate:
public partial class EmployeesEntity : EmployeesEntityBase
{
protected override bool OnValidateFieldValue(int fieldIndex, object value)
{
bool toReturn = true;
switch ((EmployeesFieldIndex)fieldIndex)
{
case EmployeesFieldIndex.BirthDate:
// birthday is valid if employee is adult.
if (value != null)
{
if (((DateTime)value).AddYears(18).CompareTo(DateTime.Now) > 0)
toReturn = false;
}
else
{
toReturn = true;
}
break;
case EmployeesFieldIndex.HireDate:
if (value != null)
{
toReturn = ((DateTime)value).CompareTo(DateTime.Now) > 0;
}
else
{
toReturn = true;
}
break;
default:
toReturn = true;
break;
}
return toReturn;
}
}
I want to cancel saving while validation failed. It can debug into above code while saving, but the action(save) did not cancel(Data saved into database).
How can i get the validate status while validation failed? Thanks.