Expand|Select|Wrap|Line Numbers
- Public Class CustomerForm
- Private theBinding As BindingSource
- Private objCustomer As CustomerTier
- Private Sub CustomerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim dsCustomer As CustDataSet
- objCustomer = New CustomerTier
- dsCustomer = objCustomer.getDataSet()
- Try
- theBinding = New BindingSource()
- theBinding.DataSource = dsCustomer
- theBinding.DataMember = "Customer"
- Catch ex As Exception
- MessageBox.Show("Error With the Binding", ex.Message)
- End Try
- txtFirstName.DataBindings.Add("Text", theBinding, "First Name")
- txtLastName.DataBindings.Add("Text", theBinding, "Last Name")
- txtAddress.DataBindings.Add("Text", theBinding, "Address")
- txtCity.DataBindings.Add("Text", theBinding, "City")
- txtState.DataBindings.Add("Text", theBinding, "State")
- txtZip.DataBindings.Add("Text", theBinding, "Zip Code")
- lblID.DataBindings.Add("Text", theBinding, "Account Number")
- EnableNav()
- End Sub
- Private Sub EnableEdit()
- txtFirstName.ReadOnly() = True
- txtLastName.ReadOnly() = True
- txtAddress.ReadOnly() = True
- txtCity.ReadOnly() = True
- txtState.ReadOnly() = True
- txtZip.ReadOnly() = True
- btnCancel.Enabled = True
- btnFirst.Enabled = False
- btnPrev.Enabled = False
- btnNext.Enabled = False
- btnLast.Enabled = False
- End Sub
- Private Sub EnableNav()
- txtFirstName.ReadOnly() = True
- txtLastName.ReadOnly() = True
- txtAddress.ReadOnly() = True
- txtCity.ReadOnly() = True
- txtState.ReadOnly() = True
- txtZip.ReadOnly() = True
- btnCancel.Enabled = False
- btnFirst.Enabled = True
- btnPrev.Enabled = True
- btnNext.Enabled = True
- btnLast.Enabled = True
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
- If btnAdd.Text = "Add" Then
- btnAdd.Text = "Save"
- EnableEdit()
- btnEdit.Enabled = False
- 'btnDelete.Enabled = False
- theBinding.AddNew()
- Else
- btnAdd.Text = "Add"
- EnableNav()
- btnEdit.Enabled = True
- 'btnDelete.Enabled = True
- theBinding.EndEdit()
- objCustomer.setDataSet()
- End If
- End Sub
- Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
- If btnEdit.Text = "Edit" Then
- btnEdit.Text = "Save"
- EnableEdit()
- btnAdd.Enabled = False
- 'btnDelete.Enabled = False
- Else
- btnEdit.Text = "Edit"
- EnableNav()
- btnAdd.Enabled = True
- 'btnDelete.Enabled = True
- theBinding.EndEdit()
- objCustomer.setDataSet()
- End If
- End Sub