使用基于方法值的字段值

时间:2018-01-23 15:15:38

标签: dialog lookup dynamics-ax-2012 x++

我创建了一个类对话框,其中有一个名为#include <stdio.h> #include <conio.h> #include <time.h> #include <stdbool.h> int main(){ //check bool ok=false; //true when guess==real time int tent=0; //tryes //guesses char tempo[5]; //input string from user char ora[2]; //houres char min[2]; //mins //get time time_t my_time; struct tm * timeinfo; time (&my_time); timeinfo = localtime (&my_time); //random srand(time(NULL)); //guessing game, user shound input a string that conains current time to win: hh:mm printf("In principio era uno, e il nulla.\n\n"); printf("Poi l'uomo lo duplico', e tra essi traccio' la via...\n"); printf("Lo fece ancora... e gli sembro' perfetto.\n"); printf("Ma non era abbastanza... "); printf("Cosi' si spinse piu' in profondita', e sbirciando poco oltre trovo'... "); do{ //get guessed time (could also get words and non relevant numbers, if input is not hh:mm (current hour:current mins) user gets error) scanf("%s",&tempo); fflush(stdin); //split array tempo into ora and min to separate h from mins ora[0]=tempo[0]; ora[1]=tempo[1]; min[0]=tempo[3]; min[1]=tempo[4]; //cast guess form string to int int oraint=atoi(ora); //creat integer hour from string int minint=atoi(min); //integer mins //check guess == real time if(oraint==timeinfo->tm_hour && minint==timeinfo->tm_min){ //win printf("\nCOMPLIMENTI! Hai trovato la risposta!\n"); printf("\n\nEcco le tue prossime istruzioni!\n\n"); printf("TURFeE1UQXdNREF3TVRFd01EQXdNVEF4TVRFd01ERXhNREV4TVRBd01URXdNVEV4TURFeE1UQXhNVEF4TVRFeE1ERXhNVEF3TVRBd01URXdNREV3TURBd01URXhNREV3TURBeE1EQXdNREF3TVRBd01ERXhNREF4TVRBeE1URXhNREV4TVRBeE1ERXdNVEV4TURBeE1EQXhNVEV3TVRBd01ERXhNREV3TURBd01UQXdNREV3TURBeE1UQXhNREF4TURFeE1ERXhNREV3TVRFd01ERXdNVEF4TVRBeE1URXdNREV4TVRBd01URXdNVEV3TVRBd01UQXhNVEF4TVRFeE1ERXhNREV4TVRBPQ==\n\n"); printf("Che c'e'? devo anche dirti come decifrarle?\n"); printf("...e va bene...ti do un'indizio\n"); printf("Ricorda che, a volte, un colpo non basta."); ok=true; } else { tent++; int val=rand()%6; //random error pharases switch(val){ case 0: printf("Non ci siamo...\n\n"); break; case 1: printf("Pare di no...\n\n"); break; case 2: printf("Riprova.\n\n"); break; case 3: printf("Pensaci meglio...\n\n"); break; case 4: printf("Nah, prova ancora.\n\n"); break; case 5: printf("Ti ho mai detto quante risposte hai gia' provato?\n"); printf("Beh... sono ben "); printf("%d\n\n",tent); break; } } }while(ok=true); getchar(); return 0; } 的选择字段。

在这个课程中,我有一个返回值的方法:

ReasonId

另外,我有一个使用find方法的方法,使用基于以上枚举值的过滤器:

ReasonId  reasonId()
{
    return reasonId::ValueX;
}

在对话框方法中,我试图显示find方法返回的值,表中有更多的值,但由于我是根据Reason搜索的,所以我只想显示这些值:

ReasonId  documentReasonId()
{
    return DocumentReasons::findByReason(this.reasonId()).Name;
}

我现在配置它的方法是在这个对话框中显示我的目标,我不知道如何实现这一点。

1 个答案:

答案 0 :(得分:2)

我没有看到方法DocumentReasons::findByReason()中的代码,无论是获取单个记录(如果在那里使用firstOnly关键字),还是多个记录。所以我不打算在下面的例子中使用这个方法。

由于您要使用下拉列表,因此应使用FormComboBoxControl。您可以从这样的事情开始,并根据需要进行修改:

public Object dialog()
{
    DocumentReasons documentReasons;
    FormComboBoxControl comboBox;
    Counter i;

    dialogRunbase = super();

    select count(RecId) from documentReasons
        where documentReasons.ReasonId == ReasonId::ValueX;

    comboBox = dialogRunbase.curFormBuildGroup().addControl(FormControlType::ComboBox, 'testName');
    comboBox.items(documentReasons.RecId);

    while select Name from documentReasons
        where documentReasons.ReasonId == ReasonId::ValueX
    {
        i++;

        comboBox.item(i);
        comboBox.text(documentReasons.Name);
    }

    return dialogRunbase;
}

我还没有在AX中对它进行测试,但它应该可以正常工作。