Apr 15, 2013

How create the records on click event with required format

The following code helps to create new records in the current form on a button click

void clicked()

{

    Dialog                                 dialog;
    DialogField                         textField,field1,field2;
    UBM_BookValue               FromBook,ToBook,noOfHashs,fromLen,toLen;
    UBM_ReceiptBook           ReceiptBookTable;
    UBM_ReceiptBookId        formatText,commonText,hashText;
    str                                        hashstr;
    ;
    super();

    dialog        =  new Dialog("Create Receipt BookId's");
    dialog.addText("Enter the From Receipt BookId and To Receipt BookId");
    textField   = dialog.addField(extendedTypeStr(UBM_Format)," Format  : ");
    field1        = dialog.addField(extendedTypeStr(UBM_BookValue)," From Book");
    field2        = dialog.addField(extendedTypeStr(UBM_BookValue),"TO Book");
    dialog.run();

    if (dialog.closedOk())
    {
        formatText  = textField.value();
       //noOfHashs   = strNfind(formatText,"#",1,strLen(formatText));
        //hashstr     = subStr(formatText,strNfind(formatText,"#",1,strLen(formatText)),strLen(formatText));       

        FromBook        = field1.value();
        ToBook             = field2.value(); 

        while(FromBook <=  ToBook)
        {
            hashText   = strReplace(hashText,"#",int2str(0));
            ReceiptBookTable.ReceiptBookId    =  NumberSeq::numInsertFormat(any2int FromBook),formatText);
            ReceiptBookTable.Description   = ReceiptBookTable.ReceiptBookId;
            ReceiptBookTable.insert();
            FromBook++;
        }

    } 
    UBM_ReceiptBook_ds.research();
    UBM_ReceiptBook_ds.reread(); 

}

 

1 comment:

Anonymous said...

Excellent ...