show / hide menu

Validate Personal Leave Date

The employee should apply for leave and get that approved before taking the personal leave. So when a employee is applying for a personal leave, the date of leave should not be less than the current date. The company also has a restriction that the employee should not take any company restricted date in the personal leave.

So this rule when completed will display as:

DynamicGrid dgPersonal – Column Value Change Event fill trigger the following rule

Rule 1 : dgPersonal.ColIndex=2 & GridGetValue(dgPersonal,dgPersonal.RowIndex,2) <= GlobalVariable(ServerDate)

( If the current column in the dynamic grid is 1 and the selected date is less than current date )

Action 1 : dgPersonal.PreventNewRow=true (Disable the Insert New Row Link button )

Action 2 : GridSetValue(dgPersonal,dgPersonal.RowIndex,4,0) (Display a red label in the row to indicate a invalid date selected )

Action 3 : MessageBox(“Date should be greater than current date, please select another date”) (Show a alert that the date selected is wrong)

Rule 2: dgPersonal.ColIndex=2 & GridGetValue(dgPersonal,dgPersonal.RowIndex,2)>=GlobalVariable(ServerDate)
( If the current column in the dynamic grid is 1 and the selected date is greater than current date )

Action 1 : txtDate.Value = GridGetValue(dgPersonal,dgPersonal.RowIndex,2) (pass the date to the hidden textbox which will trigger another rule )

Rule 3 : dgPersonal.ColIndex=3 ( If the current column is the hours )
Action 1 : txtTotalPLTR.Value=GridSum(dgPersonal,3,false) ( Display the sum in the textbox below )

The textbox txtDate will trigger the ExecuteCommand of the Select Restricted Date. We need to make sure that the following actions are added to the same rule before the command is executed.

Action 1 : dgPersonal.PreventNewRow=false (enable the Insert New Row Link button )
Action 2 : Clear(txtDateId) (Clear the value in the textbox txtDateId )
Action 2 : GridSetValue(dgPersonal,dgPersonal.RowIndex,4,1)
(Display a green label in the row which will be overridden if it is a restricted date)

We will need to add a rule for the textbox txtDateId to see if there is a positive number returned from the server for this date criteria. If it returns a valid date id, then the user has selected a invalid date. So the rule should read as following.

Rule 1 : txtDateId.Value > 0
( If the command execution has returned a valid Id )
Action 1 : dgPersonal.PreventNewRow=true (Disable the Insert New Row Link button )
Action 2 : GridSetValue(dgPersonal,dgPersonal.RowIndex,4,0) (Display a red label in the row to indicate a invalid date selected )
Action 3 : MessageBox(“Selected date is restricted, please select another date”) (Show a alert that the date selected is wrong)