In an interface there are 5 tabs (Tab 1 to Tab 5). Each tab has a Binding Navigator to Add, Delete, Save, Edit items. For Tab 2 (subcategory for tab 1), the Delete button in the Binding Navigator has the following code. Tab 3 is the subcategory for tab 2, Tab 4 is the subcategory for tab3 and so it goes.
My question is :
Do I have to change the names of the highlighted section for each tab? (gSQLstr, cSQL, gSQLcon, DQcheck, DHcheck, Dvcheck) ?
Private Sub subcatBindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorDeleteItem.Click
Try
If dgsubcategory.RowCount > 0 Then
If subcatBindingNavigatorDeleteItem.Text = "Delete" Then
If MessageBox.Show("Are you sure to delete this record?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
[B]gSQLstr = "SELECT COUNT(iim_subcat) FROM inv_itemmaster WHERE iim_subcat = " & cSQL(cmbsubcatcode.Text) & ""
If gSQLcon.State = ConnectionState.Closed Then
gSQLcon.Open()
End If
DQcheck.Connection = gSQLcon
DQcheck.CommandText = gSQLstr
DHcheck.SelectCommand = DQcheck
DHcheck.Fill(DScheck, ("subcat_list"))
Dvcheck.Table = DScheck.Tables("subcat_list")
If Dvcheck.Table.Rows(0).Item(0) > 0 Then MessageBox.Show("Record cannot be deleted!", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
InvitemsubcategoryBindingSource.RemoveCurrent()
Inv_itemsubcategoryTableAdapter.Update(dsInventory)
MessageBox.Show("Record has been deleted.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
DScheck.Clear()
gSQLcon.Close()[/B] End If
Else
If AddNew = True Then
AddNew = False
End If
subcat(True)
txtsubcatdesc.Enabled = False
refreshsubcat()
cmbsubcatcode.SelectedValue = subcatcode
End If
Else
MessageBox.Show("No record to delete.", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 2(Delete)", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub