public object GerarDataEstadoCivil() { try { var data = new Charts.Data(); var connString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString; var qry = @"Select ec.Estado as Estado, COUNT(*) as Total from Resultado r inner join EstadoCivil ec on r.IdEstadoCivil = ec.IdEstadoCivil Group by ec.Estado Order By ec.Estado "; using (SqlConnection conn = new SqlConnection(connString)) { var cmd = new SqlCommand(qry, conn); conn.Open(); var reader = cmd.ExecuteReader(); var dsEstadoCivilo = new DonutDataSet() { label = "Estado Civil", backgroundColor = new List <string> { Color.DodgerBlue.Name, Color.DarkGray.Name, Color.Moccasin.Name, Color.DarkSalmon.Name, Color.Wheat.Name }, hoverBackgroundColor = new List <string> { Color.DodgerBlue.Name, Color.DarkGray.Name, Color.Moccasin.Name, Color.DarkSalmon.Name, Color.Wheat.Name } }; if (reader.HasRows) { while (reader.Read()) { data.labels.Add(reader["Estado"].ToString()); dsEstadoCivilo.data.Add(Convert.ToInt32(reader["Total"])); } } conn.Close(); data.datasets.Add(dsEstadoCivilo); } return(data); } catch (Exception e) { SystemLog.Erro(e); return(null); } }
public object GerarDataFilhos() { try { var data = new Charts.Data(); var connString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString; var qry = @"Select ifi.Intervalo, COUNT(*) as Total from Resultado r inner join IntervaloFilhos ifi on r.IdIntervaloFilhos = ifi.IdIntervaloFilhos group by ifi.Intervalo, ifi.IdIntervaloFilhos Order By ifi.IdIntervaloFilhos"; using (SqlConnection conn = new SqlConnection(connString)) { var cmd = new SqlCommand(qry, conn); conn.Open(); var reader = cmd.ExecuteReader(); var ds = new DonutDataSet() { label = "Estado Civil", backgroundColor = new List <string> { "#e1bcc3", "#a1cde8", "#757da4", "#b9e5e8", "#c6b6d1" }, hoverBackgroundColor = new List <string> { "#e1bcc3", "#a1cde8", "#757da4", "#b9e5e8", "#c6b6d1" } }; if (reader.HasRows) { while (reader.Read()) { data.labels.Add(reader["Intervalo"].ToString()); ds.data.Add(Convert.ToInt32(reader["Total"])); } } conn.Close(); data.datasets.Add(ds); } return(data); } catch (Exception e) { SystemLog.Erro(e); return(null); } }
public object GerarDataGenero() { try { var data = new Charts.Data(); var connString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString; var qry = @"Select g.Nome as Genero, Count(*) as Total from Resultado r inner join Genero g on r.IdGenero = g.IdGenero Group By g.Nome Order By g.Nome"; using (SqlConnection conn = new SqlConnection(connString)) { var cmd = new SqlCommand(qry, conn); conn.Open(); var reader = cmd.ExecuteReader(); var dsGenero = new DonutDataSet() { label = "Generos", backgroundColor = new List <string> { Color.Pink.Name, Color.DodgerBlue.Name }, hoverBackgroundColor = new List <string> { Color.Pink.Name, Color.DodgerBlue.Name } }; if (reader.HasRows) { while (reader.Read()) { data.labels.Add(reader["Genero"].ToString()); dsGenero.data.Add(Convert.ToInt32(reader["Total"])); } } conn.Close(); data.datasets.Add(dsGenero); } return(data); } catch (Exception e) { SystemLog.Erro(e); return(null); } }