Thursday, May 12, 2016

CAll METHODS IN TUNNEL PAGE BASED ON THE BUTTON CLICKED NEXT AND CANCEL FINISH.X++ CODE ENTERPRISE PORTAL : ITEMUPDATE ITEMCOMMAND

 CAll METHODS IN TUNNEL PAGE BASED ON THE BUTTON CLICKED NEXT AND CANCEL FINISH.X++ CODE ENTERPRISE PORTAL


protected void Page_Init(object sender, EventArgs e)
    {
        wizDetailsCreateTunnel.NextButtonClick += new WizardNavigationEventHandler(wizCreateTunnel_NextButtonClick);
        wizDetailsCreateTunnel.FinishButtonClick += new WizardNavigationEventHandler(wizCreateTunnel_FinishButtonClick);
        wizDetailsCreateTunnel.CancelButtonClick += new EventHandler(wizDetailsCreateTunnel_CancelButtonClick);
        this.Employee1Form.ItemCommand += new DetailsViewCommandEventHandler(EMP_ItemCommand);
        this.Employee1Form.ItemUpdated += new DetailsViewUpdatedEventHandler(Employee1Form_ItemUpdated);
        this.SetupMode();
       
    }

protected void EMP_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Cancel")
        {
            this.EmpDataSourceView.CancelEdit();
            Boolean fetchEMP1Check;
            fetchEMP1Check = (Boolean)this.AxDataSource2.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("validateEMP1WInfo");
            //Proxy.Info obj = new Proxy.Info(this.AxSession.AxaptaAdapter);
            //obj.add(Proxy.Exception.Info, fetchEMP1Check.ToString());
            if (fetchEMP1Check == false)
            {
                this.AxDataSource2.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("deleteEMP");
            }
            //this.RedirectToPreviousPage();
        }
    }


    protected void Employee1Form_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {

        try
        {
            if (AxGridView4.Rows.Count > 0 && AxGridView4.EditIndex != -1)
            {
                this.AxGridView4.UpdateRow(AxGridView4.EditIndex, true);
                // Check the RowUpdating functionality threw any error.
                if (!rowUpdateSuccess) return;
            }            
        }
        catch (System.Exception ex)
        {
            AxExceptionCategory exceptionCategory;

            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
            {
                // Throw the fatal exception
                throw;
            }
        }
        if (e.Exception == null)
        {
            Boolean fetchEMP1;
            fetchEMP1 = (Boolean)this.AxDataSource2.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("validateEMP1");

            /*if(fetchEMP1 == true)
                this.RedirectToPreviousPage();*/
        }

    }


Code to call validate method in AX from .net dataset in Enterprise portal X++ :CALL AX METHOD FROM VISUAL STUDIO X++

Code to call validate method in AX from .net dataset in Enterprise portal X++

  #region Employee
        if (e.CurrentStepIndex == 2)//
        {          
            try
            {
                if (AxGridViewNameName4.Rows.Count > 0 && AxGridViewNameName4.EditIndex != -1)
                {
                    this.AxGridViewNameName4.UpdateRow(AxGridViewNameName4.EditIndex, true);
                }
                this.AxDataSource22.GetDataSourceView(this.AxGridViewNameName4.DataMember).DataSetView.AddNew();
                this.AxDataSource22.GetDataSourceView(this.AxGridViewName4.DataMember).DataSetView.Delete();

                if (AxGridViewName5.Rows.Count > 0 && AxGridViewName5.EditIndex != -1)
                {                  
                    this.AxGridViewName5.UpdateRow(AxGridViewName5.EditIndex, true);
                }
                this.AxDataSource22.GetDataSourceView(this.AxGridViewName5.DataMember).DataSetView.AddNew();
                this.AxDataSource22.GetDataSourceView(this.AxGridViewName5.DataMember).DataSetView.Delete();
               
            }
            catch (System.Exception ex)
            {
                AxExceptionCategory exceptionCategory;

                if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
                {
                    throw;
                }
            }
            //if (e. == null) check employee
            {
                Boolean fetchEMP;
                fetchEMP = (Boolean)this.AxDataSource22.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("validateEMP");
             

                if (fetchEMP == false)
                    e.Cancel = true;
            }
        }
       
        #endregion

Enterprise Portal DATASET LOOKUP CODE X++

Enterprise Portal DATASET LOOKUP X++

Query to create a dataset lookup in AX Enterrprise portal .

void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List                    _list;
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource1, queryBuildDataSource2, queryBuildDataSource3 ;
    QueryBuildRange         queryBuildRange,queryBuildRange2,queryBuildRange3;
    DirpartyTable           dirpartyTable;
    ;

    _list = new List(Types::String);
    _list.addEnd(fieldstr(EmplTable, EmplId));
    _list.addEnd(fieldstr(EmplTable, EmplName));


    queryBuildDataSource1 = query.addDataSource(tablenum(EmplTable));
    queryBuildDataSource2 = queryBuildDataSource1.addDataSource(tablenum(Dimensions));
    queryBuildDataSource2.joinMode(JoinMode::InnerJoin);
    queryBuildDataSource2.addLink(fieldnum(EmplTable,EmplId),fieldnum(Dimensions,Num));


    queryBuildRange       = queryBuildDataSource2.addRange (fieldnum (Dimensions, DimensionCode));
    queryBuildRange.value(queryvalue(sysdimension::Purpose));

    sysDataSetLookup.parmLookupFields(_list);
    sysDataSetLookup.parmQuery(query);
}

Related Posts Plugin for WordPress, Blogger...