Starting in MAS 500 7.0, Sage has provided ‘hooks’ for developers to use to create .NET applications that can run within a MAS 500 session.   However, to get the look and feel of a true MAS 500 task, developers needed a way to be able to have Navigators, Lookups, and GL Account controls on their forms. Unfortunately, Sage did not provide these controls or documentation on how to add/use them within the SDK.

 This article hopefully will fill that void and provide the steps necessary to add the following controls to a MAS 500 .NET task. The following controls will be discussed:

  •    Text Lookup Control
  •      Masked Edit Lookup Control
  •      GL Account Lookup Control

 There is also a .NET version of the standard Lookup control. However, this article does not discuss this control as it is not used as often as the text lookup control.

 The first thing that needs to be done is to add the controls to Visual Studio’s tool box. I’d recommend adding a new tab to the tool box labeled ‘MAS 500 Controls’ and place the controls within it.

 To add the controls select ‘Choose Items’ from the Toolbox’s context menu. Select browse from the ‘Select Toolbox Item’ screen. On the ‘Open’ screen select Accounting.Framework.LookupControls.dll. This resides in the MAS 500 Client\Managed Applications\Framework Folder. Ensure all the controls are selected and select OK. You will now see the MAS 500 lookup controls added to your toolbox and ready to use.

Text Lookup Control

The first control we’ll discuss is the most commonly used one. The text lookup control pulls double duty as a task’s navigator and as a lookup.   It is one of the key controls that makes MAS 500 unique to other programs in its space.

 The TextLookup displays a Textbox control combined with a Lookup allowing the user to either enter the information or select from the Lookup Search Window when invoked from the Lookup button.

 The benefits of using the controls together as one control are:

  • Lookup position placement is always correct which makes our forms appear professional.
  • Starting value logic for the application is performed within the control.
  • If LookupReturnColumn is set, the value in the return column set into the Text property of the text box upon user selection of the row.
  • Handles F4 and F5 hotkey feature to automatically invoke the Lookup Search Window.

 To use the lookup control, add the following references to your .NET task. This assumes that your project is already coded to use the existing MAS 500 hooks.

  •  Accounting.Framework.Common
  • Accounting.Framework.License
  • Accounting.LookupBusinessLayer
  • Accounting.LookupControls
  • Accounting.LookupForm
  • Accounting.Framework.Session
  • Infragistics2.Shared.v5.3
  • Infragistics2.Win.Misc.v5.3
  • Infragistics2.Win.v5.3

 Add a lookup control to your form and name it appropriately using the naming standard lku or nav based on how the control is being used.

 Import the following into your form

  •  Imports System.Data
  •  Imports System.Data.SqlClient
  •  Imports Accounting.Framework
  •  Imports Infragistics.Win.UltraControlBase

 To setup a lookup control, the only real requirements are a LookupID and Session object. The LookupReturnColumnName property is used as a binding mechanism on the value in this property to the Text property of the Textbox control. Also, in most uses, there exists a restriction on the data by the calling application, which implies parameter setup.

 Example:

With TextLookup1.LookupControl

   .Session = _Session

   .LookupID = "Customer"

   .RestrictClause = "CompanyID = @CompanyID"

   .Parameters.Add("@CompanyID", SqlDbType.Char, 3)

   .Parameters("@CompanyID").Value = _Session.CompanyID

End With

TextLookup1.LookupReturnColumnName = "CustID"

 In order to get data into other controls associated with this Lookup control, the application must handle the Selected event. To do this add a handler to a new Selected event for the control.

 AddHandler TextLookup1.LookupControl.Selected, AddressOf TextLookup1_Selected

 Example Code for the Selected event routine.

 Private Sub TextLookup1_Selected(ByVal sender As Object, ByVal e As Accounting.Framework.Lookup.LookupSelectedEventArgs)

       txtCustName.Text = CType(e.SelectedRow("CustName"), String).Trim

End Sub

MaskEditLookup

The MaskEditLookup displays a Syncfusion MaskEdit control combined with a Lookup allowing the user to either enter the information in a formatted text box or select from the Lookup Search Window when invoked from the Lookup button.

The benefits of using the controls together as one control are:

  • Lookup position placement is always correct which makes our forms appear professional.
  • Starting value logic for the application is performed within the control.
  • If LookupReturnColumn is set, the value in the return column set into the Text property of the mask edit control upon user selection of the row.
  • Handles F4 and F5 hotkey feature to automatically invoke the Lookup Search Window.

 To use this control you’ll need to set one additional reference to the SyncFusion.Shared.Base assembly

 The coding for the MaskEditLookup is the same as the TextLookup control

 'MaskedTextLookup

       With MaskEditLookup1.LookupControl

           .Session = _Session

           .LookupID = "Customer"

           .RestrictClause = "CompanyID = @CompanyID"

           .Parameters.Add("@CompanyID", SqlDbType.VarChar, 3)

           .Parameters("@CompanyID").Value = _Session.CompanyID

       End With

       MaskEditLookup1.LookupReturnColumnName = "CustID"

        AddHandler MaskEditLookup1.LookupControl.Selected, AddressOf MaskEditLookup1_Selected

 Private Sub MaskEditLookup1_Selected(ByVal sender As Object, ByVal e As Lookup.LookupSelectedEventArgs)

       txtCustName2.Text = CType(e.SelectedRow("CustName"), String).Trim

End Sub

 GLAccountLookup

The GLAccount lookup inherits from the MaskEditLookup and therefore displays a Syncfusion MaskEdit control combined with a Lookup allowing the user to either enter the information in a GLAccount formatted text box or select from the Lookup Search Window when invoked from the Lookup button. The GLAccount entry is formatted for the CompanyID specified, defaulted from the Session company. The default LookupID is set to “Account” for the GLAccountLookup.LookupControl. The default LookupReturnColumnName is set to “GLAcctNo”.

 The benefits of using the controls together as one control are:

  • Lookup position placement is always correct which makes our forms appear professional.
  • Starting value logic for the application is performed within the control.
  • If LookupReturnColumn is set, the value in the return column set into the Text property of the mask edit control upon user selection of the row.
  • Handles F4 and F5 hotkey feature to automatically invoke the Lookup Search Window.

 Because there is a default LookupID on the control and the CompanyID is set from the Session object, the only the the application would need to provide is the Session object.

 GlAccountLookup1.LookupControl.Session = _Session

 In order to get data into other controls associated with this Lookup control, the application must handle the Selected event.

 AddHandler GlAccountLookup1.LookupControl.Selected, AddressOf GlAccountLookup1_Selected

 Code for the Selected event routine.

 Private Sub GlAccountLookup1_Selected(ByVal sender As Object, ByVal e As Lookup.LookupSelectedEventArgs)

       txtDescription.Text = CType(e.SelectedRow("Description"), String).Trim

End Sub

 

Last edited Mar 2, 2011 at 11:53 PM by ldavis1, version 1

Comments

No comments yet.