public void TotalizaFechamento() { DTFechamento.Rows.Clear(); string Filtro = "IdNfceMovimento = " + Sessao.Instance.Movimento.Id; IList <NfceFechamentoDTO> ListaFechamento = NfceFechamentoController.ConsultaNfceFechamentoLista(Filtro); if (ListaFechamento != null) { for (int i = 0; i <= ListaFechamento.Count - 1; i++) { DataRow Registro = DTFechamento.NewRow(); Registro["ID"] = ListaFechamento[i].Id; Registro["TIPO_PAGAMENTO"] = ListaFechamento[i].TipoPagamento; Registro["VALOR"] = ListaFechamento[i].Valor.Value.ToString("N2"); DTFechamento.Rows.Add(Registro); } } decimal Total = 0; foreach (DataRow Registro in DTFechamento.Rows) { Total = Total + Convert.ToDecimal(Registro["VALOR"]); } edtTotal.Text = Total.ToString("N2"); }
private void btnAdicionar_Click(object sender, EventArgs e) { if (ComboTipoPagamento.Text.Trim() == "") { MessageBox.Show("Informe uma forma de Pagamento valida!", "Informação do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); ComboTipoPagamento.Focus(); return; } if (Convert.ToDecimal(edtValor.Text) <= 0) { MessageBox.Show("Informe um Valor valido!", "Informação do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); edtValor.Focus(); return; } try { NfceFechamentoDTO Fechamento = new NfceFechamentoDTO(); Fechamento.IdNfceMovimento = Sessao.Instance.Movimento.Id; Fechamento.TipoPagamento = ComboTipoPagamento.Text; Fechamento.Valor = Convert.ToDecimal(edtValor.Text); NfceFechamentoController.GravaNfceFechamento(Fechamento); TotalizaFechamento(); } catch (Exception eError) { Log.write(eError.ToString()); } edtValor.Clear(); ComboTipoPagamento.Focus(); }
private void btnRemover_Click(object sender, EventArgs e) { if (DTFechamento.Rows.Count > 0) { DataRow Registro = DTFechamento.Rows[GridValores.CurrentRow.Index]; NfceFechamentoDTO EcfFechamentoParaExclusao = new NfceFechamentoDTO(); EcfFechamentoParaExclusao.Id = Convert.ToInt32(Registro["ID"]); NfceFechamentoController.ExcluiNfceFechamento(EcfFechamentoParaExclusao); TotalizaFechamento(); } ComboTipoPagamento.Focus(); }