protected void Cadastrar(object sender, EventArgs e)
        {
            Models.Candidato c = new Models.Candidato();
            c.Nome = txtNome.Text;

            try
            {
                c.Numero = Int32.Parse(txtNumero.Text);
            }
            catch (Exception)
            {
                Response.Redirect("/Candidato/CadastroError");
            }

            Models.Candidato c1 = CandidatoDAO.VerificarCandidatoPorNome(c);
            Models.Candidato c2 = CandidatoDAO.VerificarCandidatoPorNumero(c);

            if (c1 == null && c2 == null)
            {
                if (CandidatoDAO.AdicionarCandidato(c))
                {
                    Response.Redirect("/Candidato/CadastroSuccess");
                }
                else
                {
                    Response.Redirect("/Candidato/CadastroError");
                }
            }
            else
            {
                Response.Redirect("/Candidato/CadastroExistente");
            }
        }
Exemple #2
0
        public void populaCandidato(string eleicao, string codMunicipio, string idCargo)
        {
            CandidatoDAO candidatoDAO = new CandidatoDAO();

            try
            {
                cbCandidato.DataSource    = candidatoDAO.selectCandidato(eleicao, codMunicipio, idCargo);
                cbCandidato.ValueMember   = "cpf";
                cbCandidato.DisplayMember = "nome";
                cbCandidato.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao popular o combox de candidato " + ex);
            }
        }
 public CandidatoController(CandidatoDAO dao)
 {
     this.dao = dao;
 }
        public void gerarGraficosColuna1()
        {
            CandidatoDAO    candidatoDAO    = new CandidatoDAO();
            MySqlDataReader mySqlDataReader = candidatoDAO.selectVotoZona();

            Axis axis = new Axis()
            {
                Separator = new Separator()
                {
                    Step      = 1,
                    IsEnabled = false
                }
            };

            ColumnSeries col = new ColumnSeries()
            {
                DataLabels = true,
                Values     = new ChartValues <int>(),
                Title      = "ZONA 11",
                LabelPoint = point => point.Y.ToString(),
            };
            ColumnSeries col1 = new ColumnSeries()
            {
                DataLabels = true,
                Values     = new ChartValues <int>(),
                Title      = "ZONA 299",
                LabelPoint = point => point.Y.ToString(),
            };

            axis.Labels = new List <string>();
            List <ColumnSeries> LineSeries = new List <ColumnSeries>();

            if (mySqlDataReader.HasRows)
            {
                while (mySqlDataReader.Read())
                {
                    if (mySqlDataReader["zona"].Equals(11))
                    {
                        col.Values.Add(mySqlDataReader["qtdVotos"]);
                        axis.Labels.Add(mySqlDataReader["nome"].ToString());
                    }
                    else
                    {
                        col1.Values.Add(mySqlDataReader["qtdVotos"]);
                        axis.Labels.Add(mySqlDataReader["nome"].ToString());
                    }
                }
            }
            LineSeries.Add(col);
            LineSeries.Add(col1);
            foreach (ColumnSeries c in LineSeries)
            {
                ccVotosZona.Series.Add(c);
            }
            ccVotosZona.AxisX.Add(axis);
            ccVotosZona.AxisY.Add(new Axis
            {
                LabelFormatter = value => value.ToString(),
                Separator      = new Separator()
            });
        }
        public void gerarGraficoPizza()
        {
            CandidatoDAO    candidatoDAO = new CandidatoDAO();
            MySqlDataReader reader       = candidatoDAO.selectVotoEleicao();

            int[]    votos = new int[3];
            string[] nome  = new string[3];

            PieSeries pie0 = new PieSeries()
            {
                Values     = new ChartValues <int>(),
                PushOut    = 15,
                DataLabels = true,
                LabelPoint = point => point.Y.ToString()
            };

            PieSeries pie1 = new PieSeries()
            {
                Values     = new ChartValues <int>(),
                PushOut    = 15,
                DataLabels = true,
                LabelPoint = point => point.Y.ToString()
            };

            PieSeries pie2 = new PieSeries()
            {
                Values     = new ChartValues <int>(),
                PushOut    = 15,
                DataLabels = true,
                LabelPoint = point => point.Y.ToString()
            };

            List <PieSeries> pieSeries = new List <PieSeries>();

            if (reader.HasRows)
            {
                for (int i = 0; i < 3; i++)
                {
                    reader.Read();
                    votos[i] = Convert.ToInt32(reader["votos"]);
                    nome[i]  = reader["nome"].ToString();
                }
            }

            pie0.Values.Add(votos[0]);
            pie0.Title = nome[0];
            pie1.Values.Add(votos[1]);
            pie1.Title = nome[1];
            pie2.Values.Add(votos[2]);
            pie2.Title = nome[2];


            pieSeries.Add(pie0);
            pieSeries.Add(pie1);
            pieSeries.Add(pie2);
            foreach (var x in pieSeries)
            {
                pcVotosTotal.Series.Add(x);
            }

            pcVotosTotal.LegendLocation = LegendLocation.Right;
        }
        public void populaDataGrid()
        {
            CandidatoDAO candidatoDAO = new CandidatoDAO();

            dtGridVotoSecao.DataSource = candidatoDAO.selectVotoSecao();
        }
