Monday 8 December 2014

Price list report with parameters call in ax EP 2012

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PriceListView.ascx.cs" Inherits="PriceListView" %>
<%@ Register Assembly="Microsoft.Dynamics.Framework.Portal, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="Microsoft.Dynamics.Framework.Portal.UI.WebControls" TagPrefix="dynamics" %>
<style type="text/css">
    .style1
    {
        width: 70px;
    }
    .style5
    {
        width: 60px;
    }
    .style7
    {
        width: 108px;
    }
    .style8
    {
        width: 125px;
    }
</style>
<dynamics:AxMultiSection ID="EPPriceByRegionMultiSection" runat="server" 
    Height="40px">
    <dynamics:AxSection ID="EPPriceByRegionSection" runat="server">
     <table>
            <tr>
                <td style="padding-left:19px;" align="right" class="style1">                
                    <asp:Label ID="lblBPGroup" runat="server" AssociatedControlID="tbBPGroup"
                        Text="BP Group" style="font-weight: 700"></asp:Label> 
                </td>
                <td align="right">
                    <asp:TextBox class="AxInputField" ID="tbBPGroup" Width="100%"  
                        ToolTip="<%$Axlabel:@SYS191513%>" runat="server" ReadOnly="False" 
                        Enabled="True" style="margin-left: 0px"></asp:TextBox>
                </td>
                <td>
                <dynamics:AxLookup ID="DropDownBPSelection" runat="server" AutoPostBack="true" 
                TargetControlId="tbBPGroup"
                OnLookup="DropDownBPSelection_Lookup" TabIndex="1" 
                onokclicked="DropDownBPSelection_OkClicked">
                </dynamics:AxLookup>
                </td>
                <td align="right" class="style7">
                    <asp:Label ID="lblProductGroup" runat="server" AssociatedControlID="tbProductGroup"
                        Text="Product Group" style="font-weight: 700"></asp:Label>
                </td>
                <td align="right">
                    <asp:TextBox class="AxInputField" ID="tbProductGroup" Width="100%"  ToolTip="<%$Axlabel:@SYS191513%>" runat="server" ReadOnly="False" Enabled="True"></asp:TextBox>
                </td>
                <td>
                <dynamics:AxLookup ID="AxLookup2" runat="server" AutoPostBack="true" 
                TargetControlId="tbProductGroup"
                OnLookup="DropDownProductBPSelection_Lookup" TabIndex="1" 
                onokclicked="DropDownProductBPSelection_OkClicked">
                </dynamics:AxLookup>
                </td>  
                <td align="right" class="style8">
                    <asp:Label ID="lblParentCategory" runat="server" AssociatedControlID="tbParentCategory"
                        Text="Product Category" style="font-weight: 700"></asp:Label>
                </td>
                <td align="right">
                    <asp:TextBox class="AxInputField" ID="tbParentCategory" Width="100%"  ToolTip="<%$Axlabel:@SYS191513%>" runat="server" ReadOnly="False" Enabled="True"></asp:TextBox>
                </td>
                 <td>
                <dynamics:AxLookup ID="AxLookup3" runat="server" AutoPostBack="true" 
                TargetControlId="tbParentCategory"
                OnLookup="DropDownProductCatSelection_Lookup" TabIndex="1" 
                onokclicked="DropDownProductCatBPSelection_OkClicked">
                </dynamics:AxLookup>
                </td>
                 <td align="right" class="style5">
                    <asp:Label ID="lblModel" runat="server" AssociatedControlID="tbModel"
                        Text="Model" style="font-weight: 700"></asp:Label>
                </td>
                <td align="right">
                    <asp:TextBox class="AxInputField" ID="tbModel" Width="100%"  ToolTip="<%$Axlabel:@SYS191513%>" runat="server" ReadOnly="False" Enabled="True"></asp:TextBox>
                </td>
                <td>
                <dynamics:AxLookup ID="AxLookup4" runat="server" AutoPostBack="true" 
                TargetControlId="tbModel"
                OnLookup="DropDownItemidSelection_Lookup" TabIndex="1" 
                onokclicked="DropDownItemidSelection_OkClicked">
                </dynamics:AxLookup>
                </td>
            
            
            <td style="padding-left:12px;" align="right">
            <asp:Button runat="server" ID="Button1" 
            Text="View Price List " onclick="ViewReportButton_Click1" 
                    style="font-weight: 700"  />
            </td>
        </tr>
        </table>
    </dynamics:AxSection>
    
</dynamics:AxMultiSection>
<p>
    &nbsp;    
    <dynamics:AxReportViewer runat="server" ID="SalesByRegion" MenuItemName="PriceListview" />
</p>

