Created
June 23, 2014 01:16
-
-
Save Fhernd/eabc028bd18469f80cd2 to your computer and use it in GitHub Desktop.
Control para las imágenes de las monedas.
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: ControlMonedas.cs | |
// | |
// Original en: http://goo.gl/PG7uxo | |
// | |
// Propósito: Botones para selección de las monedas a | |
// ahorrar en la alcancía. | |
// | |
============================================================*/ | |
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 Alcancia.Modelo; | |
namespace Alcancia.GUI | |
{ | |
/// <summary> | |
/// Control con la representación de las monedas. | |
/// </summary> | |
public partial class ControlMonedas : UserControl | |
{ | |
#region Campos (componentes de interfaz gráfica) | |
/// <summary> | |
/// Interfaz principal de usuario. | |
/// </summary> | |
private Principal ventanaPrincipal; | |
#endregion | |
#region Constructores | |
/// <summary> | |
/// Crea una instancia de ControlMonedas. | |
/// </summary> | |
/// <param name="principal"></param> | |
public ControlMonedas(Principal principal) | |
{ | |
InitializeComponent(); | |
ventanaPrincipal = principal; | |
} | |
#endregion | |
#region Métodos | |
/// <summary> | |
/// Cambia la cantidad de monedas a una cantidad determinada. | |
/// </summary> | |
/// <param name="cantidad">Cantidad de monedas.</param> | |
internal void CambiarCantidad(int cantidad) | |
{ | |
rbnMoneda20Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
rbnMoneda50Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
rbnMoneda100Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
rbnMoneda200Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
rbnMoneda500Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
} | |
/// <summary> | |
/// Cambia la cantidad de monedas para una denominación dada. | |
/// </summary> | |
/// <param name="denominacion">Denominación (20, 50, 100, 200, 500) de la moneda.</param> | |
/// <param name="cantidad">Cantidad de monedas.</param> | |
public void CambiarCantidad(Moneda denominacion, int cantidad) | |
{ | |
switch (denominacion) | |
{ | |
case Moneda.Veinte: | |
rbnMoneda20Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
return; | |
case Moneda.Cincuenta: | |
rbnMoneda50Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
return; | |
case Moneda.Cien: | |
rbnMoneda100Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
return; | |
case Moneda.Doscientos: | |
rbnMoneda200Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
return; | |
case Moneda.Quinientos: | |
rbnMoneda500Pesos.Text = String.Format("{0}", cantidad.ToString()); | |
return; | |
} | |
} | |
#endregion | |
#region Eventos | |
/// <summary> | |
/// Agrega una moneda a la alcancía. | |
/// </summary> | |
/// <param name="sender">Generador del evento.</param> | |
/// <param name="e">Datos del evento.</param> | |
private void btnAgregarMoneda_Click(object sender, EventArgs e) | |
{ | |
Moneda denominacion; | |
if (rbnMoneda20Pesos.Checked) | |
{ | |
denominacion = Moneda.Veinte; | |
} | |
else if (rbnMoneda50Pesos.Checked) | |
{ | |
denominacion = Moneda.Cincuenta; | |
} | |
else if (rbnMoneda100Pesos.Checked) | |
{ | |
denominacion = Moneda.Cien; | |
} | |
else if (rbnMoneda200Pesos.Checked) | |
{ | |
denominacion = Moneda.Doscientos; | |
} | |
else | |
{ | |
denominacion = Moneda.Quinientos; | |
} | |
ventanaPrincipal.AgregarMoneda(denominacion); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment