Hi,
I have posted my coding here.Please check and tell me the possible ways to implement..
private Hashtable applyingLogicForSpreadOfResultsGetAvgStd(PeerGroupAvgRatiosSdeviationsBmTypedView dt, string ratioType)
{
try
{
char[] chrSplit = new char[] { '@' };
Hashtable avgStd = new Hashtable();
double whiteRegionMinus = 0.00d, whiteRegionPlus = 0.00d, yellowRegionMinus = 0.00d, yellowRegionPlus = 0.00d, redRegionPlus = 0.00d, redRegionMinus = 0.00d, pgAvg = 0.00d, pgStdDev = 0.00d;
string[] splitStr;
string tempstr;
if (dt.Rows.Count >= 1)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
if (ratioType.ToUpper() == dt.Columns[i].ColumnName.ToUpper().ToString())
{
if (dt.Rows[0][i] != DBNull.Value)
{
tempstr = dt.Rows[0][i].ToString();
splitStr = tempstr.Split(chrSplit);
if (splitStr.Length >= 2)
{
pgAvg = Convert.ToDouble(splitStr[0].ToString());
pgStdDev = Convert.ToDouble(splitStr[1].ToString());
break;
}
}
}
}
}
if (pgAvg != 0.00d && pgStdDev != 0.00d)
{
whiteRegionPlus = pgAvg + (lowerStdDevLevel * pgStdDev); // 1 Standard Deviation
whiteRegionMinus = pgAvg - (lowerStdDevLevel * pgStdDev); // -1 Standard Deviation
yellowRegionPlus = pgAvg + (upperStdDevLevel * pgStdDev); // 1.5 Standard Deviation
yellowRegionMinus = pgAvg - (upperStdDevLevel * pgStdDev); // -1.5 Standard Deviation
redRegionPlus = pgAvg + (moreThan_1_5_Std_Deviation * pgStdDev); // 2.0 Standard Deviation
redRegionMinus = pgAvg - (moreThan_1_5_Std_Deviation * pgStdDev); // -2.0 Standard Deviation
}
avgStd.Add("whiteRegionPlus", whiteRegionPlus);
avgStd.Add("whiteRegionMinus", whiteRegionMinus);
avgStd.Add("yellowRegionPlus", yellowRegionPlus);
avgStd.Add("yellowRegionMinus", yellowRegionMinus);
avgStd.Add("redRegionPlus", redRegionPlus);
avgStd.Add("redRegionMinus", redRegionMinus);
return (avgStd);
}
catch (Exception ex)
{
CDMS.COMMON.ExceptionLog.Log.Error(ex.Message, ex);
throw ex;
}
}
Thanks in advance,
Balaji