using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using banco1.domain;
using banco1.domain.auxi;

namespace banco1.presentacion
{
	/// <summary>
	/// Descripción breve de FCuenta.
	/// </summary>
	public class FCuenta : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button bBuscar;
		private System.Windows.Forms.Button bCrear;
		private System.Windows.Forms.Button bCancelar;
		private System.Windows.Forms.Button bBloquear;
		/// <summary>
		/// Variable del diseñador requerida.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.ListView lvTitulares;
		private System.Windows.Forms.Button bTerminarCreacion;
		private System.Windows.Forms.Button bAddTitular;
		private System.Windows.Forms.CheckBox chBloqueada;
		private System.Windows.Forms.CheckBox chCancelada;
		private System.Windows.Forms.Button bDesbloquear;

		private System.Windows.Forms.ListView lvMovimientos;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button bTransferir;
		private System.Windows.Forms.TextBox tbImporte;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox tbImporteIR;
		private System.Windows.Forms.Button bIngresar;
		private System.Windows.Forms.Button bRetirar;
		private System.Windows.Forms.Button button1;
		private controlesMacario.NumeroDeCuenta cuentaOrigen;
		private controlesMacario.NumeroDeCuenta cuentaDestino;
		private System.Windows.Forms.Button button2;
		//***
		private Cuenta mCuenta;

		public FCuenta(FMenu padre)
		{
			//
			// Necesario para admitir el Diseñador de Windows Forms
			//
			InitializeComponent();

			//***
			this.MdiParent=padre;
			lvTitulares.Columns.Add("", 0, HorizontalAlignment.Left);
			lvTitulares.Columns.Add("Nombre", 50, HorizontalAlignment.Left);
			lvTitulares.Columns.Add("Apellidos", 150, HorizontalAlignment.Left);
			lvTitulares.Columns.Add("NIF", -2, HorizontalAlignment.Left);
			lvTitulares.View = View.Details;
			lvMovimientos.Columns.Add("", 0, HorizontalAlignment.Left);
			lvMovimientos.Columns.Add("Fecha", 120, HorizontalAlignment.Left);
			lvMovimientos.Columns.Add("Concepto", 350, HorizontalAlignment.Left);
			lvMovimientos.Columns.Add("Importe", -2, HorizontalAlignment.Left);
			lvMovimientos.View = View.Details;
		}

		/// <summary>
		/// Limpiar los recursos que se estén utilizando.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Método necesario para admitir el Diseñador, no se puede modificar
		/// el contenido del método con el editor de código.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.cuentaOrigen = new controlesMacario.NumeroDeCuenta();
			this.bDesbloquear = new System.Windows.Forms.Button();
			this.chCancelada = new System.Windows.Forms.CheckBox();
			this.chBloqueada = new System.Windows.Forms.CheckBox();
			this.bBloquear = new System.Windows.Forms.Button();
			this.bCancelar = new System.Windows.Forms.Button();
			this.bCrear = new System.Windows.Forms.Button();
			this.bBuscar = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.bAddTitular = new System.Windows.Forms.Button();
			this.bTerminarCreacion = new System.Windows.Forms.Button();
			this.lvTitulares = new System.Windows.Forms.ListView();
			this.lvMovimientos = new System.Windows.Forms.ListView();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.cuentaDestino = new controlesMacario.NumeroDeCuenta();
			this.bTransferir = new System.Windows.Forms.Button();
			this.tbImporte = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.groupBox4 = new System.Windows.Forms.GroupBox();
			this.bRetirar = new System.Windows.Forms.Button();
			this.bIngresar = new System.Windows.Forms.Button();
			this.tbImporteIR = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.groupBox4.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.cuentaOrigen);
			this.groupBox1.Controls.Add(this.bDesbloquear);
			this.groupBox1.Controls.Add(this.chCancelada);
			this.groupBox1.Controls.Add(this.chBloqueada);
			this.groupBox1.Controls.Add(this.bBloquear);
			this.groupBox1.Controls.Add(this.bCancelar);
			this.groupBox1.Controls.Add(this.bCrear);
			this.groupBox1.Controls.Add(this.bBuscar);
			this.groupBox1.Location = new System.Drawing.Point(16, 24);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(264, 136);
			this.groupBox1.TabIndex = 6;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Número de cuenta";
			// 
			// cuentaOrigen
			// 
			this.cuentaOrigen.ccc = "";
			this.cuentaOrigen.dc = "";
			this.cuentaOrigen.entidad = "1000";
			this.cuentaOrigen.Location = new System.Drawing.Point(16, 24);
			this.cuentaOrigen.Name = "cuentaOrigen";
			this.cuentaOrigen.Size = new System.Drawing.Size(240, 24);
			this.cuentaOrigen.sucursal = "";
			this.cuentaOrigen.TabIndex = 17;
			// 
			// bDesbloquear
			// 
			this.bDesbloquear.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.bDesbloquear.Location = new System.Drawing.Point(195, 56);
			this.bDesbloquear.Name = "bDesbloquear";
			this.bDesbloquear.Size = new System.Drawing.Size(64, 24);
			this.bDesbloquear.TabIndex = 16;
			this.bDesbloquear.Text = "Desbloquear";
			this.bDesbloquear.Visible = false;
			this.bDesbloquear.Click += new System.EventHandler(this.bDesbloquear_Click);
			// 
			// chCancelada
			// 
			this.chCancelada.Enabled = false;
			this.chCancelada.Location = new System.Drawing.Point(104, 96);
			this.chCancelada.Name = "chCancelada";
			this.chCancelada.Size = new System.Drawing.Size(80, 16);
			this.chCancelada.TabIndex = 15;
			this.chCancelada.Text = "Cancelada";
			// 
			// chBloqueada
			// 
			this.chBloqueada.Enabled = false;
			this.chBloqueada.Location = new System.Drawing.Point(8, 96);
			this.chBloqueada.Name = "chBloqueada";
			this.chBloqueada.Size = new System.Drawing.Size(80, 16);
			this.chBloqueada.TabIndex = 14;
			this.chBloqueada.Text = "Bloqueada";
			// 
			// bBloquear
			// 
			this.bBloquear.Location = new System.Drawing.Point(200, 56);
			this.bBloquear.Name = "bBloquear";
			this.bBloquear.Size = new System.Drawing.Size(58, 24);
			this.bBloquear.TabIndex = 13;
			this.bBloquear.Text = "Bloquear";
			this.bBloquear.Click += new System.EventHandler(this.bBloquear_Click);
			// 
			// bCancelar
			// 
			this.bCancelar.Location = new System.Drawing.Point(136, 56);
			this.bCancelar.Name = "bCancelar";
			this.bCancelar.Size = new System.Drawing.Size(58, 24);
			this.bCancelar.TabIndex = 12;
			this.bCancelar.Text = "Cancelar";
			this.bCancelar.Click += new System.EventHandler(this.bCancelar_Click);
			// 
			// bCrear
			// 
			this.bCrear.Location = new System.Drawing.Point(72, 56);
			this.bCrear.Name = "bCrear";
			this.bCrear.Size = new System.Drawing.Size(58, 24);
			this.bCrear.TabIndex = 11;
			this.bCrear.Text = "Crear";
			this.bCrear.Click += new System.EventHandler(this.bCrear_Click);
			// 
			// bBuscar
			// 
			this.bBuscar.Location = new System.Drawing.Point(8, 56);
			this.bBuscar.Name = "bBuscar";
			this.bBuscar.Size = new System.Drawing.Size(58, 24);
			this.bBuscar.TabIndex = 10;
			this.bBuscar.Text = "Buscar";
			this.bBuscar.Click += new System.EventHandler(this.bBuscar_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.bAddTitular);
			this.groupBox2.Controls.Add(this.bTerminarCreacion);
			this.groupBox2.Controls.Add(this.lvTitulares);
			this.groupBox2.Location = new System.Drawing.Point(288, 24);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(328, 136);
			this.groupBox2.TabIndex = 7;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Titulares";
			// 
			// bAddTitular
			// 
			this.bAddTitular.Location = new System.Drawing.Point(8, 104);
			this.bAddTitular.Name = "bAddTitular";
			this.bAddTitular.Size = new System.Drawing.Size(96, 24);
			this.bAddTitular.TabIndex = 2;
			this.bAddTitular.Text = "Añadir titular";
			this.bAddTitular.Visible = false;
			this.bAddTitular.Click += new System.EventHandler(this.bAddTitular_Click);
			// 
			// bTerminarCreacion
			// 
			this.bTerminarCreacion.Location = new System.Drawing.Point(112, 104);
			this.bTerminarCreacion.Name = "bTerminarCreacion";
			this.bTerminarCreacion.Size = new System.Drawing.Size(104, 24);
			this.bTerminarCreacion.TabIndex = 1;
			this.bTerminarCreacion.Text = "Terminar creación";
			this.bTerminarCreacion.Visible = false;
			this.bTerminarCreacion.Click += new System.EventHandler(this.bTerminarCreacion_Click);
			// 
			// lvTitulares
			// 
			this.lvTitulares.Location = new System.Drawing.Point(8, 24);
			this.lvTitulares.Name = "lvTitulares";
			this.lvTitulares.Size = new System.Drawing.Size(312, 72);
			this.lvTitulares.TabIndex = 0;
			// 
			// lvMovimientos
			// 
			this.lvMovimientos.Location = new System.Drawing.Point(16, 168);
			this.lvMovimientos.Name = "lvMovimientos";
			this.lvMovimientos.Size = new System.Drawing.Size(600, 120);
			this.lvMovimientos.TabIndex = 8;
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.cuentaDestino);
			this.groupBox3.Controls.Add(this.bTransferir);
			this.groupBox3.Controls.Add(this.tbImporte);
			this.groupBox3.Controls.Add(this.label2);
			this.groupBox3.Controls.Add(this.label1);
			this.groupBox3.Location = new System.Drawing.Point(16, 296);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(368, 88);
			this.groupBox3.TabIndex = 9;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "Transferencias internas (traspasos)";
			// 
			// cuentaDestino
			// 
			this.cuentaDestino.ccc = "";
			this.cuentaDestino.dc = "";
			this.cuentaDestino.entidad = "1000";
			this.cuentaDestino.Location = new System.Drawing.Point(104, 24);
			this.cuentaDestino.Name = "cuentaDestino";
			this.cuentaDestino.Size = new System.Drawing.Size(240, 24);
			this.cuentaDestino.sucursal = "";
			this.cuentaDestino.TabIndex = 5;
			// 
			// bTransferir
			// 
			this.bTransferir.Location = new System.Drawing.Point(264, 56);
			this.bTransferir.Name = "bTransferir";
			this.bTransferir.Size = new System.Drawing.Size(80, 24);
			this.bTransferir.TabIndex = 4;
			this.bTransferir.Text = "Transferir";
			this.bTransferir.Click += new System.EventHandler(this.bTransferir_Click);
			// 
			// tbImporte
			// 
			this.tbImporte.Location = new System.Drawing.Point(104, 56);
			this.tbImporte.Name = "tbImporte";
			this.tbImporte.Size = new System.Drawing.Size(136, 20);
			this.tbImporte.TabIndex = 3;
			this.tbImporte.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(48, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "Importe:";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "Cuenta destino:";
			// 
			// groupBox4
			// 
			this.groupBox4.Controls.Add(this.bRetirar);
			this.groupBox4.Controls.Add(this.bIngresar);
			this.groupBox4.Controls.Add(this.tbImporteIR);
			this.groupBox4.Controls.Add(this.label3);
			this.groupBox4.Location = new System.Drawing.Point(392, 304);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(184, 80);
			this.groupBox4.TabIndex = 10;
			this.groupBox4.TabStop = false;
			this.groupBox4.Text = "Ingresar/retirar";
			// 
			// bRetirar
			// 
			this.bRetirar.Location = new System.Drawing.Point(96, 48);
			this.bRetirar.Name = "bRetirar";
			this.bRetirar.Size = new System.Drawing.Size(80, 24);
			this.bRetirar.TabIndex = 3;
			this.bRetirar.Text = "Retirar";
			this.bRetirar.Click += new System.EventHandler(this.bRetirar_Click);
			// 
			// bIngresar
			// 
			this.bIngresar.Location = new System.Drawing.Point(8, 48);
			this.bIngresar.Name = "bIngresar";
			this.bIngresar.Size = new System.Drawing.Size(80, 24);
			this.bIngresar.TabIndex = 2;
			this.bIngresar.Text = "Ingresar";
			this.bIngresar.Click += new System.EventHandler(this.bIngresar_Click);
			// 
			// tbImporteIR
			// 
			this.tbImporteIR.Location = new System.Drawing.Point(64, 16);
			this.tbImporteIR.Name = "tbImporteIR";
			this.tbImporteIR.Size = new System.Drawing.Size(112, 20);
			this.tbImporteIR.TabIndex = 1;
			this.tbImporteIR.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 24);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 16);
			this.label3.TabIndex = 0;
			this.label3.Text = "Importe:";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(584, 312);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(80, 32);
			this.button1.TabIndex = 11;
			this.button1.Text = "Crear tarjeta";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(584, 352);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(80, 32);
			this.button2.TabIndex = 12;
			this.button2.Text = "Listar tarjetas";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// FCuenta
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(672, 397);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox4);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.lvMovimientos);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Name = "FCuenta";
			this.Text = "Gestión de cuentas corrientes";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void bCrear_Click(object sender, System.EventArgs e)
		{
			this.cuentaOrigen.ccc="";
			this.lvMovimientos.Items.Clear();
			this.lvTitulares.Items.Clear();
			try 
			{
				mCuenta=new Cuenta(this.cuentaOrigen.sucursal);
				activaBotones(true);
				if (mCuenta!=null) 
				{
					this.cuentaOrigen.sucursal=mCuenta.sucursal;
					this.cuentaOrigen.dc=mCuenta.digitoDeControl;
					this.cuentaOrigen.ccc=mCuenta.ccc;
				}
				addTitular();
			}
			catch (Exception ex) 
			{
				MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
		}

		private void activaBotones(bool accion) 
		{
			this.bCrear.Enabled=!accion;
			this.bBloquear.Enabled=!accion;
			this.bBuscar.Enabled=!accion;
			this.bCancelar.Enabled=!accion;
			this.bAddTitular.Visible=accion;
			this.bTerminarCreacion.Visible=accion;
		}

		private void bCancelar_Click(object sender, System.EventArgs e)
		{
			if (mCuenta==null) 
			{
				MessageBox.Show("No hay ninguna cuenta seleccionada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			if (mCuenta.esCancelable())
				mCuenta.cancelar();
			else 
			{
				MessageBox.Show("La cuenta no puede ser cancelada", "Error",
					MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
			muestra();
		}

		private void bBloquear_Click(object sender, System.EventArgs e)
		{
			if (mCuenta==null) 
			{
				MessageBox.Show("No hay ninguna cuenta seleccionada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			mCuenta.bloquear();
			muestra();
		}

		private void bBuscar_Click(object sender, System.EventArgs e)
		{
			try 
			{
				mCuenta=new Cuenta(this.cuentaOrigen.sucursal, this.cuentaOrigen.ccc);
				if (mCuenta==null) 
				{
					MessageBox.Show("No se encuentra la cuenta indicada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					return;
				} 
				else 
				{
					muestra();
				}
			}
			catch (Exception ex) 
			{
				MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void bAddTitular_Click(object sender, System.EventArgs e)
		{
			addTitular();
		}

		private void addTitular() 
		{
			FCliente f=new FCliente();
			f.ShowDialog();
			Cliente c=f.cliente;
			if (c!=null) 
			{
				mCuenta.add(c);
				addCliente(c);
			}
		}

		private void bAbrirFicha_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show("Escribe el código para que aparezca una ficha del cliente con todos los" +
				"productos que tiene contratados", "Ejercicio", 
				MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
		}

		private void bTerminarCreacion_Click(object sender, System.EventArgs e)
		{
			this.mCuenta.desbloquear();
			this.activaBotones(false);
		}

		private void muestra() 
		{
			this.cuentaOrigen.entidad=Cuenta.entidad;
			this.cuentaOrigen.sucursal=mCuenta.sucursal;
			this.cuentaOrigen.dc=mCuenta.digitoDeControl;
			this.cuentaOrigen.ccc=mCuenta.ccc;
			this.chBloqueada.Checked=!mCuenta.estaActivo();
			this.chCancelada.Checked=mCuenta.cancelado;
			muestraTitulares();
			muestraMovimientos();
			if (mCuenta.estaActivo()) 
			{
				this.bBloquear.Visible=true;
				this.bDesbloquear.Visible=false;
			} 
			else 
			{
				this.bBloquear.Visible=false;
				this.bDesbloquear.Visible=true;
			}
			this.Text="Gestión de cuentas corrientes - " + mCuenta.numero;
		}

		private void muestraTitulares() 
		{
			lvTitulares.Items.Clear();
			for (int i=0; i<mCuenta.titulares.Count; i++) 
			{
				Cliente c=(Cliente) this.mCuenta.titulares[i];
				addCliente(c);
			}
		}

		private void muestraMovimientos() 
		{
			lvMovimientos.Items.Clear();
			for (int i=0; i<mCuenta.movimientos.Count; i++) 
			{
				Movimiento m=(Movimiento) mCuenta.movimientos[i];
				addMovimiento(m);
			}
		}

		private void addCliente(Cliente c) 
		{
			ListViewItem fila = new ListViewItem();
			fila.SubItems.Add(c.nombre);
			fila.SubItems.Add(c.apellidos);
			fila.SubItems.Add(c.nif);
			lvTitulares.Items.Add(fila);
		}

		private void addMovimiento(Movimiento m) 
		{
			ListViewItem fila = new ListViewItem();
			fila.SubItems.Add(m.fecha.ToString());
			fila.SubItems.Add(m.concepto);
			fila.SubItems.Add(m.importe.ToString());
			this.lvMovimientos.Items.Add(fila);
		}

		private void bDesbloquear_Click(object sender, System.EventArgs e)
		{
			if (mCuenta==null) 
			{
				MessageBox.Show("No hay ninguna cuenta seleccionada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			this.mCuenta.desbloquear();
			muestra();
		}

		private void bTransferir_Click(object sender, System.EventArgs e)
		{
			Cuenta destino=new Cuenta(this.cuentaDestino.sucursal, this.cuentaDestino.ccc);
			if (destino==null) 
			{
				MessageBox.Show("La cuenta destino no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			if (mCuenta==null) 
			{
				MessageBox.Show("Seleccione la cuenta desde la que desea operar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			try 
			{
				mCuenta.transferir(destino, double.Parse(this.tbImporte.Text));
				muestra();
			}
			catch (Exception ex) 
			{
				MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void bIngresar_Click(object sender, System.EventArgs e)
		{
			try 
			{
				this.mCuenta.ingresar(double.Parse(this.tbImporteIR.Text));
				muestra();
			}
			catch (Exception ex) 
			{
				MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void bRetirar_Click(object sender, System.EventArgs e)
		{
			try 
			{
				this.mCuenta.retirar(double.Parse(this.tbImporteIR.Text));
				muestra();
			}
			catch (Exception ex) 
			{
				MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if (mCuenta==null) 
			{
				MessageBox.Show("Seleccione primero una cuenta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
			FTarjeta f=new FTarjeta(mCuenta);
			f.MdiParent=this.MdiParent;
			f.Show();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			try 
			{
				String SQL="Select * from TarjetasDeTitulares where " +
					"[Cuenta asociada (sucursal/CCC)]='" + 
					mCuenta.sucursal + "/" +
					mCuenta.ccc + "'"; 
				ArrayList datos=GestorDeListas.getVista(SQL);
				FListaDeTarjetas f=new FListaDeTarjetas("Tarjetas asociadas a la cuenta " + mCuenta.numero, datos);
				f.MdiParent=this.MdiParent;
				f.Show();
			}
			catch (Exception ex) 
			{
				MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

	}
}
