Last post Nov 02, 2020 04:45 PM by mgebhard
Nov 02, 2020 03:06 PM|dlchase|LINK
Our users wanted an insert blocked if PTO entry exceeds a limit on number of days off. Now they want to give some users the ability to override this and allow the insert to happen. Below is the OnInserting code we are currently using. They want a popup
to confirm this insert before the actual insert(s) are committed. How can we do this?
Dim strMsg As String = ""
Dim strDatesOver As String = ""
Using conData As SqlConnection = New SqlConnection(DBClass.GetMgmtConnectionString)
Dim strSQL As String = "EXEC dbo.ms_selEmployeeTimeOffMax " &
"@StartDate = '" & dtDateFrom.ToShortDateString & "'" &
", @EndDate = '" & dtDateTo.ToShortDateString & "'" &
", @EmployeeCode='" & ddl.SelectedValue & "'"
Dim cmdSelect As SqlCommand = New SqlCommand(strSQL, conData)
Dim dtr As SqlDataReader = cmdSelect.ExecuteReader()
If dtr.HasRows Then
strDatesOver &= Format(dtr("TimeOffDate"), "M/d/yyyy") & "~"
If strDatesOver <> "" Then
'PTO max exceeded on one or more dates
strMsg = "The PTO dates below would exceed daily group maximums for PTO. PTO entry was cancelled.~" & strDatesOver
txtMsg.Text = strMsg
e.Cancel = True
Nov 02, 2020 04:45 PM|mgebhard|LINK
How can we do this?
First, come up with a design that meets the requirements. These are steps. Next, write the code to meet the requirement.
If you want the community to complete your work, then are you also willing to share your fee?
As a hint, the current business rules are within the stored procedure. Modify the procedure to accept another parameter which overrides the current logic.