Exemple #7
0
        public void graficoPizza(string codMun, string idEleicao, string cpf, string idCargo)
        {
            pieChart1.Series.Clear();

            CandidatoDAO    candidatoDAO    = new CandidatoDAO();
            MySqlDataReader mySqlDataReader = candidatoDAO.selectVotoZonaCandidato(codMun, idEleicao, cpf, idCargo);
            int             linhas          = candidatoDAO.countZonaCandidato(codMun, idEleicao, cpf, idCargo);

            List <PieSeries> pieSeries = new List <PieSeries>();

            int[]    votos = new int[linhas];
            string[] nome  = new string[linhas];
            string[] zona  = new string[linhas];



            if (mySqlDataReader.HasRows)
            {
                int cont = 0;
                while (mySqlDataReader.Read())
                {
                    votos[cont] = Convert.ToInt32(mySqlDataReader["qtdVotos"]);
                    nome[cont]  = mySqlDataReader["nome"].ToString();
                    zona[cont]  = mySqlDataReader["zona"].ToString();
                    cont++;
                }
            }


            if (linhas == 1)
            {
                PieSeries pie0 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };

                pie0.Values.Add(votos[0]);
                pie0.Title = zona[0];

                pieSeries.Add(pie0);
            }
            else if (linhas == 2)
            {
                PieSeries pie0 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };

                PieSeries pie1 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };

                pie0.Values.Add(votos[0]);
                pie0.Title = zona[0];
                pie1.Values.Add(votos[1]);
                pie1.Title = zona[1];

                pieSeries.Add(pie0);
                pieSeries.Add(pie1);
            }
            else if (linhas == 3)
            {
                PieSeries pie0 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };

                PieSeries pie1 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };

                PieSeries pie2 = new PieSeries()
                {
                    Values     = new ChartValues <int>(),
                    PushOut    = 15,
                    DataLabels = true,
                    LabelPoint = point => point.Y.ToString()
                };
                pie0.Values.Add(votos[0]);
                pie0.Title = zona[0];
                pie1.Values.Add(votos[1]);
                pie1.Title = zona[1];
                pie2.Values.Add(votos[2]);
                pie2.Title = zona[2];

                pieSeries.Add(pie0);
                pieSeries.Add(pie1);
                pieSeries.Add(pie2);
            }

            foreach (var x in pieSeries)
            {
                pieChart1.Series.Add(x);
            }



            pieChart1.LegendLocation = LegendLocation.Right;
        }
Exemple #8
0
        public void grafico(string codMun, string idEleicao, string cpf, string idCargo)
        {
            cartesianChart1.Series.Clear();
            cartesianChart1.AxisY.Clear();
            cartesianChart1.AxisX.Clear();

            CandidatoDAO candidatoDAO = new CandidatoDAO();
            int          numCand      = candidatoDAO.getNumberCandidato(codMun, idEleicao, cpf, idCargo);

            MySqlDataReader mySqlDataReader = candidatoDAO.selectVotoSecaoPorCandidato(codMun, idCargo, numCand.ToString());



            LineSeries column = new LineSeries()
            {
                DataLabels = true,
                Values     = new ChartValues <int>(),
                LabelPoint = point => point.Y.ToString()
            };

            LineSeries column1 = new LineSeries()
            {
                DataLabels = true,
                Values     = new ChartValues <int>(),
                LabelPoint = point => point.Y.ToString()
            };



            Axis axis = new Axis()
            {
                Separator = new Separator()
                {
                    Step      = 1,
                    IsEnabled = false
                }
            };


            axis.Labels = new List <string>();
            List <LineSeries> LineSeries = new List <LineSeries>();



            if (mySqlDataReader.HasRows)
            {
                while (mySqlDataReader.Read())
                {
                    if (mySqlDataReader["zona"].Equals(11))
                    {
                        column.Values.Add(Convert.ToInt32(mySqlDataReader["VOTOS"]));
                        axis.Labels.Add("Seção " + mySqlDataReader["secao"].ToString());
                        column.Title = "Zona " + mySqlDataReader["zona"].ToString();
                    }
                    else
                    {
                        column1.Values.Add(Convert.ToInt32(mySqlDataReader["VOTOS"]));
                        axis.Labels.Add("Seção " + mySqlDataReader["secao"].ToString());
                        column1.Title = "Zona " + mySqlDataReader["zona"].ToString();
                    }
                }
            }

            LineSeries.Add(column);
            LineSeries.Add(column1);
            foreach (LineSeries c in LineSeries)
            {
                cartesianChart1.Series.Add(c);
            }

            cartesianChart1.Zoom = ZoomingOptions.X;
            cartesianChart1.AxisX.Add(axis);
            cartesianChart1.AxisY.Add(new Axis
            {
                LabelFormatter = value => value.ToString()
            });
            cartesianChart1.LegendLocation = LegendLocation.Top;
        }