0
Good afternoon guys, I’m already a few hours trying to solve this C# workbook exercise of Caelum, but I believe I am far from solved. I would like to know how to use an IF within a Combobox to make it distinguish between a current account and a savings account at the time of account creation. It follows the code that I have been able to produce so far. This is the code only of the registration form. In the main form everything is ok so far hehe... This is the question itself of exercise: In the registration form, add a combo box (called comboTipoConta) that allows the choice of the account type that will be registered. thank you in advance.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Banco1
{
public partial class FormCadastroConta : Form
{
private Form1 formPrincipal;
public ComboBox tipoConta { get; set; }
public FormCadastroConta(Form1 formPrincipal)
{
this.formPrincipal = formPrincipal;
InitializeComponent();
comboTipoConta.Items.Add("Corrente");
comboTipoConta.Items.Add("Poupança");
}
public FormCadastroConta()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void botaoCadastro_Click(object sender, EventArgs e)
{
this.Close();
}
public void comboTipoConta_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToBoolean(comboTipoConta.Items.Add("Corrente")))
{
ContaCorrente novaConta = new ContaCorrente();
novaConta.Titular = new Cliente(textoTitular.Text);
novaConta.Numero = Convert.ToInt32(textoNumero.Text);
this.formPrincipal.AdicionaConta(novaConta);
}
else if (Convert.ToBoolean(comboTipoConta.Items.Add("Poupança")))
{
ContaPoupança novaConta = new ContaPoupança();
novaConta.Titular = new Cliente(textoTitular.Text);
novaConta.Numero = Convert.ToInt32(textoNumero.Text);
this.formPrincipal.AdicionaConta(novaConta);
}
}
}
}
I doubt I can help without knowing exactly what it is to do, but anyway I see several errors in this code, many that seem correct, which are the most dangerous.
– Maniero
give a discount to start now kkkkk what was not clear pq da to know what I have to do
– Edivan Jr.