Active price upload from excel

Hi,

I'm trying to update active price for items through excel, I added one button in inventitemprice form.. when I try to update for 1 item its getting updated but for more than 1 item its not updating..

My code is

 

void clicked()
{
    //super();
    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    COMVariantType                  type;
    System.DateTime                 ShlefDate;
    FilenameOpen                    filename;
    dialogField                     dialogFilename;
    Dialog                          dialog;

    //Table Declarations Starts
    InventItemPrice                 inventprice;
    //Table Declartions Ends
    //fields
    ItemId                          _itemid;
    CostingVersionId                _versionid;
    CostingVersionPriceType         _type;
    Price                           _price;
    CostingVersionId                _version;
    InventDimId                     _invent;
    int                             row;
    ;
    dialog              =   new Dialog("Excel Upoad");
    dialogFilename      =   dialog.addField(typeId(FilenameOpen));
    dialog.filenameLookupTitle("Upload from Excel");
    dialog.caption("Sales Price Excel Upload");
    dialogFilename.value(filename);
    if(!dialog.run())
    return;
    filename            =   dialogFilename.value();
    info(filename);
    application         =   SysExcelApplication::construct();
    workbooks           =   application.workbooks();

    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }

    workbook            =   workbooks.item(1);
    worksheets          =   workbook.worksheets();
    worksheet           =   worksheets.itemFromNum(1);
    cells               =   worksheet.cells();

    try
    {
        ttsbegin;
        do
        {
            row++;
            _itemid                 =   cells.item(row, 1).value().bStr();
            _type                   =   new DictEnum(enumNum(CostingVersionPriceType)).name2Value(cells.item(row,2).value().bStr()) ;
            _price                  =   cells.item(row, 3).value().double();
            _version                =   cells.item(row, 4).value().bStr();
            //_invent                 =   cells.item(row, 5).value().bStr();
            if(row > 1)
            {
            //update into inventprice table
            while select forupdate Price from inventprice where inventprice.ItemId==_itemid && inventprice.VersionId==_version && inventprice.PriceType==_type
            {
                if(inventprice.RecId)
                {
                     ttsbegin;
                
                     inventprice.Price=_price;
                     inventprice.update();
                     info(strfmt("Price updated successfully",_itemid));
                     ttscommit;
                      ItemPriceActivated_ds.research();
                }

                else
                {
                     warning(strfmt("Price can't be update for (%1)",_itemid));
                }
             }

            }
         type = cells.item(row+1, 1).value().variantType();
         }
             while (type != COMVariantType::VT_EMPTY);
             application.quit();
             ttscommit;
         }
            catch
            {
            Error("Upload Failed");
            }
}

My excel file is

may I know how to update? 

Related
Recommended