private ProjectionPercentages CalculatePercentage() { Double percentage = 0; Double amount = 0; ProjectionPercentages percentages = new ProjectionPercentages(); List<Double> list = new List<Double>(); StoredProcedures sp = new StoredProcedures(); DataSet ds = sp.GetNetRevenueAndNetCHGByYear(); int index = 0; foreach (DataRow row in ds.Tables[0].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.netRevenue = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[1].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.grossRevenue = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[2].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.exportedRevenue = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[3].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.assessments = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[4].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.grossCHG = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[5].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.exportedCHG = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[6].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.netCHG = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[7].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.expendetures = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[8].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.costDrivers = percentage / list.Count; //list.RemoveRange(0, list.Count); //percentage = 0; //amount = 0; //index = 0; //foreach (DataRow row in ds.Tables[9].Rows) //{ // if (index == 0) // { // amount = Double.Parse(row[1].ToString()); // } // else // { // list.Add((Double.Parse(row[1].ToString()) - amount) / amount); // amount = Double.Parse(row[1].ToString()); // } // index++; //} //foreach (Double iteam in list) //{ // percentage = percentage + iteam; //} //percentages.differentialRevenue = percentage / list.Count; list.RemoveRange(0, list.Count); percentage = 0; amount = 0; index = 0; foreach (DataRow row in ds.Tables[10].Rows) { if (index == 0) { amount = Double.Parse(row[1].ToString()); } else { list.Add((Double.Parse(row[1].ToString()) - amount) / amount); amount = Double.Parse(row[1].ToString()); } index++; } foreach (Double iteam in list) { percentage = percentage + iteam; } percentages.surplus = percentage / list.Count; ViewState["percentages"] = percentages; return percentages; }