0
I wouldn’t want to use several if's
to control a method of mine, unless there is no way to do it without the if's
. I write in a list, the return of the BD that may or may not have banking information. The list returns me, Nome_Banco
, Conta
and Agencia
. I need to fill out some textbox
, but only if there is data. I’m having difficulties to do 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 if data exists or not. I can do it with if's
and test if it is null
or not, but the question is: Is there a way to do this without the if
?
Responding to the Maniero.
These fields are displayed in a panel, like a "popup". These fields are in this panel. When in the form I type the CPF or CNPJ, then the panel is visible and these fields are filled after the search in the BD. The back list: CPF/CNPJ, Social Reason, Agency, Account, Bank Number and Bank Name(Institution).
Well, it turns out, since it’s an old rap sheet, I don’t always have the banking information. So when the panel is displayed (Visible), if any banking data comes null
, will give error when assigning value to TextBoxes
relative.
I’d like to avoid that mistake by already testing null
in the information. if it comes null, the panel is displayed (Visible) with CPF/CNPJ and Social Reason filled and the other textboxes
should come blank (empty) to be able to be filled manually(user type fields, agency, account, number and name of the bank (institution)).
And what do you want to do if it’s
null
?– Maniero
It won’t fill out automatically. Then the padding will be manual, make the panel visible with the blank fields and then the user fills them manually.
– pnet
But you have to explain how you want to proceed with this. Your questions are complicated because we have to guess how you are doing. What is manual padding? What is visible panel? You don’t mention any of this in the question. Which fields should be blank? What is it to be blank to you? I ask this because you usually say one thing but want another. Is there a problem when you do?
– Maniero
I will edit the question and try to be more explicit, but I think the question is appropriate.
– pnet