lingdanglfw(DAX)

导航

load mainaccount

static

void LoadMainAccountCSV(Args _args)

{

       

 

/*

        SysExcelApplication        excel;

        SysExcelWorkbooks      workbooks;

        SysExcelWorkbook        workbook,_workbook;

        SysExcelWorksheets    worksheets,_worksheets;

        SysExcelWorksheet      worksheet,_worksheet;

        SysExcelCells              cells,_cells;

        */

        CommaIo           csvFile;

        COMVariantType              type,_type;

       

 

int                        row = 1;

        MainAccount                   _MainAccount;

        MainAccountLegalEntity        _MainAccountLegalEntity;

        FileName                      fileName;

       

 

container                     readCon = conNull();

        AccountNum                 mainAccountId;

        ;

        filename =

 

@'C:\COA_live.csv';

        csvFile =

 

new CommaIo(filename, 'r');

        csvFile.inFieldDelimiter(

 

','); // Delimiter...

       

 

/*

        #define.filename(@'C:\chartofaccount.xlsx')

        excel = SysExcelApplication::construct();

        workbooks = excel.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();

        //row = row + 1;

        type = cells.item(row+1, 1).value().variantType();

        //通过循环读取导入信息

        */

       

 

ttsBegin;

       

 

//delete_from _MainAccount;

       

 

if (csvFile)

        {

            readCon = csvFile.read();

           

 

while (csvFile.status() == IO_Status::OK)

            {

                readCon = csvFile.read();

                   

 

if(conLen(readcon) < 1)

                {

                   

 

break;

                }

               

 

if(!MainAccount::findByMainAccountId(conPeek(readCon,1)).RecId)

                {

 

                    _MainAccount.clear();

                    _MainAccount.MainAccountId =

 

conPeek(readCon,1);

                    _MainAccount.LedgerChartOfAccounts =

 

5637144576;

                   

 

switch(conPeek(readCon,2))

                    {

                       

 

case"Total":

                            _MainAccount.Type = DimensionLedgerAccountType::Total;

                           

 

break;

                       

 

case"Asset":

                            _MainAccount.Type = DimensionLedgerAccountType::Asset;

                           

 

break;

                       

 

case"Liability":

                            _MainAccount.Type = DimensionLedgerAccountType::Liability;

                           

 

break;

                       

 

case"Equity":

                            _MainAccount.Type = DimensionLedgerAccountType::Equity;

                           

 

break;

                       

 

case"BalanceSheet":

                            _MainAccount.Type = DimensionLedgerAccountType::BalanceSheet;

                           

 

break;

                       

 

case"Expense":

                            _MainAccount.Type = DimensionLedgerAccountType::Expense;

                           

 

break;

                       

 

case"Revenue":

                            _MainAccount.Type = DimensionLedgerAccountType::Revenue;

                           

 

break;

                       

 

case"ProfitAndLoss":

_MainAccount.Type = DimensionLedgerAccountType::ProfitAndLoss;

                           

 

break;

                       

 

case"Blank":

                            _MainAccount.Type = DimensionLedgerAccountType::Blank;

                           

 

break;

                       

 

case"Reporting":

                            _MainAccount.Type = DimensionLedgerAccountType::Reporting;

                           

 

break;

                       

 

case"Common_CN":

                            _MainAccount.Type = DimensionLedgerAccountType::Common_CN;

                           

 

break;

                    }

                    _MainAccount.Name =

 

conPeek(readcon,3);

                    _MainAccount.insert();

                }

               

 

else

                {

                    mainAccountId =

 

conPeek(readCon,1);

                   

 

selectforUpdate _MainAccount

                   

 

where _MainAccount.MainAccountId == mainAccountId;

                   

 

if(_MainAccount)

                    {

                       

 

switch(conPeek(readCon,2))

                        {

                           

 

case"Total":

                                _MainAccount.Type = DimensionLedgerAccountType::Total;

                               

 

break;

                           

 

case"Asset":

                                _MainAccount.Type = DimensionLedgerAccountType::Asset;

                               

 

break;

                           

 

case"Liability":

                                _MainAccount.Type = DimensionLedgerAccountType::Liability;

                               

 

break;

                           

 

case"Equity":

                                _MainAccount.Type = DimensionLedgerAccountType::Equity;

                               

 

break;

                           

 

case"BalanceSheet":

                                _MainAccount.Type = DimensionLedgerAccountType::BalanceSheet;

                               

 

break;

                           

 

case"Expense":

                                _MainAccount.Type = DimensionLedgerAccountType::Expense;

                               

 

break;

                           

 

case"Revenue":

                                _MainAccount.Type = DimensionLedgerAccountType::Revenue;

                               

 

break;

                           

 

case"ProfitAndLoss":

_MainAccount.Type = DimensionLedgerAccountType::ProfitAndLoss;

                               

 

break;

                           

 

case"Blank":

                                _MainAccount.Type = DimensionLedgerAccountType::Blank;

                               

 

break;

                           

 

case"Reporting":

                                _MainAccount.Type = DimensionLedgerAccountType::Reporting;

                               

 

break;

                           

 

case"Common_CN":

                                _MainAccount.Type = DimensionLedgerAccountType::Common_CN;

                               

 

break;

                        }

                    }

                    _MainAccount.update();

                }

            }

 

        }

       

 

ttsCommit;

 

   

 

/*

    ttsBegin;

    //delete_from _MainAccountLegalEntity;

    while select _MainAccount

    {

        _MainAccountLegalEntity.clear();

        _MainAccountLegalEntity.LegalEntity = 5637144577;

        _MainAccountLegalEntity.MainAccount = _MainAccount.RecId;

        _MainAccountLegalEntity.insert();

    }

    ttsCommit;

    */

        info(

 

"ok");

}

posted on 2015-10-30 22:53  lingdanglfw  阅读(241)  评论(0编辑  收藏  举报