Exemplo n.º 1
0
        /// <summary>
        /// EventHandler Vote
        /// </summary>
        /// <param name="senador">Name of senator.</param>
        /// <param name="voto">Type of vote.</param>
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                //int aux = int.Parse(lblEsperando.Text) - 1;
                int aux;
                int.TryParse(lblEsperando.Text, out int auxNumber);
                aux = auxNumber - 1;
                lblEsperando.Text = $"{aux}";
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    try {
                        if (serializator.Guardar(path, votacion) && dbManager.Guardar("Votaciones", votacion))
                        {
                            MessageBox.Show("Datos Guardados en XML y DB", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error al guardar datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    } catch (Exception exe) {
                        MessageBox.Show(exe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            Dao dao;

            if (this.groupBox2.InvokeRequired)
            {
                Votacion.voto recall = new Votacion.voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);

                    // Guardar resultados
                    dao = new Dao();
                    SerializarXML <Votacion> ser = new SerializarXML <Votacion>();

                    short abstenciones, afirmativos, negativos;
                    votacion.NombreLey          = txtLeyNombre.Text;
                    votacion.ContadorAbstencion = short.TryParse(lblAbstenciones.Text, out abstenciones)? abstenciones:(short)0;
                    votacion.ContadorAfirmativo = short.TryParse(lblAfirmativo.Text, out afirmativos) ? afirmativos : (short)0;
                    votacion.ContadorNegativo   = short.TryParse(lblNegativo.Text, out negativos) ? negativos : (short)0;

                    dao.Guardar(null, votacion);
                    ser.Guardar("archivoFM.xml", votacion);
                }
            }
        }
Exemplo n.º 3
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    try
                    {
                        SerializarXML <Votacion> ser = new SerializarXML <Votacion>();
                        ser.Guardar("archivoXML.xml", votacion);
                    }
                    catch (ErrorArchivoException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    Dao sql = new Dao();
                    sql.Guardar(votacion);
                }
            }
        }
Exemplo n.º 4
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    try
                    {
                        Dao baseDatos = new Dao();
                        baseDatos.Guardar("dbo.Votaciones", this.votacion);

                        binario.Guardar("VotacionBinaria", this.votacion); //no le agrego ubicacion para que aparezca en la carpeta del proyecto.
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    VotacionDAO db = new VotacionDAO();
                    SerializarXML <Votacion> Xml = new SerializarXML <Votacion>();
                    string path = string.Format(@"{0}\Votacion.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                    if (db.Guardar("Votaciones", this.votacion))
                    {
                        MessageBox.Show("Se ha guardado en data base", "Atencion", MessageBoxButtons.OK);
                    }
                    if (Xml.Guardar(path, this.votacion))
                    {
                        MessageBox.Show("Se ha guardado en Xml", "Atencion", MessageBoxButtons.OK);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.DelegadoVoto recall = new Votacion.DelegadoVoto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    SerializarXml <Votacion> xml = new SerializarXml <Votacion>();

                    xml.Guardar(AppDomain.CurrentDomain.BaseDirectory + "Resultados xml", votacion);
                    Dao dao = new Dao();
                    //Dao<Votacion> dao = new Dao<Votacion>();
                    StringBuilder cadena = new StringBuilder();
                    cadena.Append("server=DELL-PC\\SQLEXPRESS; database=Votacion;Integrated Security=True");
                    //"Data Source=[Instancia Del Servidor]; Initial Catalog =[Nombre de la Base de Datos]; Integrated Security = True"
                    dao.Guardar(cadena.ToString(), votacion);
                }
            }
        }
Exemplo n.º 7
0
 void ManejadorContador(string senador, Votacion.EVoto voto)
 {
     contadorEvento++;
 }
Exemplo n.º 8
0
 public void ManejadorVotos(string senador, Votacion.EVoto voto)
 {
     count++;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Contador para ver cuantas veces se llama al evento
 /// </summary>
 /// <param name="str"></param>
 /// <param name="eVoto"></param>
 public void Contador(string str, Votacion.EVoto eVoto)
 {
     contador++;
 }
Exemplo n.º 10
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Voto recall = new Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    SerializarXML xml = new SerializarXML();
                    try
                    {
                        xml.Guardar(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\votacion.xml", votacion);
                        MessageBox.Show("Se guardó los resultados de la votación en archivo XML");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("No se pudo guarda XML");
                    }
                    DAO baseDatos = new DAO();
                    try
                    {
                        baseDatos.Guardar("", votacion);
                        MessageBox.Show("Se guardó los resultados de la votación en la base de datos");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("No se pudo guarda en Base de Datos");
                    }
                }
            }
        }
Exemplo n.º 11
0
 private void UnitTest1_evento(string senador, Votacion.EVoto voto)
 {
     contador++;
 }
Exemplo n.º 12
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    string conection  = "Data Source=.\\SQLEXPRESS; Initial Catalog=votacion-sp-2018; Integrated Security=True";
                    Dao    guardarSql = new Dao();
                    SerializerXML <Votacion> guardar = new SerializerXML <Votacion>();
                    try
                    {
                        guardarSql.Guardar(conection, this.votacion);
                    }
                    catch (Exception)
                    {
                    }
                    try
                    {
                        guardar.Guardar("VotacionActual.txt", this.votacion);
                    }
                    catch (ErrorArchivoException)
                    {
                    }
                }
            }
        }
Exemplo n.º 13
0
 public static void Contador(string senador, Votacion.EVoto voto)
 {
     cont += 1;
 }
Exemplo n.º 14
0
 public void TestEvento(string senador, Votacion.EVoto voto)
 {
     this.cantidadInvocaciones--;
 }
Exemplo n.º 15
0
 private void Votacion_EventoVotoEfectuado(string senador, Votacion.EVoto voto)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 16
0
 public void Manejador(string senador, Votacion.EVoto voto)
 {
 }