________________________________________________________________________________________
using System;
using System.Collections.Generic;
using Microsoft.Dynamics.Framework.Portal.UI.WebControls;
using Microsoft.Dynamics.AX.Framework.Services.Client;
using Microsoft.Dynamics.Framework.BusinessConnector.Session;
using Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts;
using Microsoft.Dynamics.AX.Framework.Reporting.Shared;
using Microsoft.Dynamics.Framework.Portal.UI;
using BCProxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
using Microsoft.Dynamics.Framework.Portal.UI.WebControls;
using System.Data;
using System.Collections;
using Microsoft.Dynamics.Framework.BusinessConnector.Adapter;
using Microsoft.Dynamics.AX.Framework.Portal.Data;
public partial class PriceListView : System.Web.UI.UserControl
{
     /// <summary>
    /// Web part private
    /// </summary>
    AxBaseWebPart _baseWebpart = null;
    #region Properties
    /// <summary>
    /// Webpart 
    /// </summary>
    AxBaseWebPart BaseWebpart
    {
        get
        {
            //return the basewebpart if it is not null
            if (this._baseWebpart != null)
                return this._baseWebpart;
            //get the webpart if basewebpart is null
            this._baseWebpart = AxBaseWebPart.GetWebpart(this);
            return this._baseWebpart;
        }
    }
    /// <summary>
    /// Gets the current Web Part Session.
    /// </summary>
    ISession AxSession
    {
        get
        {
            return BaseWebpart.Session;
        }
    }
    #endregion
  
