Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cancel Entity
Message
From
06/04/2011 08:34:19
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Cancel Entity
Miscellaneous
Thread ID:
01506242
Message ID:
01506242
Views:
98
*******************************************************************FIX********************************************************************************
Hello. I placed "Me._building.Cancel()" in the cancel event of the button. I didn't think I had to do this since Me._building is registered as the primary BO.

Doesn't the form call the necessary events for the primary BO?

Thanks.


Hello. I'm using the most recent version of MM.NET in VS2010 and classic BO's.

I've created a new project and I currently have 1 form and 1 BO. I have a Save, Cancel, Delete, New, and Close button on the form.
If I make changes and click the "Cancel" button nothing happens. When I close the form it messages me that I have unsaved changes.
In caps are my greater than less than symbols
Here's my code:
Imports System.Data
Imports System.ComponentModel

Imports OakLeaf.MM.Main
Imports OakLeaf.MM.Main.Windows.Forms
Imports NYSDTF.TelecommunicationBusiness

Public Class BuildingMaintenance
    Inherits mmBusinessForm

    Private _building As Building

    Public Sub New()
        'Change the mouse cursor to the wait cursor
        Me.Cursor = Cursors.WaitCursor

        ' Instantiate and register business objects
        Me._building = CType(Me.RegisterPrimaryBizObj(New Building), Building)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        'Do not autogenerate columns
        Me.grdBuildings.AutoGenerateColumns = False

        'Reset the mouse cursor
        Me.Cursor = Cursors.Default
    End Sub

    'Disable/enable buttons
    Private Sub DefaultMode()
        If Not Me._building.Entity.HasErrors Then
            Me.btnSave.Enabled = False
            Me.btnCancel.Enabled = False

            If Me._building.EntityList.Count > 0 Then
                Me.btnDelete.Enabled = True
            Else
                Me.btnDelete.Enabled = False
            End If

            Me.btnNew.Enabled = True
        End If
    End Sub

    'Disable/enable buttons
    Private Sub EditMode()
        Me.btnSave.Enabled = True
        Me.btnCancel.Enabled = True
        Me.btnDelete.Enabled = False
        Me.btnNew.Enabled = False
    End Sub

    Private Sub ShowMessage(ByVal message As String)
        MessageBox.Show(message, "Telecommunications", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    'Search for a building
    Private Sub btnSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click
        If Me.txtSearchCode.Text NOT EQUAL String.Empty Then
            Me._building.SearchBuildingByCode(Me.txtSearchCode.Text)

            If Me._building.EntityList.Count = 0 Then
                Me.ShowMessage("Your search resulted in no matching records.")
                Me.txtSearchCode.Focus()
            Else
                Me.txtCode.Focus()
                Me.btnDelete.Enabled = True
            End If
        Else
            Me.ShowMessage("You must enter a building code to peform a search")
        End If

    End Sub

    'Save changes
    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
        Me.DefaultMode()
    End Sub

    'Cancel changes
    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
        Me.DefaultMode()
    End Sub

    'Create a new building
    Private Sub btnNew_Click(sender As System.Object, e As System.EventArgs) Handles btnNew.Click
        Me.EditMode()
    End Sub

    'Send the form into "Edit" mode
    Private Sub txtKeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtName.KeyUp, txtCode.KeyUp
        If e.KeyCode "GREATER THEN EQUAL TO" 65 And e.KeyCode "LESS THEN EQUAL TO" 90 Or e.KeyCode EQUAL 46 Or e.KeyCode EQUAL 8 Then
            Me.EditMode()
        End If
    End Sub
End Class
Thanks.
Next
Reply
Map
View

Click here to load this message in the networking platform