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); } } }
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 path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Votacion.xml"; SerializarXML <Votacion> serializarXML = new SerializarXML <Votacion>(); serializarXML.Guardar(path, this.votacion); Dao sql = new Dao(); sql.Guardar("HOLA", this.votacion); } } }