lundi 10 janvier 2011

How to pass values between two forms

Lets suppose that we have FormA which calls FormB and passes some parameters to that form. 
For the method clicked button in formA that calls formB we can use this code: 

void clicked()
{
    LogId            login0;
    Password         password0;
    Fonctions        Fonction;
    Args             args;
    FormRun          formRun;
    Integer          emplId;

    ;

    super();
    args = new Args();
    login0 = login.valueStr();
    password0 = password.valueStr();

    select firstOnly  EmpId,title, logid, password from employee where employee.logid == login0 && employee.password == password0;

    emplid = employee.EmpId;

       if (employee.title == Fonction::None)
       {
            box::info("Wrong login or password");
       }
       else
       {
            if (employee.title == Fonction::Employee)
            {
                args.name(formstr(HistoryHolidays));
            }
            else
            {
                args.name(formstr(ConfirmHoliday));
            }

            args.parm( login.text()  );
            formRun = classfactory.formRunClass(args);
            formRun.init();
            formRun.run();
            formRun.wait();
       }
       args.parmObject( args );

}
then in the init method of the formB we have to use this:

public void init()
{
    ;
    if( element.args() )
    {
        logId =  element.args().parm();
    }
    super();
}

Thus, you can use the parameter LogId that you gets from FormA in the FormB.

Resources :
Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire