private void AddPagamento() { if (Convert.ToDecimal(textBoxForma.Text) > 0) { if (decimal.TryParse(textBoxValor.Text, out decimal cod)) { GridFormaPagamentoInfo gridFormaPagamentoInfo = new GridFormaPagamentoInfo { pagband = Convert.ToInt32(comboBoxBandeira.SelectedValue), pagbanddescricao = comboBoxBandeira.Text, pagdescricao = labelValorForma.Text, pagid = Convert.ToInt32(textBoxForma.Text), pagtipo = Convert.ToInt32(comboBoxTipo.SelectedValue), pagvalor = Convert.ToDecimal(textBoxValor.Text), parcela = comboBoxTipo.Text + "/" + comboBoxParcela.Text, parc = Convert.ToInt32(comboBoxParcela.Text.Replace("x", "")) }; gridFormaPagamentoColecao.Add(gridFormaPagamentoInfo); PreencherGrid(); } else { FormMessage.ShowMessegeWarning("Insira um valor vĂ¡lido!"); textBoxValor.Clear(); } } else { FormMessage.ShowMessegeWarning("Defina a forma de pagamento!"); } }
private void buttonRemover_Click(object sender, EventArgs e) { if (dataGridViewFormaPag.SelectedRows.Count > 0) { GridFormaPagamentoInfo gridFormaPagamentoInfo = (dataGridViewFormaPag.SelectedRows[0].DataBoundItem as GridFormaPagamentoInfo); for (int i = 0; i < gridFormaPagamentoColecao.Count; i++) { if (gridFormaPagamentoInfo.pagid == gridFormaPagamentoColecao[i].pagid) { gridFormaPagamentoColecao.RemoveAt(i); } } textBoxForma.Text = "1"; groupBoxPag.Enabled = true; AoDeixar(textBoxForma.Text); PreencherGrid(); } else { FormMessage.ShowMessegeWarning("Selecione um item!"); } }