[chronojump] exhibitionCardGenerator with statistics
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] exhibitionCardGenerator with statistics
- Date: Wed, 27 Feb 2019 12:41:50 +0000 (UTC)
commit 61f832032a33eb65ed37e777975876812917c8b1
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Feb 27 13:40:03 2019 +0100
exhibitionCardGenerator with statistics
exhibitions/exhibitionCardGenerator.cs | 57 ++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/exhibitions/exhibitionCardGenerator.cs b/exhibitions/exhibitionCardGenerator.cs
index bd6e8af7..c7508d07 100644
--- a/exhibitions/exhibitionCardGenerator.cs
+++ b/exhibitions/exhibitionCardGenerator.cs
@@ -115,6 +115,8 @@ public class ExhibitionCardGenerator
else if(option == "e")
{
new Statistics(dbcmd);
+ printOption("", "(enter)", " ?");
+ option = Console.ReadLine();
}
else if(option == "t")
createTablesPrepare();
@@ -379,7 +381,6 @@ public class School
int count = 0;
while(reader.Read()) {
- Console.WriteLine("readed: [" + reader[0].ToString());
if(reader[0].ToString() != "")
count = Convert.ToInt32(reader[0].ToString());
}
@@ -706,18 +707,68 @@ public class Statistics
public Statistics(SqliteCommand dbcmd)
{
this.dbcmd = dbcmd;
+
+ Console.WriteLine("\n--- EstadÃstiques ---");
+ Console.WriteLine("\nTotal de alumnes: " + totalPersons().ToString());
+ Console.WriteLine("\nTotal de centre: " + totalSchools().ToString());
+ Console.WriteLine("\nRanking de centres (per nombre de inscrits): ");
+ schoolsRanking();
}
- private void totalPersons()
+ private int totalPersons()
{
+ dbcmd.CommandText = "SELECT count(*) FROM person";
+ if(Options.Debug)
+ Console.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ int count = 0;
+ while(reader.Read()) {
+ if(reader[0].ToString() != "")
+ count = Convert.ToInt32(reader[0].ToString());
+ }
+ reader.Close();
+ return count;
}
- private void totalSchools()
+ private int totalSchools()
{
+ dbcmd.CommandText = "SELECT count(*) FROM school";
+ if(Options.Debug)
+ Console.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ int count = 0;
+ while(reader.Read()) {
+ if(reader[0].ToString() != "")
+ count = Convert.ToInt32(reader[0].ToString());
+ }
+ reader.Close();
+ return count;
}
private void schoolsRanking()
{
+ dbcmd.CommandText = "SELECT school.name, count(*) AS conta FROM person, school WHERE
person.schoolID = school.id GROUP BY person.schoolID ORDER BY conta DESC LIMIT 10";
+ if(Options.Debug)
+ Console.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ //Console.WriteLine("Escola: Participants");
+ while(reader.Read()) {
+ if(reader[0].ToString() != "")
+ Console.WriteLine(string.Format("- {0}: {1}", reader[0], reader[1]));
+ }
+ reader.Close();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]