示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int contraseña     = int.Parse(contraseña_text.Text);
         int identificacion = int.Parse(text_identificacion.Text);
         id     = identificacion;
         Cuenta = null;
         foreach (CuentaAhorros cuenta in BancoCuentas.getBanco())
         {
             if (identificacion == cuenta.Identificacion1)
             {
                 Cuenta = cuenta;
                 break;
             }
         }
         if (banco.IniciarSesion(identificacion, contraseña) == true)
         {
             this.Hide();
             this.label2.Text = "Ingresa a Tus Sueños";
             BancoCuentas.Variables.Transacciones.Show();
         }
         else
         {
             throw new AccountExistsException("No existe el número de cuenta ingresado");
         }
     }
     catch (AccountExistsException ex)
     {
         label2.Text      = ex.getMensaje();
         label2.ForeColor = System.Drawing.Color.Red;
     }
     catch (FormatException)
     {
         label2.Text      = "campos vacio, no se reconoce usuario";
         label2.ForeColor = System.Drawing.Color.Red;
     }
     finally
     {
         contraseña_text.ResetText();
     }
 }
示例#2
0
        private void button_registrar_Click(object sender, EventArgs e)
        {
            Console.WriteLine(BancoCuentas.getBanco().Count);
            Random random           = new Random();
            int    Numero_de_cuenta = random.Next(100000001, int.MaxValue);

            try
            {
                String Nombre         = (Textbox_nombres.Text + " " + TextBox_apellidos.Text);
                double Identificacion = double.Parse(textBox_identificación.Text);
                int    Saldoinicial   = int.Parse(textBox_saldo.Text);
                int    Pin            = int.Parse(text_pin.Text);
                double Saldo          = 0;
                if (Saldoinicial >= 2000000)
                {
                    Saldo = Saldoinicial * 0.05 + Saldoinicial;
                }
                else
                {
                    Saldo = Saldoinicial;
                }
                CuentaAhorros Nueva_cuenta = new CuentaAhorros(Numero_de_cuenta, Nombre, Identificacion, Saldo, Pin);
                int           cont         = 0;
                if (BancoCuentas.getBanco().Count == 0)
                {
                    banco.AñadirCuenta(Nueva_cuenta);
                    Textbox_nombres.ResetText();
                    TextBox_apellidos.ResetText();
                    textBox_identificación.ResetText();
                    textBox_saldo.ResetText();
                    text_pin.ResetText();
                    label_result_registrarse.Text      = "Registro Exitoso";
                    label_result_registrarse.ForeColor = System.Drawing.Color.Green;
                    label_anota.Text       = "Su numero de cuenta es:";
                    label_anota.ForeColor  = System.Drawing.Color.Black;
                    label_cuenta.Text      = Numero_de_cuenta.ToString();
                    label_cuenta.ForeColor = System.Drawing.Color.Black;
                    cont = 0;
                }
                else
                {
                    while (cont < BancoCuentas.getBanco().Count)
                    {
                        if (Nueva_cuenta.Identificacion1 == BancoCuentas.getBanco()[cont].Identificacion1)
                        {
                            throw new AccountExistsException("Error, Usuario ya registrado");
                        }
                        cont++;
                    }

                    banco.AñadirCuenta(Nueva_cuenta);
                    Textbox_nombres.ResetText();
                    TextBox_apellidos.ResetText();
                    textBox_identificación.ResetText();
                    textBox_saldo.ResetText();
                    text_pin.ResetText();
                    label_result_registrarse.Text      = "Registro Exitoso";
                    label_result_registrarse.ForeColor = System.Drawing.Color.Green;
                    label_anota.Text       = "Su numero de cuenta es:";
                    label_anota.ForeColor  = System.Drawing.Color.Black;
                    label_cuenta.Text      = Numero_de_cuenta.ToString();
                    label_cuenta.ForeColor = System.Drawing.Color.Black;
                    cont = 0;
                }
            }
            catch (FormatException)
            {
                label_result_registrarse.Text      = "Campos vacios, por favor llenar los datos";
                label_result_registrarse.ForeColor = System.Drawing.Color.Red;
            }
            catch (AccountExistsException ex)
            {
                label_result_registrarse.Text      = ex.getMensaje();
                label_result_registrarse.ForeColor = System.Drawing.Color.Red;
                Textbox_nombres.ResetText();
                TextBox_apellidos.ResetText();
                textBox_identificación.ResetText();
                textBox_saldo.ResetText();
                text_pin.ResetText();
            }
        }
示例#3
0
 public Registrarse()
 {
     InitializeComponent();
     Console.WriteLine(BancoCuentas.getBanco().Count);
 }