private decimal Get_Assets(string accountNumber, decimal balance) { HKeInvestCode myHKeInvestCode = new HKeInvestCode(); HKeInvestData myHKeInvestData = new HKeInvestData(); ExternalFunctions myExternalFunctions = new ExternalFunctions(); DataTable dtCurrency = myExternalFunctions.getCurrencyData(); DataTable dt = myHKeInvestData.getData("SELECT type, code, shares, base FROM [SecurityHolding] WHERE accountNumber='" + accountNumber + "'"); decimal ret = balance; foreach (DataRow row in dt.Rows) { string securityCode = row["code"].ToString(); string securityType = row["type"].ToString(); string securityBase = row["base"].ToString(); decimal shares = Convert.ToDecimal(row["shares"]); decimal price = myExternalFunctions.getSecuritiesPrice(securityType, securityCode); decimal value = Math.Round(shares * price - (decimal).005, 2); DataRow[] baseRateRow = dtCurrency.Select("currency = '" + securityBase + "'"); DataRow[] toRateRow = dtCurrency.Select("currency = 'HKD'"); if (baseRateRow.Length == 1 && toRateRow.Length == 1) { value = myHKeInvestCode.convertCurrency(securityBase, baseRateRow[0]["rate"].ToString(), "HKD", toRateRow[0]["rate"].ToString(), value); } ret += value; } return(ret); }
public void convertCurrencyTest( string fromCurrency, string fromCurrencyRate, string toCurrency, string toCurrencyRate, decimal value, decimal expectedResult) { HKeInvestCode myHKeInvestCode = new HKeInvestCode(); Assert.That( myHKeInvestCode.convertCurrency(fromCurrency, fromCurrencyRate, toCurrency, toCurrencyRate, value), Is.EqualTo(expectedResult) ); }
public void TestSetup() { my = new HKeInvestCode(); }