Risk Category
|
Score
|
Rating
|
";
if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 1)
{
DataTable dtSummary = ds.Tables[1];
if (dtSummary.Rows.Count > 1)
{
for (int i = 0; i < dtSummary.Rows.Count; i++)
{
decimal score;
decimal ratingScore = 0;
if (decimal.TryParse(dtSummary.Rows[i]["score"].ToString(), out score))
ratingScore = score;
strTable += "";
strTable += dtSummary.Rows[i]["riskCategory"].ToString() + " | ";
strTable += ratingScore.ToString("0.00") + " | " + rating(ratingScore) + " |
";
}
}
}
else
{
string expression = "type = 'A'";
DataRow[] Category;
Category = ds.Tables[0].Select(expression);
int index = 0;
foreach (var item in Category)
{
index++;
strTable += "";
strTable += item["summaryDescription"].ToString() + " | ";
catWeightList.Add(item["summaryDescription"].ToString(), Convert.ToDecimal(item["weight"].ToString()));
string expression1 = "ParentId Like '" + index.ToString() + ".%' and type = 'B'";
DataRow[] SubCategory;
SubCategory = ds.Tables[0].Select(expression1);
decimal subCatWeight = Convert.ToDecimal(item["weight"].ToString()) / SubCategory.Length;
int subCatIndex = 0;
//subCatTotalList = new ItemList();
Dictionary subCatTotalList = new Dictionary();
foreach (var subCat in SubCategory)
{
subCatIndex++;
expression = "ParentId Like '" + index.ToString() + "." + subCatIndex.ToString() + "' and type = 'C'";
DataRow[] foundRows;
foundRows = ds.Tables[0].Select(expression);
var itemCount = foundRows.Length;
totalMaxScore = maxScore * itemCount;
decimal subTotal = 0;
foreach (var row in foundRows)
{
if (decimal.TryParse(row["score"].ToString(), out Score))
subTotal += Score;
}
subCatTotalList.Add(subCatIndex.IntToLetter(), (subTotal / totalMaxScore) * subCatWeight);
}
decimal subCatTotal = 0;
foreach (KeyValuePair kvp in subCatTotalList)
{
subCatTotal += kvp.Value;
}
var score = (subCatTotal / Convert.ToDecimal(item["weight"].ToString())) * maxScore;
strTable += (score).ToString("0.00") + " | " + rating(score) + " |
";
totalScore += score * Convert.ToDecimal(item["weight"].ToString()) / 100;
}
strTable += "";
strTable += "Overall " + " | ";
strTable += (totalScore).ToString("0.00") + " | " + rating(totalScore) + " |
";
}
strTable += "
";
divSummary.InnerHtml = strTable;
}
string rating(decimal score)
{
string result = "";
string[] scoringCriteria = hdnscoringCriteria.Value.Split(':');
if (scoringCriteria.Length >= 3)
{
if (score <= Convert.ToDecimal(scoringCriteria[0]))
result = scoringCriteria[1];
else if (score <= Convert.ToDecimal(scoringCriteria[2]))
result = scoringCriteria[3];
else if (score > Convert.ToDecimal(scoringCriteria[2]))
result = scoringCriteria[5];
}
return result;
}
}
}