|
#include "stdafx.h"
#include "CurOpers.h"
#include "DbOpers.h"
void CCurOpers::LoadArrCurs()
{
CppSQLite3Query q = dbAdmin.execQuery("SELECT * FROM CURRENCIES");
CCurrency cur;
CdbOpers dbop;
while (!q.eof())
{
dbop.GetCurrency(&cur, &q);
if (cur.Value == 1)
IdBasicCurID = cur.ID;
mapcur[cur.ID] = cur;
q.nextRow();
}
}
double CCurOpers::GetCurValue(int IdCur, int IdCurRef)
{
double factor = 1;
BOOL finaliza = FALSE;
CCurrency cur;
if (IdCur <= 0) return 0;
cur = mapcur[IdCur];
while (!finaliza)
{
factor *= cur.Value;
if (cur.ID == IdCurRef || cur.Reference == 0)
return factor;
cur = mapcur[cur.Reference];
}
}
CString CCurOpers::GetCurPrefix(int IdCur)
{
map <int, CCurrency>::iterator itr;
if (mapcur.empty()) return "";
if (IdCur != 0) return mapcur[IdCur].Prefix;
for(itr = mapcur.begin(); itr != mapcur.end(); ++itr)
{
if ((*itr).second.Value == 1)
return (*itr).second.Prefix;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
System developer from Argentina.
Programmed in VB 5,6,.NET, C#, Java, PL-SQL, Transac-SQL, C, C++ and even some "calculator" language.
Love to build small, useful applications.
Usually building big and complicated apps based on solid, reliable components.
Hobbies: reading, photography, chess, paddle, running.