private void btnAdicionarPagamento_Click(object sender, EventArgs e) { Controller.PagamentoController pagc = new Controller.PagamentoController(); Entidades.FormaPagamento forma = new Entidades.FormaPagamento(); Entidades.TabelaFormaPagamento tforma = new Entidades.TabelaFormaPagamento(); if (Convert.ToInt32(cbbForma.SelectedValue) > 0 && !String.IsNullOrEmpty(mskValorPagar.Text.ToString())) { DataTable dtForma = pagc.retornaObjFormaPagamento(Convert.ToInt32(cbbForma.SelectedValue)); if (dtForma != null && dtForma.Rows.Count > 0) { DataRow drForma = dtForma.Rows[0]; forma.Codigo = Convert.ToInt32(drForma["codformapag"].ToString()); forma.Forma = drForma["formpag_descricao"].ToString(); } tforma.Forma = forma; tforma.Valor = Convert.ToDouble(mskValorPagar.Text.ToString()); listapag.Add(tforma); carregaDGVF(listapag); mskValorPagar.Text = ""; double recebido = somaValor(listapag); mskRecebido.Text = recebido + ""; double total = Convert.ToDouble(mskTotal.Text.ToString()); if (total - recebido > 0) { mskRestante.Text = (total - recebido) + ""; } else { mskRestante.Text = "0.00"; mskTroco.Text = (recebido - total) + ""; } } }
private void btnExcluirForma_Click(object sender, EventArgs e) { Controller.PagamentoController pagc = new Controller.PagamentoController(); Entidades.FormaPagamento forma = new Entidades.FormaPagamento(); Entidades.TabelaFormaPagamento tforma = new Entidades.TabelaFormaPagamento(); if (dgvformasPagamento.CurrentRow.Index > -1) { tforma = listapag.ElementAt(dgvformasPagamento.CurrentRow.Index); listapag.Remove(listapag.ElementAt(dgvformasPagamento.CurrentRow.Index)); carregaDGVF(listapag); double recebido = somaValor(listapag); mskRecebido.Text = recebido + ""; double total = Convert.ToDouble(mskTotal.Text.ToString()); if (total - recebido > 0) { mskRestante.Text = (total - recebido) + ""; mskTroco.Text = "0.00"; mskRestante.Text = Convert.ToDouble(mskRestante.Text).ToString("###,###,##0.00"); } else { mskRestante.Text = "0.00"; mskTroco.Text = (recebido - total) + ""; mskTroco.Text = Convert.ToDouble(mskTroco.Text).ToString("###,###,##0.00"); } } }