public void AdicionarConta(Conta c)
        {
            this.Contas.Add(c);
            cbContas.Items.Add(c.Titular.Nome);

            this.dicionario.Add(c.Titular.Nome, c);
        }
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            bool ehDevedor = false;
            for (int i = 0; i < 30000; i++)
            {
                ehDevedor = this.devedores.Contains(txtTitular.Text);
            }
            if (!ehDevedor)
            {
                Conta novaconta = new Conta();
                novaconta.Titular = new Cliente(txtTitular.Text);
                novaconta.Numero = Convert.ToInt32(txtNumero.Text);

                this.frmPrincipal.AdicionarConta(novaconta);
            }
            else
            {
                MessageBox.Show("Devedor!");
            }
        }
Exemplo n.º 3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     this.c = new Conta();
 }
        private void frmArrayContas_Load(object sender, EventArgs e)
        {
            this.dicionario = new Dictionary<string, Conta>();

            this.Contas = new List<Conta>();

            Conta c1 = new Conta();
            c1.Titular = new Cliente("victor");
            c1.Numero = 1;
            this.Contas.Add(c1);

            Conta c2 = new Conta();
            c2.Titular = new Cliente("mauricio");
            c2.Numero = 2;
            this.Contas.Add(c2);

            Conta c3 = new Conta();
            c3.Titular = new Cliente("onsi");
            c3.Numero = 3;
            this.Contas.Add(c3);

            foreach (Conta conta in Contas)
            {
                cbContas.Items.Add(conta.Titular.Nome);
            }
        }