//Parameter list public static HighChartsBarGraphInfo GetReportProjectFundsAtLocation() { int retValue = -1; IList<string> projects = new List<string>(); IList<string> locations = new List<string>(); IList<BarGraphSeriesInfo> series = new List<BarGraphSeriesInfo>(); HighChartsBarGraphInfo result = new HighChartsBarGraphInfo(); result.categories = new List<string>(); IList<ReportData> data = new List<ReportData>(); using (SqlDataReader dr = ProjManagementAdmin.GetAllLocations(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { string locationName = dr["location_name"].ToString(); locations.Add(locationName); } //dr.Close(); } using (SqlDataReader dr = ProjManagementAdmin.GetAllProjects(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { string projectName = dr["project_name"].ToString(); projects.Add(projectName); } //dr.Close(); } using (SqlDataReader dr = ProjManagementAdmin.GetReportProjectsFunds(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { ReportData d = new ReportData(); d.LocationName = dr["location_name"].ToString(); d.ProjectName = dr["project_name"].ToString(); d.FundAmount = Convert.ToInt32(dr["amount"]); data.Add(d); } } result.series = new List<BarGraphSeriesInfo>(); foreach (string l in locations) { BarGraphSeriesInfo b = new BarGraphSeriesInfo(); b.data = new List<int>(); b.name = l; foreach (string p in projects) { bool flag = false; for(int i =0;i<data.Count;i++) { if(data[i].ProjectName.Equals(p)&& data[i].LocationName.Equals(l)) { b.data.Add(data[i].FundAmount); flag = true; } } if(flag==false) { b.data.Add(0); } } result.series.Add(b); } result.categories = projects; return result; }
public static HighChartsBarGraphInfo GetReportProjectFundsAtLocation() //Parameter list { int retValue = -1; IList <string> projects = new List <string>(); IList <string> locations = new List <string>(); IList <BarGraphSeriesInfo> series = new List <BarGraphSeriesInfo>(); HighChartsBarGraphInfo result = new HighChartsBarGraphInfo(); result.categories = new List <string>(); IList <ReportData> data = new List <ReportData>(); using (SqlDataReader dr = ProjManagementAdmin.GetAllLocations(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { string locationName = dr["location_name"].ToString(); locations.Add(locationName); } //dr.Close(); } using (SqlDataReader dr = ProjManagementAdmin.GetAllProjects(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { string projectName = dr["project_name"].ToString(); projects.Add(projectName); } //dr.Close(); } using (SqlDataReader dr = ProjManagementAdmin.GetReportProjectsFunds(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { ReportData d = new ReportData(); d.LocationName = dr["location_name"].ToString(); d.ProjectName = dr["project_name"].ToString(); d.FundAmount = Convert.ToInt32(dr["amount"]); data.Add(d); } } result.series = new List <BarGraphSeriesInfo>(); foreach (string l in locations) { BarGraphSeriesInfo b = new BarGraphSeriesInfo(); b.data = new List <int>(); b.name = l; foreach (string p in projects) { bool flag = false; for (int i = 0; i < data.Count; i++) { if (data[i].ProjectName.Equals(p) && data[i].LocationName.Equals(l)) { b.data.Add(data[i].FundAmount); flag = true; } } if (flag == false) { b.data.Add(0); } } result.series.Add(b); } result.categories = projects; return(result); }