Showing posts with label using dialog to auto populate the fields. Show all posts
Showing posts with label using dialog to auto populate the fields. Show all posts

Monday, 26 December 2011

create a dialog with custtable fields

Hi Friends,

         Today we will create  a dialog with custTable fields and auto populate the fields using the methods,

1.  In AOT, create a new class named CustSelect with the following code:
class CustSelect extends RunBase
{
    DialogField fieldAccount;
    DialogField fieldName;
    DialogField fieldGroup;
    DialogField fieldCurrency;
    DialogField fieldPaymTermId;
    DialogField fieldPaymMode;
}
public container pack()
{
    return connull();
}
public boolean unpack(container packedClass)
{
    return true;
}
protected Object dialog()
{
    Dialog          dialog;
    DialogTabPage   tabGeneral;
    DialogTabPage   tabDetails;
    DialogGroup     groupCustomer;
    DialogGroup     groupPayment;

   ;
    dialog = super();
    dialog.caption("Customer information");
    dialog.allowUpdateOnSelectCtrl(true);
    tabGeneral      = dialog.addTabPage("General");
    fieldAccount    = dialog.addField(
        typeid(CustAccount),
        "Customer account");
    fieldName       = dialog.addField(typeid(CustName));
    fieldName.enabled(false);
    tabDetails      = dialog.addTabPage("Details");
    groupCustomer   = dialog.addGroup("Setup");
    fieldGroup      = dialog.addField(typeid(CustGroupId));
    fieldCurrency   = dialog.addField(typeid(CurrencyCode));
    fieldGroup.enabled(false);
    fieldCurrency.enabled(false);
    groupPayment    = dialog.addGroup("Payment");
    fieldPaymTermId = dialog.addField(typeid(CustPaymTermId));
    fieldPaymMode   = dialog.addField(typeid(CustPaymMode));
    fieldPaymTermId.enabled(false);
    fieldPaymMode.enabled(false);
    return dialog;
}
public void dialogSelectCtrl()
{
    CustTable custTable;
    ;
    custTable   = CustTable::find(fieldAccount.value());
    fieldName.value(custTable.Name);
    fieldGroup.value(custTable.CustGroup);
    fieldCurrency.value(custTable.Currency);
    fieldPaymTermId.value(custTable.PaymTermId);
    fieldPaymMode.value(custTable.PaymMode);
}
static void main(Args _args)
{
    CustSelect custSelect = new CustSelect();
    ;
    if (CustSelect.prompt())
    {
        CustSelect.run();
    }
}