Skip to content

Commit

Permalink
Merge pull request #667 from Patowhiz/namibia_bug_fix
Browse files Browse the repository at this point in the history
Added prompt entry for duplicate entry
  • Loading branch information
conlooptechnologies authored Nov 25, 2021
2 parents 8f4e420 + bc7c330 commit 3b6ece7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ClimsoftVer4/ClimsoftVer4/ucrBaseDataLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Public Class ucrBaseDataLink
Next
End Sub

Private Function GetLinkedControlsFilter() As TableFilter
Public Function GetLinkedControlsFilter() As TableFilter
Dim clsOverallControlsFilter As TableFilter = Nothing

UpdateDctLinkedControlsFilters()
Expand Down
27 changes: 26 additions & 1 deletion ClimsoftVer4/ClimsoftVer4/ucrNavigation.vb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ Public Class ucrNavigation
Private Sub displayRecordNumber()
'Display the record number in the data navigation Textbox
If iCurrRow = -1 Then
txtRecNum.Text = "New Record"
If CheckIfRowExistsInDb() Then
txtRecNum.Text = "Record Exists"
Else
txtRecNum.Text = "New Record"
End If

'disable navigation buttons
EnableNavigationButtons(False)
ElseIf iMaxRows = 0 Then
Expand Down Expand Up @@ -290,6 +295,7 @@ Public Class ucrNavigation
Dim row As Dictionary(Of String, String)

If dctKeyControls IsNot Nothing AndAlso dctKeyControls.Count > 0 AndAlso iMaxRows > 0 Then

'check if its current row first before fetching from database
bRowExists = True
row = GetRow(iCurrRow)
Expand All @@ -306,6 +312,12 @@ Public Class ucrNavigation
iCurrRow = GetRowPosition(dctFieldvalue)
End If

'if row already exists then try to notify the user
If iCurrRow = -1 AndAlso CheckIfRowExistsInDb() Then
'MsgBox("Record already entered. Saving it will not be permitted")
MessageBox.Show(Me, "This record already exists. Saving it will not be permitted")
End If

End If

bSuppressKeyControlChanges = True
Expand Down Expand Up @@ -634,6 +646,19 @@ Public Class ucrNavigation
Return dctRow
End Function


Private Function CheckIfRowExistsInDb() As Boolean
Dim iRowsFound As Integer = -1
Dim clsOverallControlsFilter As TableFilter = ucrLinkedTableEntry.GetLinkedControlsFilter

If clsOverallControlsFilter IsNot Nothing Then
iRowsFound = clsDataDefinition.TableCount(clsOverallControlsFilter.Clone)
End If

Return iRowsFound > 0
End Function


'TODO. Change how this is implemented
'Gets the row position. The parameter is dictionary of column names and the values to fetch
Private Function GetRowPosition(dctFieldvalue As Dictionary(Of String, String)) As Integer
Expand Down

0 comments on commit 3b6ece7

Please sign in to comment.