Thursday, 25 July 2013

EP: Multi Select & Loop DataSet (Looping Data set in C#)





When you set the AllowMarking property to true, the user can mark multiple rows in the grid. You may want to know which rows the user has marked. The following example shows how to use the GetMarkedRowsSet method for the data source view to retrieve the set of marked rows. In this example, the name of each marked row is added to a list box.

This example uses the .NET Business Connector to access data. It requires access to the following namespaces:

C#

using Microsoft.Dynamics.AX.Framework.Portal.Data;

using Microsoft.Dynamics.Framework.BusinessConnector.Session;

using Microsoft.Dynamics.Framework.BusinessConnector.Adapter;

 

The following code for a button retrieves the list of marked rows.

C#

protected void Button1_Click(object sender, EventArgs e)

{

    // Create a container.

    IAxaptaContainerAdapter recordIds = this.AxSession.AxaptaAdapter.CreateAxaptaContainer();

 

    // Get the marked rows.

    IReadOnlySet rows = this.AxDataSource1.GetDataSourceView("FCMRooms").DataSetView.GetMarkedRowsSet();

 

    // Create an enumerator to examine each marked row.

    IEnumerator enumRows = rows.GetEnumerator();

 

    DataSetViewRow row;

    string description;

 

    // Clear the list box.

    ListBox1.Items.Clear();

 

    while (enumRows.MoveNext())

    {

        // Get the current row.

        row = (DataSetViewRow)enumRows.Current;

 

        // Retrieve the name of the room.

        description = row.GetFieldValue("RoomName").ToString();

 

        // Add the item to the list box.

        ListBox1.Items.Add(description);

    }

}

 

Friday, 19 July 2013

EP: Code to Modify the standard Title bar in EP


//set the titlebar to show the record context
 ITitleProvider titleProvider = AxBaseWebPart.GetWebpart(this) as ITitleProvider;
        try
        {
            row = this.GetCurrentRow;
            if (row != null)
            {
                titleProvider.ShowContext = false;
                //set the title----
                SalesId = row.GetFieldValue("SalesId").ToString();
                ItemId = row.GetFieldValue("ItemId").ToString();
                titleProvider.Caption = String.Format(Labels.GetLabel("@AVA1712") + ": " + SalesId + ", " + ItemId);
}
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;
            // Determine whether the exception can be handled.
            if (AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory) == false)
            {
                // The exception was fatal and cannot be handled. Rethrow it.
                throw;
            }
        }

Wednesday, 3 July 2013

Accessing (AXBound) Bound Field Properties

///

    /// Code to get Field from Grid. Mallik
    ///

    ///
    ///
    ///
    static AxBoundField GetField(DataControlFieldCollection fields, string name)
    {
        foreach (DataControlField field in fields)
        {
            // Is this the field being searched for?
            AxBoundField boundField = field as AxBoundField;
            if (boundField != null && String.Compare(boundField.DataField, name, true) == 0)
            {
                return boundField;
            }
        }
        // Nothing found, so return null.
        return null;
    }

--------------------------------------------------------------------------------------------------------------------------
The following example uses the method created above to set the ReadOnly property for the SalesQty bound field in the AxGridView1  grid object for an AxForm.
-------------------------------------------------------------------------------------------------------------------------
AxBoundField RelatedSalesQty;
        AxBoundField RelatedSalesUnit;
        try
        {
            row = this.GetCurrentRow;
            authorizationStatus = row.GetFieldValue("AvaAuthorizationStatus").ToString();
            if (authorizationStatus == "0")//Labels.GetLabel("@AVA114"))
            {
                AxGridView1.AllowEdit = true;
                AxGridView1.AllowDelete = true;
                AxGridView1.AutoGenerateEditButton = true;
               
                RelatedSalesQty = GetField(AxGridView1.Columns, "SalesQty");
                RelatedSalesQty.ReadOnly = false;
                RelatedSalesUnit = GetField(AxGridView1.Columns, "SalesUnit");
                RelatedSalesUnit.ReadOnly = false;
                //AxGridView1.Columns.Contains("SalesQty")
                ret = true;
            }

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...