我设计了一个表格,并使用表格上的条形图来显示在特定年份(例如 2009 年)在特定项目(护理)中遇到特定问题(例如家庭问题)的学生人数。我设计了其他所有东西来从数据库中获取总数并将其显示在条形图上。我可以在表单上实现这一点,但我必须生成报告并在报告上显示相同的条形图。我的问题是我可以在不连接数据库的情况下实现这一点吗?如果是,那么太棒了,但是如何?提前致谢。
下面的代码是 3 年内在特定项目中有问题(家庭问题、吸毒者等)的学生总数的条形图代码。
public void calculateStatsFor3Years(int year1, int year2, int year3)
{
//count the number of students in with intervention in particular program in a year
intervention.Classes.Programs objPrograms = new intervention.Classes.Programs();
List<int> programCodeList = objPrograms.GetProgramCode();
List<int> numStudentsYear1 = new List<int>();
List<int> numStudentsYear2 = new List<int>();
List<int> numStudentsYear3 = new List<int>();
int temp1 = 0;
int temp2 = 0;
int temp3 = 0;
for (int counter = 0; counter < programCodeList.Count; counter++)
{
temp1 = Convert.ToInt32(objControllerClass.get_students_intervention_particular_year_program(year1, programCodeList.ElementAt(counter)));
numStudentsYear1.Add(temp1);
temp2 = Convert.ToInt32(objControllerClass.get_students_intervention_particular_year_program(year2, programCodeList.ElementAt(counter)));
numStudentsYear2.Add(temp2);
temp3 = Convert.ToInt32(objControllerClass.get_students_intervention_particular_year_program(year3, programCodeList.ElementAt(counter)));
numStudentsYear3.Add(temp3);
}//for
int[] yValues0 = numStudentsYear1.ToArray();//2011-2012
int[] yValues1 = numStudentsYear2.ToArray();//2010-2011
int[] yValues2 = numStudentsYear3.ToArray();//2009-2010
string[] xNameSeries0 = { "Agent immobilier", "Mécanique du bâtiment", "Gestion des eaus ", "Soins infirmiers ", "Anglais ", "Comtabilité et gestion ", "Bureautique ", "Architecture et gestion de réseau ", "Programmeur web ", "Assurance de dommages ", "O'Bois ", "Éducation à l'enface ", "Francisation " };
myBarChart.Series[0].Points.DataBindXY(xNameSeries0, yValues0);
myBarChart.Series[1].Points.DataBindXY(xNameSeries0, yValues1);
myBarChart.Series[2].Points.DataBindXY(xNameSeries0, yValues2);
//legend text
myBarChart.Series[0].LegendText = year1.ToString();
myBarChart.Series[1].LegendText = year2.ToString();
myBarChart.Series[2].LegendText = year3.ToString();
}//calculateStatsFor3Years()
这是我需要在 Crystal Reports 中显示的水平图的屏幕截图。
http://i1342.photobucket.com/albums/o765/CSharpJunior/C%20Sharp%20project/horizontalGraph.jpg