Search This Blog

Tuesday 2 September 2014

Sum of two Numbers using Dialog Class in Ax 2009

Hi ,

Today i would like to share you , how to get the dynamic input value using dialog class

In c, scanf() is used to get the dynamic input value .
Similarly in Ax , Dialog is used to get the dynamic input Value.

For an Example,

I wrote a class to get an input value from users dynamically and print the sum of values as output

Coding:

class Dynamicclass extends RunBase
{
    int FirstNum;
    int SecondNum;
    int SumValue;
   
    DialogGroup diaGrp;
    DialogField diaFld,diaFld2;
    Dialog      dialog;

}

Dialog:

protected Object dialog()
{
    ;

    dialog = super();

    dialog.caption("Enter the valid  Number");

    diaGrp=dialog.addGroup("Number");

    diaFld=dialog.addField(Typeid(Integer)," First Number","Enter the First Number");
    diaFld2=dialog.addField(Typeid(Integer)," Second Number","Enter the second Number");

    return dialog;
   
}

Display Date

void displaydata()
{
    ;
    info(strfmt("First Number =%1",FirstNum));
    info(strfmt("Second Number =%1",SecondNum));
    info(strfmt("Sum of Two Number =%1",SumValue));
}

Get Data:


void getdata(int _firstNum,int _secondNum)
{
    ;
   
    FirstNum    =   _firstNum;
    SecondNum   =   _secondNum;
    SumValue    =   _firstNum+_secondNum;
}

Pack:

public container pack()
{
    return connull();
}

Run:

void run()
{
    super();
   
    FirstNum = diaFld.value();
    SecondNum = diaFld2.value();
    this.getdata(FirstNum,SecondNum);
    this.displaydata();
}

UnPack:

public boolean unpack(container packedClass)
{
    return true;
}

Main:

public static void main(Args args)
{

Dynamicclass obj =new Dynamicclass();

    if(obj.prompt())
    {
         obj.run();
    }

}


Output:

Happy Daxing....

No comments:

Post a Comment