private void CriterioList_SelectedIndexChanged(object sender, EventArgs e) { Valor.Text = "0,00"; if (CriterioList.SelectedIndex > -1) { CustomListBoxItem4 item = (CustomListBoxItem4)CriterioList.SelectedItem; Valor.Text = item._value2.ToString("#0.00"); } }
private void CriterioList_SelectedIndexChanged(object sender, EventArgs e) { if (CriterioList.SelectedIndex == -1) { return; } CustomListBoxItem4 item = (CustomListBoxItem4)CriterioList.SelectedItem; ValorText.Text = item._value2.ToString("#0.00"); }
private void btCC1_Click(object sender, EventArgs e) { if (CriterioList.SelectedIndex == -1) { return; } if (MainListView.SelectedItems.Count == 0) { return; } CustomListBoxItem4 item = (CustomListBoxItem4)CriterioList.SelectedItem; bool _find = false; foreach (ListViewItem lv in CriterioListView.Items) { if (Convert.ToInt32(lv.Text) == item._value) { _find = true; break; } } if (!_find) { string _cnae = gtiCore.RetornaNumero(MainListView.SelectedItems[0].Text); Empresa_bll empresa_Class = new Empresa_bll(_connection); Cnae_criterio reg = new Cnae_criterio { Cnae = _cnae, Criterio = item._value }; Exception ex = empresa_Class.Incluir_Cnae_Criterio(reg); if (ex == null) { ListViewItem lv = new ListViewItem(item._value.ToString()); lv.SubItems.Add(item._name); lv.SubItems.Add(item._value2.ToString("#0.00")); CriterioListView.Items.Add(lv); } else { ErrorBox eBox = new ErrorBox("Atenção", "Erro de inclusão.", ex); eBox.ShowDialog(); } } else { MessageBox.Show("Critério já incluso na lista.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OkButton_Click(object sender, EventArgs e) { if (Qtde.Text == "") { Qtde.Text = "0"; } if (CriterioList.Items.Count == 0) { MessageBox.Show("Selecione um Cnae.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { decimal _valor = Convert.ToDecimal(Valor.Text); if (_valor == 0) { MessageBox.Show("Selecione um CNAE com valor cadastrado.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int _qtde = Convert.ToInt32(Qtde.Text); if (_qtde == 0) { MessageBox.Show("Digite a Quantidade.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { CustomListBoxItem4 item = (CustomListBoxItem4)CriterioList.SelectedItem; Item_VS = new CnaeStruct { CNAE = CnaeList.Text.Substring(0, 9), Descricao = CnaeList.Text.Substring(10, CnaeList.Text.Length - 10), Criterio = item._value, Qtde = _qtde, Valor = _valor }; Close(); } } } }