private void btPagamento_Click(object sender, EventArgs e) { int linhaGrid = 0; int idOPItem = 0; OrdemPagamentoItem opItemAtualizado = new OrdemPagamentoItem(); try { if (gvItens.RowCount == 0) { return; } linhaGrid = gvItens.SelectedCells[0].RowIndex; idOPItem = int.Parse(gvItens[11, linhaGrid].Value.ToString()); if (idOPItem == 0) { MessageBox.Show("Favor gravar os itens antes de realizar o seu pagamento.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } OrdemPagamentoItem opItem = new OrdemPagamentoItem() { idOrdemPagamentoItem = idOPItem, descricaoDespesa = gvItens[5, linhaGrid].Value.ToString(), dataVencimento = DateTime.Parse(gvItens[7, linhaGrid].Value.ToString()), Valor = decimal.Parse(gvItens[8, linhaGrid].Value.ToString()), dataPagamento = gvItens[9, linhaGrid].Value == null ? DateTime.MinValue : DateTime.Parse(gvItens[9, linhaGrid].Value.ToString()), Multa = decimal.Parse(gvItens[14, linhaGrid].Value.ToString()), Desconto = decimal.Parse(gvItens[15, linhaGrid].Value.ToString()), valorPago = decimal.Parse(gvItens[10, linhaGrid].Value.ToString()), idUsuarioPagamento = int.Parse(gvItens[12, linhaGrid].Value.ToString()), nomeUsuarioPagamento = gvItens[13, linhaGrid].Value.ToString() }; OrdemPagamentoManutencaoPagamento formPagto = new OrdemPagamentoManutencaoPagamento(opItem); formPagto.ShowDialog(); opItemAtualizado = formPagto.opItem; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().Valor = opItemAtualizado.Valor; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().dataVencimento = opItemAtualizado.dataVencimento; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().valorPago = opItemAtualizado.valorPago; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().dataPagamento = opItemAtualizado.dataPagamento; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().Multa = opItemAtualizado.Multa; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().Desconto = opItemAtualizado.Desconto; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().idUsuarioPagamento = opItemAtualizado.idUsuarioPagamento; opSelecionada.lstItens.Where(x => x.idOrdemPagamentoItem == idOPItem).First().nomeUsuarioPagamento = opItemAtualizado.nomeUsuarioPagamento; this.CarregarItens(); } catch (Exception) { MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <OrdemPagamentoItem> PesquisarOrdemPagamentoItem(OrdemPagamentoItem ordemPagamentoItem) { List <OrdemPagamentoItem> lstItens = new List <OrdemPagamentoItem>(); DataAccess dao = new DataAccess(); Dictionary <string, string> lstParametros = new Dictionary <string, string>(); dynamic lst = new List <OrdemPagamentoItem>(); try { lstParametros = this.MontarParametrosPesquisarOrdemPagamentoItem(ordemPagamentoItem); using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTOITENS_CONSULTAR", lstParametros)) { lst = from f in ds.Tables[0].AsEnumerable <OrdemPagamentoItem>() select f; } lstItens.AddRange(lst); } catch (Exception ex) { string parametrosSQL = string.Empty; parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros); LogErro log = new LogErro() { procedureSQL = "SP_ORDEMPAGAMENTOITENS_CONSULTAR", parametrosSQL = parametrosSQL, mensagemErro = ex.ToString() }; bizLogErro.IncluirLogErro(log); throw ex; } return(lstItens); }
private void btRemover_Click(object sender, EventArgs e) { int linhaGrid = 0; decimal valorPago = decimal.Zero; if (gvItens.RowCount == 0) { return; } linhaGrid = gvItens.SelectedCells[0].RowIndex; valorPago = decimal.Parse(gvItens[10, linhaGrid].Value.ToString()); if (valorPago != decimal.Zero) { MessageBox.Show("Não é possível remover um item que já foi pago", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } OrdemPagamentoItem itemSelecionado = new OrdemPagamentoItem() { idOrdemPagamentoItem = int.Parse(gvItens[11, linhaGrid].Value.ToString()), idDespesa = int.Parse(gvItens[2, linhaGrid].Value.ToString()), Valor = decimal.Parse(gvItens[8, linhaGrid].Value.ToString()), dataVencimento = DateTime.Parse(gvItens[7, linhaGrid].Value.ToString()) }; opSelecionada.lstItens.RemoveAll(item => item.idOrdemPagamentoItem == itemSelecionado.idOrdemPagamentoItem && item.idDespesa == itemSelecionado.idDespesa && item.Valor == itemSelecionado.Valor && item.dataVencimento.Date == itemSelecionado.dataVencimento.Date); CarregarItens(); }
private void btAdicionar_Click(object sender, EventArgs e) { string msgRetorno = string.Empty; List <OrdemPagamentoItemParcela> lstParcelas = new List <OrdemPagamentoItemParcela>(); msgRetorno = VerificarNovoItem(); if (msgRetorno == string.Empty) { if (chkGerarParcelamento.Checked) { OrdemPagamentoManutencaoParcelamento form = new OrdemPagamentoManutencaoParcelamento(new OrdemPagamentoItemParcela() { valorParcela = decimal.Parse(tbValor.Text), dataVencimento = tbDataVencimento.Value }); form.ShowDialog(); lstParcelas = form.lstParcelas; foreach (OrdemPagamentoItemParcela parcela in lstParcelas) { OrdemPagamentoItem itemOP = new OrdemPagamentoItem() { idObraGastoRealizado = 0, idUEN = int.Parse(cbUEN.SelectedValue.ToString()), descricaoUEN = cbUEN.Text, idCentroCusto = int.Parse(cbCentroCusto.SelectedValue.ToString()), descricaoCentroCusto = cbCentroCusto.Text, idDespesa = int.Parse(cbDespesa.SelectedValue.ToString()), descricaoDespesa = cbDespesa.Text, Valor = parcela.valorParcela, dataVencimento = parcela.dataVencimento, numeroParcela = parcela.numeroParcela, totalParcelas = parcela.totalParcelas }; opSelecionada.lstItens.Add(itemOP); } } else { OrdemPagamentoItem itemOP = new OrdemPagamentoItem() { idObraGastoRealizado = 0, idUEN = int.Parse(cbUEN.SelectedValue.ToString()), descricaoUEN = cbUEN.Text, idCentroCusto = int.Parse(cbCentroCusto.SelectedValue.ToString()), descricaoCentroCusto = cbCentroCusto.Text, idDespesa = int.Parse(cbDespesa.SelectedValue.ToString()), descricaoDespesa = cbDespesa.Text, Valor = decimal.Parse(tbValor.Text), dataVencimento = tbDataVencimento.Value, numeroParcela = 1, totalParcelas = 1 }; opSelecionada.lstItens.Add(itemOP); } CarregarItens(); tbValor.Text = "0,00"; chkGerarParcelamento.Checked = false; } else { MessageBox.Show("Atenção: " + msgRetorno, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public OrdemPagamentoManutencaoPagamento(OrdemPagamentoItem _opItem) { InitializeComponent(); opItem = _opItem; }
public virtual List <OrdemPagamentoItem> PesquisarItem(OrdemPagamentoItem ordemPagamentoItem) { return(new List <OrdemPagamentoItem>()); }
private Dictionary <string, string> MontarParametrosPesquisarOrdemPagamentoItem(OrdemPagamentoItem ordemPagamentoItem) { Dictionary <string, string> lstParametros = new Dictionary <string, string>(); lstParametros.Add("@idOrdemPagamento", ordemPagamentoItem.idOrdemPagamento.Equals(0) ? null : ordemPagamentoItem.idOrdemPagamento.ToString()); lstParametros.Add("@idUEN", ordemPagamentoItem.idUEN.Equals(0) ? null : ordemPagamentoItem.idUEN.ToString()); lstParametros.Add("@idCentroCusto", ordemPagamentoItem.idCentroCusto.Equals(0) ? null : ordemPagamentoItem.idCentroCusto.ToString()); lstParametros.Add("@idDespesa", ordemPagamentoItem.idDespesa.Equals(0) ? null : ordemPagamentoItem.idDespesa.ToString()); return(lstParametros); }
private Dictionary <string, string> MontarParametrosExecutarOrdemPagamentoItem(OrdemPagamentoItem ordemPagamentoItem) { Dictionary <string, string> lstParametros = new Dictionary <string, string>(); lstParametros.Add("@idOrdemPagamento", ordemPagamentoItem.idOrdemPagamento.ToString()); lstParametros.Add("@idUEN", ordemPagamentoItem.idUEN.ToString()); lstParametros.Add("@idCentroCusto", ordemPagamentoItem.idCentroCusto.ToString()); lstParametros.Add("@idDespesa", ordemPagamentoItem.idDespesa.ToString()); lstParametros.Add("@idUsuarioPagamento", ordemPagamentoItem.idUsuarioPagamento.ToString()); lstParametros.Add("@idAbastecimento", ordemPagamentoItem.idAbastecimento.ToString()); lstParametros.Add("@idManutencao", ordemPagamentoItem.idManutencao.ToString()); lstParametros.Add("@Valor", ordemPagamentoItem.Valor.ToString()); lstParametros.Add("@ValorPago", ordemPagamentoItem.valorPago.ToString()); lstParametros.Add("@DataVencimento", ordemPagamentoItem.dataVencimento.Date.ToString()); lstParametros.Add("@DataPagamento", ordemPagamentoItem.dataPagamento == DateTime.MinValue ? "01/01/1753 00:00:00.000" : ordemPagamentoItem.dataPagamento.Date.ToString()); lstParametros.Add("@NumeroParcela", ordemPagamentoItem.numeroParcela.ToString()); lstParametros.Add("@TotalParcelas", ordemPagamentoItem.totalParcelas.ToString()); lstParametros.Add("@Desconto", ordemPagamentoItem.Desconto.ToString()); lstParametros.Add("@Multa", ordemPagamentoItem.Multa.ToString()); lstParametros.Add("@UnitTest", ordemPagamentoItem.UnitTest.ToString()); return(lstParametros); }