Created
June 8, 2014 22:35
-
-
Save Fhernd/da3e336ede4947a34640 to your computer and use it in GitHub Desktop.
Representa el control ControlCandidato.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ===++=== | |
// | |
// OrtizOL | |
// | |
// ===--=== | |
/*============================================================ | |
// | |
// Clase: ControlCandidato.cs | |
// | |
// Original en: http://goo.gl/MXqqQk | |
// | |
// Propósito: Controles para la visualización de datos | |
// de un candidato. | |
// | |
============================================================*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Drawing; | |
using System.Data; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using N1_EleccionesCupi2.Modelo; | |
namespace N1_EleccionesCupi2.GUI | |
{ | |
/// <summary> | |
/// Control para los datos controles de visualización de los datos de un candidato. | |
/// </summary> | |
public partial class ControlCandidato : UserControl | |
{ | |
#region Campos | |
/// <summary> | |
/// ID del candidato. | |
/// </summary> | |
private int numeroCandidato; | |
#endregion | |
#region Campos (componentes de interfaz) | |
/// <summary> | |
/// Interfaz de usuario principal. | |
/// </summary> | |
private Principal principal; | |
#endregion | |
#region Constructores | |
/// <summary> | |
/// Crea una instancia de `ControlCandidato`. | |
/// </summary> | |
/// <param name="numeroCandidato">ID (1, 2, o 3) del candidato.</param> | |
/// <param name="principal">Referencia a la interfaz principal de la aplicación.</param> | |
public ControlCandidato(int numeroCandidato, Principal principal) | |
{ | |
InitializeComponent(); | |
this.numeroCandidato = numeroCandidato; | |
this.principal = principal; | |
ConfiguracionComponentes(); | |
} | |
#endregion | |
#region Métodos | |
/// <summary> | |
/// Configura los componentes (controles). | |
/// </summary> | |
private void ConfiguracionComponentes() | |
{ | |
switch (numeroCandidato) | |
{ | |
case 1: | |
pbxFotoCandidato.BackgroundImage = Properties.Resources.candidato1; | |
break; | |
case 2: | |
pbxFotoCandidato.BackgroundImage = Properties.Resources.candidato2; | |
break; | |
case 3: | |
pbxFotoCandidato.BackgroundImage = Properties.Resources.candidato3; | |
break; | |
} | |
gbxCandidato.Text = String.Format("Candidato {0}", numeroCandidato.ToString()); | |
} | |
/// <summary> | |
/// Actualiza la información del candidato. | |
/// </summary> | |
/// <param name="candidato">Candidato con la información actualizada.</param> | |
public void Actualizar(Candidato candidato) | |
{ | |
lblApellidoCandidato.Text = String.Format("Nombre: {0}", candidato.Apellido); | |
lblCostoCampaniaCandidato.Text = String.Format("Costo Campaña: ${0:#,##0.0}", candidato.CostoCampania); | |
lblEdadCandidato.Text = String.Format("Edad: {0}", candidato.Edad.ToString()); | |
lblNombreCandidato.Text = String.Format("Nombre: {0}", candidato.Nombre); | |
lblPartidoPoliticoCandidato.Text = String.Format("Partido Político: {0}", candidato.PartidoPolitico); | |
lblNumeroVotosCandidato.Text = String.Format("Número Votos: {0}", candidato.Votos.ToString()); | |
if (principal.CalcularVotosUrna() == 0) | |
{ | |
btnCalcularPorcentajeVotos.Enabled = false; | |
} | |
else | |
{ | |
btnCalcularPorcentajeVotos.Enabled = true; | |
} | |
} | |
#endregion | |
#region Eventos | |
/// <summary> | |
/// Invoca al método `MostrarPorcentajeVotos(int)`. | |
/// </summary> | |
/// <param name="sender">Objeto generador del evento.</param> | |
/// <param name="e">Datos del evento</param> | |
private void btnCalcularPorcentajeVotos_Click(object sender, EventArgs e) | |
{ | |
principal.MostrarPorcentajeVotos(numeroCandidato); | |
} | |
/// <summary> | |
/// Invoca al método `IngresarVotoCandidato(int)`. | |
/// </summary> | |
/// <param name="sender">Objeto generador del evento.</param> | |
/// <param name="e">Datos del evento</param> | |
private void btnVotar_Click(object sender, EventArgs e) | |
{ | |
principal.IngresarVotoCandidato(numeroCandidato); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment