예제 #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);
                    }
                }
            }
        }
예제 #2
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);
                }
            }
        }
예제 #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
                    {
                        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);
                    }
                }
            }
        }
예제 #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
                    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);
                    }
                }
            }
        }
예제 #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
                    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)
                    {
                    }
                }
            }
        }