I would not like to use multiple if's
to control a method of mine, unless there is no way to do it without if's
. Record in a list, the return of the DB that may or may not have bank information. The list returns me, Nome_Banco
, Conta
and Agencia
. I need to fill in textbox
, but only if there is data. I'm having trouble doing it without using if's
. See how it is currently.
if (vlstCorpFornecedor.Count > 0)
{
//string nm_banco = vlstCorpFornecedor[0].Banco.ToString();
txtCpfCnpjCadFornecedor.Text = vlstCorpFornecedor[0].NuCPFCNPJ.ToString();
txtNomeRazaoSocialCadFornecedor.Text = vlstCorpFornecedor[0].Nome.ToString();
txtAgenciaCadFornecedor.Text = vlstCorpFornecedor[0].Agencia.ToString();
txtContaCadFornecedor.Text = vlstCorpFornecedor[0].ContaCorrente.ToString();
cmbBancos.SelectedValue = vlstCorpFornecedor[0].Banco.ToString();
cmbBancos_SelectedIndexChanged(this, EventArgs.Empty);
}
Where vlstCorpFornecedor
is my list. From here txtAgenciaCadFornecedor
and I can only fill in whether or not data exists. I can do with if's
and test whether it is null
or not, but the question is: Is there a way to do this without if
?
Responding to Maniero.
These fields are displayed in a panel, type a "popup". These fields are in this panel. When in the form I type the CPF or CNPJ, there the panel is visible and these fields are filled after the search in the database. The list below: CPF / CNPJ, Corporate Name, Agency, Account, Bank Number and Name of Bank (Institution).
Well, it happens, since this is an old registry, I do not always have the banking information. So when the panel is displayed (Visible), if any bank data come null
, it will give error when assigning value to TextBoxes
relative.
I would like to avoid this error by already testing null
in the information. if it is null, the panel is displayed (Visible) with CPF / CNPJ and Social Ratio completed and the other textboxes
must be blank (empty) to be filled manually (user types the fields, agency, account, number and name of the bank (institution)).