This topic is locked

Rules on dates II

6/15/2019 9:36:58 PM
ASPRunner.NET General questions
O
Onofre author

Good night
I want to thank you for the help in the previous issue, thank you very much. But now I have another question.
And with multiple dates? Example:
I have 3 dates,
Date 1, Date 2 and Date 3
Date 1 may be any date,

Date 2 can not be less than date 1 and

Data 3 may not be less than date 1 and not less than date 2.
Since date 3 will not always be filled in along with date 1 and date 2.
Can you help me?
Thankful.

jadachDevClub member 6/16/2019

Try this on before record added event

DateTime dt1 = DateTime.Parse(values["Date1"].ToString());

DateTime dt2 = DateTime.Parse(values["Date2"].ToString());

DateTime dt3 = DateTime.Parse(values["Date3"].ToString());
if (dt2.Date < dt1.Date)

{

message = "Date 2 can not be less than date 1";

return false;

}

else if (dt3.Date < dt1.Date)

{

message = "Date 3 can not be less than date 1";

return false;

}

else if (dt3.Date < dt2.Date)

{

message = "Date 3 can not be less than date 2";

return false;

}

else

{

return true;

}
O
Onofre author 6/16/2019

Good afternoon
Thank you for your help.
It worked when date 3 is filled, but when date 3 is blank an error occurs.

O
Onofre author 6/16/2019

Data 3 if it is empty error occurs. And not without pre it will be fulfilled.