public static List <clsSwitchDetails_Client> addFund(int intNewFundID, List <clsSwitchDetails_Client> currentlistSwitchDetails, string strClientID, string strClientCurrency, string strUserID) { float fTotalAllocation = 0; float fTotalValue = currentlistSwitchDetails[0].propTotalValue; foreach (clsSwitchDetails_Client SwitchDetail in currentlistSwitchDetails) { fTotalAllocation = fTotalAllocation + SwitchDetail.propAllocation; if (SwitchDetail.propFund.propFundID == intNewFundID) { throw new Exception("Fund already exists."); } } clsSwitchDetails_Client NewSwitchDetail = new clsSwitchDetails_Client(); NewSwitchDetail.propCreated_By = strUserID; NewSwitchDetail.propFund = new clsFund(intNewFundID); NewSwitchDetail.propIsDeletable = true; NewSwitchDetail.propSwitchDetailsID = 0; //NewSwitchDetail.propSwitchScheme = NewSwitchDetail.propSwitchScheme; NewSwitchDetail.propTotalAllocation = fTotalAllocation; NewSwitchDetail.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(strClientID, NewSwitchDetail.propFund.propCurrency); currentlistSwitchDetails.Add(NewSwitchDetail); return(currentlistSwitchDetails); }
public static List <clsSwitchDetails_Client> getSwitchDetails(int intSwitchID) { SqlConnection con1 = new clsSystem_DBConnection(clsSystem_DBConnection.strConnectionString.NavIntegrationDB).propConnection; List <clsSwitchDetails_Client> listSwitchDetails = new List <clsSwitchDetails_Client>(); clsSwitch IFASwitch = new clsSwitch(intSwitchID); clsPortfolio Portfolio = new clsPortfolio(IFASwitch.propClientID.ToString(), IFASwitch.propPortfolioID); //throw new Exception(Portfolio.propPortfolioDetails.Count.ToString()); //throw new Exception(intSwitchID.ToString() + " - " + IFASwitch.propPortfolioID); SqlCommand cmd = new SqlCommand(); SqlDataReader dr1; con1.Open(); cmd.Connection = con1; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "[SWITCHclient_DetailsGet]"; cmd.Parameters.Add("@param_intSwitchID", System.Data.SqlDbType.Int).Value = intSwitchID; dr1 = cmd.ExecuteReader(); if (!dr1.HasRows) { SqlConnection con2 = new clsSystem_DBConnection(clsSystem_DBConnection.strConnectionString.NavIntegrationDB).propConnection; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = con2; cmd2.CommandType = System.Data.CommandType.StoredProcedure; cmd2.CommandText = "[SWITCH_DetailsGet]"; cmd2.Parameters.Add("@param_intSwitchID", System.Data.SqlDbType.Int).Value = intSwitchID; con2.Open(); dr1 = cmd2.ExecuteReader(); } float fTotalAllocation = 0; while (dr1.Read()) { clsSwitchDetails_Client newClsSwitchDetails = new clsSwitchDetails_Client(); newClsSwitchDetails.propAllocation = float.Parse(Math.Round(double.Parse(dr1["Allocation"].ToString()), 2).ToString()); newClsSwitchDetails.propCreated_By = dr1["Created_By"].ToString(); newClsSwitchDetails.propDate_Created = DateTime.Parse(dr1["Date_Created"].ToString()); newClsSwitchDetails.propDate_LastUpdate = DateTime.Parse(dr1["Date_LastUpdate"].ToString()); newClsSwitchDetails.propFund = new clsFund(int.Parse(dr1["FundID"].ToString())); newClsSwitchDetails.propFundID = int.Parse(dr1["FundID"].ToString()); newClsSwitchDetails.propSwitchDetailsID = int.Parse(dr1["SwitchDetailsID"].ToString()); newClsSwitchDetails.propSwitchID = int.Parse(dr1["SwitchID"].ToString()); newClsSwitchDetails.propUpdated_By = dr1["Updated_By"].ToString(); newClsSwitchDetails.propIsDeletable = dr1["isDeletable"].ToString().Equals("1") ? true : false; //if (Portfolio.propPortfolioDetails[0].propClientCurrency != newClsSwitchDetails.propFund.propCurrency) //{ newClsSwitchDetails.propUnits = clsSwitchDetails.computeUnits(newClsSwitchDetails.propAllocation, float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()), clsCurrency.convertToClientCurrency(IFASwitch.propClientID, newClsSwitchDetails.propFund.propPrice, newClsSwitchDetails.propFund.propCurrency)); //} //else //{ // newClsSwitchDetails.propUnits = clsSwitchDetails.computeUnits(newClsSwitchDetails.propAllocation, // float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()), // newClsSwitchDetails.propFund.propPrice); //} newClsSwitchDetails.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(IFASwitch.propClientID, newClsSwitchDetails.propFund.propCurrency); //newClsSwitchDetails.propValue = clsSwitchDetails.computeValue(newClsSwitchDetails.propAllocation, Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient); newClsSwitchDetails.propTotalValue = float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()); newClsSwitchDetails.propValue = clsSwitchDetails.computeValue(newClsSwitchDetails.propAllocation, newClsSwitchDetails.propTotalValue); fTotalAllocation = fTotalAllocation + newClsSwitchDetails.propAllocation; newClsSwitchDetails.propTotalAllocation = fTotalAllocation; listSwitchDetails.Add(newClsSwitchDetails); } con1.Close(); cmd.Dispose(); con1.Dispose(); return(listSwitchDetails); }