AnsweredAssumed Answered

VB.net

Question asked by cdebruin on Mar 9, 2012
Latest reply on Mar 9, 2012 by rkelso
Hi,
Sorry about the thread name, accidentally hit enter. Is there a way to edit that?

I'm attempting to save data fields in a form and it appears that when one field is emptied, none of the fields save properly.

Specifically the Rim Elevation field. When that is deleted by the user, all the other fields are deleted as well, but the feature still exists.
I've highlighted where I'm guessing the problem area is. Also, I apologize, the code sloppy as it's being written and edited by 3 different people.

Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Editor

Public Class FormSanMHedit

Private Sub FormSanMHedit_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Debug.Print("Begin Load Formsanmhedit")
Dim pTablesort As ITableSort, pRow As IRow, i As Integer, rCount As Integer
Dim legacyID As String
rCount = ncSewerContractsTable.RowCount(Nothing)
'Debug.Print "Count in NC Sewer Contracts is " & rCount
If rCount <> 0 Then

'Sort ncSewerContractsTable
pTablesort = New TableSort
With pTablesort
.Fields = "CONTRACT"
.Ascending("CONTRACT") = True
.QueryFilter = Nothing
.Table = ncSewerContractsTable
End With

pTablesort.Sort(Nothing)

'Get the list from the table, add each to the userform
ncSewerContractsCursor = pTablesort.Rows
pRow = ncSewerContractsCursor.NextRow

i = 0

Do Until pRow Is Nothing
cmbContract.Items.Add(pRow.Value(ncSewerContractsCONTR_IDfld))
'cmbContract.Items.Column(0, i) = pRow.Value(ncSewerContractsCONTR_IDfld)
'cmbContract.Column(1, i) = pRow.Value(ncSewerContractsCONTRACTfld) & " - " & pRow.Value(ncSewerContractsDESCRIPTIOfld)
'Debug.Print Me.cmbContract.Column(1, i)
pRow = ncSewerContractsCursor.NextRow
i = i + 1
Loop
End If

'Debug.Print(makeOrEdit)
If makeOrEdit = "Enter" Then
'Debug.Print("make mh")
Me.txtMhRimElevNGVD29.Text = ""
Me.txtLegacyMHnum.Text = ""
If Not sanmhLastContractUsed = Nothing Then
Me.cmbContract.ValueMember = sanmhLastContractUsed
Else

Me.cmbContract.ValueMember = ""
End If

Me.txtFlushCount.Text = 0
Me.txtVentNum.Text = ""
Me.txtRemarks.Text = ""

Else
legacyID = checkNullString(sanmhFeature, sanmhLegacy_IDfld)
'Debug.Print("legacyID = " & legacyID)
Me.txtLegacyMHnum.Text = checkNullString(sanmhFeature, sanmhLegacy_IDfld)
'Debug.Print("after reading mh#")
Me.txtMhRimElevNGVD29.Text = checkNullNumber(sanmhFeature, sanmhMHrimElevFld)
Me.cmbContract.SelectedValue = checkNullString(sanmhFeature, sanmhContrBuiltFld)
If Me.cmbContract.Text = Nothing Then
sanmhLastContractUsed = ""
Else
sanmhLastContractUsed = sanmhLastContractUsed
End If
Me.txtFlushCount.Text = checkNullNumber(sanmhFeature, sanmhFlushCountFld)
Me.txtVentNum.Text = checkNullString(sanmhFeature, sanmhVentNumFld)
Me.txtRemarks.Text = checkNullString(sanmhFeature, sanmhMH_RemarksFld)

End If
End Sub

Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub

Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click

Dim pPoint As IPoint = Nothing

StartEditSession(sanmhFeatClass)

If makeOrEdit = "Enter" Then
'Debug.Print("Create New Manhole")
sanmhFeature = sanmhFeatClass.CreateFeature
sanmhFeature.Shape = Point
sanmhFeature.Value(sanmhGIDfld) = GetNewGUID()
Else
'Debug.Print "Edit"
End If

If Me.txtFlushCount.Text = Nothing Then
Me.txtFlushCount.Text = 0
End If

''//cdebruin 03/08/2012: Stores a null value to the database if Rim Elev field = "". Else stores the user entered value.
''//Prompts user if non-numeric values are entered in the Rim Elev field.
If Me.txtMhRimElevNGVD29.Text = "" Then
sanmhFeature.Value(sanmhMHrimElevFld) = DBNull.Value
ElseIf IsNumeric(Me.txtMhRimElevNGVD29.Text) Then
sanmhFeature.Value(sanmhMHrimElevFld) = Me.txtMhRimElevNGVD29.Text
Else
MsgBox("Please enter only numeric values in the Rim Elevation Field.", MsgBoxStyle.Exclamation, "Invalid Data Entry")
Exit Sub
End If
sanmhFeature.Value(sanmhLegacy_IDfld) = Me.txtLegacyMHnum.Text
sanmhFeature.Value(sanmhContrBuiltFld) = Me.cmbContract.SelectedValue
sanmhLastContractUsed = Me.cmbContract.SelectedValue
sanmhFeature.Value(sanmhFlushCountFld) = Me.txtFlushCount.Text
sanmhFeature.Value(sanmhVentNumFld) = Me.txtVentNum.Text
sanmhFeature.Value(sanmhMH_RemarksFld) = Me.txtRemarks.Text
StoreNameAndTime(sanmhFeature, makeOrEdit)
sanmhFeature.Store()
EndEditSession("sanMHedit")
Me.Close()
End Sub

End Class

Outcomes