} // end of getCrossRate() public int getCrossRateCash(int aTradeMatchId, string aTradeDate, string aSecType, string aTradingCur, string aPortfolio, ref string aCrossRate, ref string aConversionInstruction) { int rtn = 0; //double number; string secType = string.Empty; string secISOCode = string.Empty; string errMsg = string.Empty; string securityCur = string.Empty; string tradeDate = string.Empty; string tradingCur = string.Empty; try { using (SqlConnection conn = new SqlConnection(dbConnection)) { conn.Open(); // 1. create a command object identifying the stored procedure SqlCommand cmd = new SqlCommand("usp_GetCrossRateCash", conn); // 2. set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; // 3. add parameter to command, which will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@tradematchid", aTradeMatchId)); cmd.Parameters.Add(new SqlParameter("@portfolio", aPortfolio)); // execute the command using (SqlDataReader rdr = cmd.ExecuteReader()) { // iterate through results while (rdr.Read()) { aCrossRate = rdr[0].ToString(); secType = rdr[1].ToString(); tradeDate = rdr[2].ToString(); } // end of while loop // // when cross rate is unavailable from Moxy try to get it from Portia // //if (String.IsNullOrEmpty(secType)) { secType = aSecType; } secType = aSecType; getISOCurrency(aTradingCur, ref tradingCur); if (String.IsNullOrEmpty(aCrossRate)) { if (PortiaDatabase.getLastCrossRate(secType, tradingCur, aTradeDate, ref aCrossRate) == -1) { screen.AppendText(String.Format(GetCurrentMethod() + "--->No cross rate for : {0} {1} {2} {3} {4} in Portia", securityCur, aTradingCur, tradeDate)); } } // get security ISO Code //if (getISOCurrency(aSecType, ref secISOCode) != -1 && getConversionInstructions(secISOCode, aTradingCur, ref conversionInstruction) != -1) if (getISOCurrency(aSecType, ref secISOCode) != -1 && getConversionInstructions(secType, tradingCur, ref aConversionInstruction) != -1) { //screen.AppendText(String.Format("\r\nFound cross rate: {0} for trade match id: {1}.", aCrossRate, aTradeMatchId)); } // end of if } // end of using } // end of outter using } // end of try catch (Exception e) { rtn = -1; screen.AppendText(Globals.saveErr(e.Message + "\r\n")); Globals.WriteErrorLog(e.Message); } return(rtn); } // end of getCrossRateCash()
/// <summary> /// Constructor /// </summary> public Trade(TextBox aScreen, string aLine, string aDbConnMoxy, string aDbConnPortia, string aTradingCurrencySP, string aLastCrossRateSP, string aReportingCurrencySP, string aSellRuleSP) { int rtn = 0; tradeCnt++; Screen = aScreen; dbConnMoxy = aDbConnMoxy; dbConnPortia = aDbConnPortia; tradingCurrencyStoredProc = aTradingCurrencySP; reportingCurrencyStoredProc = aReportingCurrencySP; sellRuleStoredProc = aSellRuleSP; lastCrossRateStoredProc = aLastCrossRateSP; items = aLine.Split(','); Screen.AppendText("\r\n ---\r\n Tran code: " + items[1] + " Line in the file: " + tradeCnt); if (tradeCnt == 27) { rtn = 0; } // // when lot location is null or nothing --> set default lot location: 254 // if (String.IsNullOrEmpty(items[29])) { items[29] = "254"; } md = new MoxyDatabase(dbConnMoxy, screen); pd = new PortiaDatabase(dbConnPortia, screen, tradingCurrencyStoredProc, lastCrossRateStoredProc, sellRuleStoredProc); rtn = md.getISOCurrency(items[3], ref securityCur); rtn = pd.getTradingCurrency(tradingCurrencyStoredProc, items[0].Replace("fc", string.Empty), ref tradeCur); rtn = pd.getReportingCurrency(reportingCurrencyStoredProc, items[0].Replace("fc", string.Empty), ref repCur); if (String.IsNullOrEmpty(tradeCur)) { tradeCur = "USD"; } clearSettleFX(ref items); // based on these values the appropriate conversion function selected if (items[4].Equals("$cash")) { tranType = "cash"; } else { tranType = "equity"; } if (tradeCur.Equals("USD")) { portType = "Us"; } else { portType = "NonUs"; } if (securityCur.Equals(tradeCur)) { secType = "SameCur"; } else { secType = "DiffCur"; } if ((items[1].Equals("sl") || items[1].Equals("SL"))) { tranCode = "Sell"; } else { tranCode = "Buy"; } rtn = 0; } // end of constructor