Hi Community,
I found out that my validateWrite() is called, when I click on "New" (CommandButton) in my Form.
I wrote a method which shall check if a vehicle is available in a time period.
I called the method in my validateWrite() of the table. I ask myself how can I avoid that the validateWrite() is called, when I click "New" CommandButton.
It doesn't actually make any sense to me...
But there are either one Option, that when you click "New" the validateWrite() is called automatically!
Or that a record before wasn't really saved, but is still in the table, even though I didn't save it correctly but closed the form!
I listed You the methods.
public boolean validateWrite()
{
boolean available;
boolean ret;
;
available = this.checkVehicleAvailability();
if (available == true)
{
ret = super();
}
else
{
ret = false;
}
return ret;
}
checkVehicleAvailability()
public boolean checkVehicleAvailability()
{
SYCFMRentalTable rentTable;
boolean available;
;
while select VehicleId, StartDate, EndDate
from rentTable
where rentTable.VehicleID == this.VehicleID
{
if (this.StartDate >= rentTable.StartDate && this.StartDate <= rentTable.EndDate)
{
available = checkFailed("Vehicle already reserved"); //Labels
}
else if (this.EndDate >= rentTable.StartDate && this.EndDate <= rentTable.EndDate)
{
available = checkFailed("Vehicle already reserved"); //Labels
}
else if (rentTable.StartDate >= this.StartDate && rentTable.StartDate <= this.EndDate)
{
available = checkFailed("Vehicle already reserved"); //Labels
}
else
{
available = true;
}
}
return available;
}