private static void setInstrument(IList <CurrentStatusInstrument> csCal, DataTable dtInstrument) { foreach (DataRow dr in dtInstrument.Rows) { string name = dr[0].ToString(); double value = (string.IsNullOrEmpty(dr[1].ToString()) ? 0 : double.Parse(dr[1].ToString())); if (value > 0) { float roi = (string.IsNullOrEmpty(dr[2].ToString()) ? 0 : float.Parse(dr[2].ToString())); int goalid = (dr[3] == DBNull.Value) ? 0 : int.Parse(dr[3].ToString()); CurrentStatusInstrument currentStatus = new CurrentStatusInstrument(); currentStatus.InstrumentName = name; currentStatus.Amount = value; currentStatus.Roi = roi; currentStatus.GoalId = goalid; csCal.Add(currentStatus); } } }
private void addMFToCurrentStatusInstrument(int plannerId, IList <CurrentStatusInstrument> csCal) { DataTable dtInstrument = new DataTable(); dtInstrument = DataBase.DBService.ExecuteCommand(string.Format(GET_ALL_EQUITY_VALUE, plannerId)); if (dtInstrument != null && dtInstrument.Rows.Count > 0) { foreach (DataRow dr in dtInstrument.Rows) { double equityMFValue = 0; double debtMFValue = 0; double.TryParse(dr["EQUITYMFSHARES"].ToString(), out equityMFValue); double.TryParse(dr["DEBTMFSHARES"].ToString(), out debtMFValue); string name = "MF_EQUITY"; double value = equityMFValue; float roi = (string.IsNullOrEmpty(dr[2].ToString()) ? 0 : float.Parse(dr[2].ToString())); int goalid = (dr[5] == DBNull.Value) ? 0 : int.Parse(dr[5].ToString()); CurrentStatusInstrument currentStatus = new CurrentStatusInstrument(); currentStatus.InstrumentName = name; currentStatus.Amount = value; currentStatus.Roi = roi; currentStatus.GoalId = goalid; csCal.Add(currentStatus); name = "MF_DEBT"; value = debtMFValue; CurrentStatusInstrument currentStatus1 = new CurrentStatusInstrument(); currentStatus1.InstrumentName = name; currentStatus1.Amount = value; currentStatus1.Roi = roi; currentStatus1.GoalId = goalid; csCal.Add(currentStatus1); } } }