User1510859543 posted
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)
conData.Open()
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
While dtr.Read()
strDatesOver &= Format(dtr("TimeOffDate"), "M/d/yyyy") & "~"
End While
End If
dtr.Close()
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
End If
End Using