    #region Events
    protected void Page_Load(object sender, EventArgs e)
    {
        string curUserId = AxSession.SessionInfo.UserId;
        bool accepted = bool.Parse(AxSession.AxaptaAdapter.CallStaticRecordMethod("UserAcceptanceTable", "exists", curUserId).ToString());
        if (accepted == false)
        {
            AxUrlMenuItem urlHomePage = new AxUrlMenuItem("Test");
            Response.Redirect(urlHomePage.Url.OriginalString, true);
        }
        if (!this.IsPostBack)
        {
           // this.setValues();
            Dictionary<string, object> parms = new Dictionary<string, object>();
            this.SalesByRegion.AddParameters(parms);
        }
    }    protected void ViewReportButton_Click1(object sender, EventArgs e)
    {
        Dictionary<string, object> parms = new Dictionary<string, object>();
       
        parms.Add("PriceListDs_BPGroup", this.tbBPGroup.Text);
        parms.Add("PriceListDs_ProdGroup", this.tbProductGroup.Text);
        parms.Add("PriceListDs_ProdCat", this.tbParentCategory.Text);
        parms.Add("PriceListDs_ItemId", this.tbModel.Text);
        parms.Add("PriceListDs_priceListView", this.DropDownListSorting.SelectedItem.Text);
        this.SalesByRegion.AddParameters(parms);
       
    }
    protected void DropDownListSorting_init(object sender, EventArgs e)
    {
        int enumNum = EnumMetadata.EnumNum(this.AxSession, "PriceListView");
        using (BCProxy.DictEnum dictEnum = new BCProxy.DictEnum(this.AxSession.AxaptaAdapter, enumNum))
        {
            int noOfElements = dictEnum.values();
            for (int counter = 0; counter < noOfElements; counter++)
            {
                this.DropDownListSorting.Items.Add(dictEnum.index2Label(counter));
            }
        }
    }
    protected void DropDownBPSelection_OkClicked(object sender, AxLookupEventArgs e)
    {
        //this.loadProdGroupDrpDown();
    }
    protected void DropDownBPSelection_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup nameLookup = e.LookupControl;
        //TxtWarehouseCode.Text = "";
        try
        {
            AxLookup lookup = (AxLookup)sender;
            // Create the lookup dataset - we will do a lookup in the DirPartyTable table
            using (BCProxy.SysDataSetBuilder sysDataSetBuilder = BCProxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "EcoresCategory")))
            {
                // Set the run time generated data set as the lookup data set
                nameLookup.LookupDataSet = new Microsoft.Dynamics.AX.Framework.Portal.Data.DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
            }
            // DataSet has to be init'ed before accessing the data sources
            nameLookup.LookupDataSet.Init();
            // Filter the lookup 
            using (BCProxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
            {
                using (BCProxy.QueryBuildDataSource qbds = query.dataSourceNo(1))
                {
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "EcoResCategory", "Level")).value = "2";
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "EcoResCategory", "ShowOnEP")).value = "Yes";
                    qbds.addOrderByField(TableDataFieldMetadata.FieldNum(this.AxSession, "EcoResCategory", "Name"));
                    qbds.orderMode = (int)OrderMode.GroupBy;
                }
            }
            // Specify the lookup fields used
            nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["Name"]));
            // Specify the select field
            nameLookup.SelectField = "Name";
        }
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;
            // This returns true if the exception can be handled here
            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
            {
                // The exception is system fatal - in this case we re-throw.                                    
                throw;
            }
        }
    }
    protected void DropDownProductBPSelection_OkClicked(object sender, AxLookupEventArgs e)
    {
        //this.loadProdGroupDrpDown();
    }
    protected void DropDownProductBPSelection_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup nameLookup = e.LookupControl;
        //TxtWarehouseCode.Text = "";
        try
        {
            AxLookup lookup = (AxLookup)sender;
            // Create the lookup dataset - we will do a lookup in the DirPartyTable table
            using (BCProxy.SysDataSetBuilder sysDataSetBuilder = BCProxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "PriceMasterTable")))
            {
                // Set the run time generated data set as the lookup data set
                nameLookup.LookupDataSet = new Microsoft.Dynamics.AX.Framework.Portal.Data.DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
            }
            // DataSet has to be init'ed before accessing the data sources
            nameLookup.LookupDataSet.Init();
            // Filter the lookup 
            using (BCProxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
            {
                using (BCProxy.QueryBuildDataSource qbds = query.dataSourceNo(1))
                {
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "BPGroup")).value = this.tbBPGroup.Text;
                    qbds.addOrderByField(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ProdGroup"));
                    qbds.orderMode = (int)OrderMode.GroupBy;
                }
            }
            // Specify the lookup fields used
            nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["ProdGroup"]));
            // Specify the select field
            nameLookup.SelectField = "ProdGroup";
        }
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;
            // This returns true if the exception can be handled here
            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
            {
                // The exception is system fatal - in this case we re-throw.                                    
                throw;
            }
        }
    }
    protected void DropDownProductCatBPSelection_OkClicked(object sender, AxLookupEventArgs e)
    {
        //this.loadProdGroupDrpDown();
    }
    protected void DropDownProductCatSelection_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup nameLookup = e.LookupControl;
        //TxtWarehouseCode.Text = "";
        try
        {
            AxLookup lookup = (AxLookup)sender;
            // Create the lookup dataset - we will do a lookup in the DirPartyTable table
            using (BCProxy.SysDataSetBuilder sysDataSetBuilder = BCProxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "PriceMasterTable")))
            {
                // Set the run time generated data set as the lookup data set
                nameLookup.LookupDataSet = new Microsoft.Dynamics.AX.Framework.Portal.Data.DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
            }
            // DataSet has to be init'ed before accessing the data sources
            nameLookup.LookupDataSet.Init();
            // Filter the lookup 
            using (BCProxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
            {
                using (BCProxy.QueryBuildDataSource qbds = query.dataSourceNo(1))
                {
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "BPGroup")).value = this.tbBPGroup.Text;
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ProdGroup")).value = this.tbProductGroup.Text;
                    qbds.addOrderByField(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ProdCategory"));
                    qbds.orderMode = (int)OrderMode.GroupBy;
                }
            }
            // Specify the lookup fields used
            nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["ProdCategory"]));
            // Specify the select field
            nameLookup.SelectField = "ProdCategory";
        }
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;
            // This returns true if the exception can be handled here
            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
            {
                // The exception is system fatal - in this case we re-throw.                                    
                throw;
            }
        }
    }
    protected void DropDownItemidSelection_OkClicked(object sender, AxLookupEventArgs e)
    {
        //this.loadProdGroupDrpDown();
    }
    protected void DropDownItemidSelection_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup nameLookup = e.LookupControl;
        //TxtWarehouseCode.Text = "";
        try
        {
            AxLookup lookup = (AxLookup)sender;
            // Create the lookup dataset - we will do a lookup in the DirPartyTable table
            using (BCProxy.SysDataSetBuilder sysDataSetBuilder = BCProxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "PriceMasterTable")))
            {
                // Set the run time generated data set as the lookup data set
                nameLookup.LookupDataSet = new Microsoft.Dynamics.AX.Framework.Portal.Data.DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
            }
            // DataSet has to be init'ed before accessing the data sources
            nameLookup.LookupDataSet.Init();
            // Filter the lookup 
            using (BCProxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
            {
                using (BCProxy.QueryBuildDataSource qbds = query.dataSourceNo(1))
                {
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "BPGroup")).value = this.tbBPGroup.Text;
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ProdGroup")).value = this.tbProductGroup.Text;
                    qbds.addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ProdCategory")).value = this.tbProductGroup.Text;
                    qbds.addOrderByField(TableDataFieldMetadata.FieldNum(this.AxSession, "PriceMasterTable", "ItemCode"));
                    qbds.orderMode = (int)OrderMode.GroupBy;
                }
            }
            // Specify the lookup fields used
            nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["ItemCode"]));
            // Specify the select field
            nameLookup.SelectField = "ItemCode";
        }
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;
            // This returns true if the exception can be handled here
            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
            {
                // The exception is system fatal - in this case we re-throw.                                    
                throw;
            }
        }
    }
}
#endregion

1 comment:

  1. Baccarat - Where to play the game - William R. R. Moynihan
    Baccarat is a card game in which players draw 바카라 the six cards 샌즈카지노 of the same color from the 1xbet korean same pile until they have exactly two cards. It is played

    ReplyDelete