コード例 #1
0
 public void Excluir(Receber recebimento)
 {
     if (recebimento.Caixa != null)
     {
         _caixaService.Excluir(recebimento.Caixa);
     }
     _receberRepository.Delete(recebimento);
 }
コード例 #2
0
 public ActionResult SalvarRecebimento(Receber receber)
 {
     if (receber == null)
     {
         return(BadRequest());
     }
     _receberService.Salvar(receber);
     return(ViewComponent("MovimentacaoRecebimentoLista", new { maxPriority = 3, isDone = false }));
 }
コード例 #3
0
 private void SalvarReceber(Receber recebimento)
 {
     if (recebimento.Id == 0)
     {
         _receberRepository.Add(recebimento);
     }
     else
     {
         _receberRepository.Update(recebimento);
     }
 }
コード例 #4
0
        public ActionResult EditarRecebimento(Receber receber)
        {
            var registroReceber = _receberService.ObterPorId(receber.Id);
            var planosContas    = _planoContaService.ObterPlanosContasEntrada().Result;
            var centrosCustos   = _centroCustoService.ObterCentrosCustos().Result;

            ViewData["Recebimento"] = registroReceber
                                      .SetarPlanosContas(planosContas)
                                      .SetarCentrosCustos(centrosCustos);

            return(ViewComponent("MovimentacaoRecebimentoFicha", new { maxPriority = 3, isDone = false }));
        }
コード例 #5
0
ファイル: fCadRecebimento.cs プロジェクト: GRSouzaSis/GPF
        private void Inicializar()
        {
            Lote    = new Lote();
            Projeto = new Projeto();
            Cliente = new Cliente();
            Receber = new Receber();
            carregarProjeto();

            carregarTipos();
            dtpVencInicial.Value           = DateTime.Now;
            dtpVencFinal.Value             = DateTime.Now;
            cbbProjeto.SelectedItem        = null;
            cbbCliente.SelectedItem        = null;
            cbbTipoMovimento.SelectedIndex = 0;
            bEstornar.Enabled = false;
            bBaixa.Enabled    = true;
        }
コード例 #6
0
        public ActionResult InserirRecebimento()
        {
            var empresa        = _empresaService.ObterEmpresas().Result.FirstOrDefault();
            var planosContas   = _planoContaService.ObterPlanosContasEntrada().Result;
            var centrosCustos  = _centroCustoService.ObterCentrosCustos().Result;
            var ultimoRegistro = _receberService.ObterRecebimentos().Result?.LastOrDefault();

            ViewData["Recebimento"] = new Receber()
                                      .SetarIdEmpresa(empresa?.Id ?? 0)
                                      .SetarPlanosContas(planosContas)
                                      .SetarCentrosCustos(centrosCustos)
                                      .SetarIdPlanoConta(ultimoRegistro?.IdPlanoConta)
                                      .SetarDescricaoPlanoConta(ultimoRegistro?.DescricaoPlanoConta)
                                      .SetarDescricao(ultimoRegistro?.Descricao);

            return(ViewComponent("MovimentacaoRecebimentoFicha", new { maxPriority = 3, isDone = false }));
        }
コード例 #7
0
        public async void Salvar(Receber recebimento)
        {
            if (recebimento.IdContaRecebimento == 0)
            {
                recebimento.DataRecebimento    = null;
                recebimento.IdContaRecebimento = null;
                recebimento.ValorRecebido      = 0;
            }

            SalvarReceber(recebimento);

            if (recebimento.ValorRecebido == 0 || recebimento.IdContaRecebimento == null)
            {
                return;
            }
            if (recebimento.DataRecebimento == null || recebimento.DataRecebimento == DateTime.MinValue)
            {
                recebimento.DataRecebimento = DateTime.Now;
            }

            var lancamentoCaixa = await _caixaService.ObterPorId(recebimento.IdCaixa ?? 0) ?? new Caixa();

            lancamentoCaixa.DataCompetencia      = recebimento.DataRecebimento ?? DateTime.Now;
            lancamentoCaixa.IdConta              = recebimento.IdContaRecebimento ?? 0;
            lancamentoCaixa.NomeConta            = recebimento.NomeContaRecebimento;
            lancamentoCaixa.IdEmpresa            = recebimento.IdEmpresa;
            lancamentoCaixa.IdCentroCusto        = recebimento.IdCentroCusto;
            lancamentoCaixa.DescricaoCentroCusto = recebimento.DescricaoCentroCusto;
            lancamentoCaixa.IdPlanoConta         = recebimento.IdPlanoConta;
            lancamentoCaixa.DescricaoPlanoConta  = recebimento.DescricaoPlanoConta;
            lancamentoCaixa.Descricao            = "Lançamento de recebimento";
            lancamentoCaixa.Credito              = recebimento.ValorRecebido;

            _caixaService.Salvar(lancamentoCaixa);
            recebimento.IdCaixa = lancamentoCaixa.Id;

            SalvarReceber(recebimento);
        }
コード例 #8
0
ファイル: Cadastro.xaml.cs プロジェクト: rafaelkds/TCCWP
        private void btAdicionarVencimento_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            if (btAdicionarVencimento.Value != null)
            {
                StackPanel sp = new StackPanel();
                sp.Margin = new Thickness(0, 0, 10, 0);
                TextBlock text = new TextBlock();
                text.Text = "Valor:";
                TextBox tb = new TextBox();
                tb.KeyUp += (s1, e1) =>
                {
                    tb.Text           = tb.Text.Replace(".", ",");
                    tb.SelectionStart = tb.Text.Length;
                };
                tb.KeyDown += (s1, e1) =>
                {
                    if (e1.Key == System.Windows.Input.Key.Unknown && tb.Text.Contains(","))
                    {
                        e1.Handled = true;
                    }
                };

                System.Windows.Input.InputScope     scope     = new System.Windows.Input.InputScope();
                System.Windows.Input.InputScopeName scopeName = new System.Windows.Input.InputScopeName();
                scopeName.NameValue = System.Windows.Input.InputScopeNameValue.Number;
                scope.Names.Add(scopeName);
                tb.InputScope = scope;

                sp.Children.Add(text);
                sp.Children.Add(tb);

                CustomMessageBox cmb = new CustomMessageBox()
                {
                    Content            = sp,
                    LeftButtonContent  = "Adicionar",
                    RightButtonContent = "Cancelar"
                };
                cmb.Dismissing += (s1, e1) =>
                {
                    switch (e1.Result)
                    {
                    case CustomMessageBoxResult.LeftButton:
                        try
                        {
                            if (string.IsNullOrWhiteSpace(tb.Text) || Convert.ToDecimal(tb.Text) == 0)
                            {
                                e1.Cancel = true;
                            }
                            else if (!string.IsNullOrWhiteSpace(tb.Text))
                            {
                                Receber novoReceber = new Receber();
                                novoReceber.Vencimento = btAdicionarVencimento.Value ?? new DateTime();
                                novoReceber.Valor      = Convert.ToDecimal(tb.Text);
                                novoPedido.Receber.Add(novoReceber);

                                listVencimentos.ItemsSource = null;
                                listVencimentos.ItemsSource = novoPedido.Receber;

                                decimal tValor = 0;
                                foreach (Receber item in novoPedido.Receber)
                                {
                                    tValor += item.Valor;
                                }
                                tbTotalReceber.Text  = tValor.ToString("0.00");
                                tbTotalRestante.Text = ((string.IsNullOrWhiteSpace(tbTotalValor.Text)
                                        ? 0 : Convert.ToDecimal(tbTotalValor.Text)) - tValor).ToString("0.00");
                            }
                        }
                        catch (FormatException)
                        {
                            e1.Cancel = true;
                        }
                        break;
                    }
                };

                cmb.Show();
            }
        }
コード例 #9
0
        public bool BaixaRecebimento(Receber receber, Cliente cliente)
        {
            using (SqlConnection connection = new SqlConnection(db.GetStringConnection()))
            {
                connection.Open();

                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;

                string updateReceber = @"Update receber set valorpago =@valorpago where id_receber =@id_receber";

                string insertRecebido = @"Insert Into recebido(cli_id,valor,desconto,acrescimo,dtpagamento) 
OUTPUT INSERTED.id_recebido
values (@cli_id,@valor1,@desconto1,@acrescimo1,@dtpagamento)";

                string insertReceber_recebido = @"Insert Into receber_recebido(id_receber, id_recebido, valor, desconto, acrescimo) 
values(@idreceber,@id_recebido,@valor,@desconto,@acrescimo)";

                try
                {
                    command.CommandText = updateReceber;  //update receber
                    command.Parameters.AddWithValue("@valorpago", receber.valorpago);
                    command.Parameters.AddWithValue("@id_receber", receber.id_receber);
                    command.ExecuteNonQuery();

                    command.CommandText = insertRecebido;
                    command.Parameters.AddWithValue("@cli_id", cliente.cli_id);
                    command.Parameters.AddWithValue("@valor1", receber.valorpago);
                    command.Parameters.AddWithValue("@desconto1", 0);
                    command.Parameters.AddWithValue("@acrescimo1", 0);
                    command.Parameters.AddWithValue("@dtpagamento", DateTime.Now);
                    //command.ExecuteNonQuery();
                    var IdInserido = Convert.ToInt32(command.ExecuteScalar());

                    command.CommandText = insertReceber_recebido;  //update receber
                    command.Parameters.AddWithValue("@idreceber", receber.id_receber);
                    command.Parameters.AddWithValue("@id_recebido", IdInserido);
                    command.Parameters.AddWithValue("@valor", receber.valorpago);
                    command.Parameters.AddWithValue("@desconto", 0);
                    command.Parameters.AddWithValue("@acrescimo", 0);
                    command.ExecuteNonQuery();

                    // Se deu certo Commit.
                    transaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    // roll back na transaction.
                    try
                    {
                        transaction.Rollback();
                        connection.Close();
                    }
                    catch (Exception ex2)
                    {
                        return(false);
                    }
                }
                return(false);
            }
        }
コード例 #10
0
        public bool EstornarRecebimento(Receber receber)
        {
            int id_recebido = 0;

            using (SqlConnection connection = new SqlConnection(db.GetStringConnection()))
            {
                connection.Open();

                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;

                string updateReceber = @"Update receber set valorpago =@valorpago where id_receber =@id_receber";

                string buscaId = @"select id_recebido from receber_recebido where id_recebido in (select id_recebido 
from receber_recebido
where id_receber =@idreceber)";

                string deleteReceber_recebido = @"delete from receber_recebido where id_receber=@id_recebe";

                string deleterecebido = @"delete from recebido where id_recebido=@id_recebido";

                try
                {
                    command.CommandText = updateReceber;  //update receber
                    command.Parameters.AddWithValue("@valorpago", 0);
                    command.Parameters.AddWithValue("@id_receber", receber.id_receber);
                    command.ExecuteNonQuery();

                    command.CommandText = buscaId;
                    command.Parameters.AddWithValue("@idreceber", receber.id_receber);
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            id_recebido = reader.GetInt32(0);
                        }
                    }
                    reader.Close();

                    command.CommandText = deleteReceber_recebido;  //delete Receber_recebido
                    command.Parameters.AddWithValue("@id_recebe", receber.id_receber);
                    command.ExecuteNonQuery();

                    command.CommandText = deleterecebido;  //delete receber
                    command.Parameters.AddWithValue("@id_recebido", id_recebido);
                    command.ExecuteNonQuery();

                    // Se deu certo Commit.
                    transaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    // roll back na transaction.
                    try
                    {
                        transaction.Rollback();
                        connection.Close();
                    }
                    catch (Exception ex2)
                    {
                        return(false);
                    }
                }
                return(false);
            }
        }
コード例 #11
0
ファイル: Cadastro.xaml.cs プロジェクト: rafaelkds/TCCWP
        private void btAdicionarVencimento_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            if (btAdicionarVencimento.Value != null)
            {
                StackPanel sp = new StackPanel();
                sp.Margin = new Thickness(0, 0, 10, 0);
                TextBlock text = new TextBlock();
                text.Text = "Valor:";
                TextBox tb = new TextBox();
                tb.KeyUp += (s1, e1) =>
                    {
                        tb.Text = tb.Text.Replace(".", ",");
                        tb.SelectionStart = tb.Text.Length;
                    };
                tb.KeyDown += (s1, e1) =>
                    {
                        if (e1.Key == System.Windows.Input.Key.Unknown && tb.Text.Contains(","))
                        {
                            e1.Handled = true;
                        }
                    };

                System.Windows.Input.InputScope scope = new System.Windows.Input.InputScope();
                System.Windows.Input.InputScopeName scopeName = new System.Windows.Input.InputScopeName();
                scopeName.NameValue = System.Windows.Input.InputScopeNameValue.Number;
                scope.Names.Add(scopeName);
                tb.InputScope = scope;

                sp.Children.Add(text);
                sp.Children.Add(tb);
                
                CustomMessageBox cmb = new CustomMessageBox()
                {
                    Content = sp,
                    LeftButtonContent = "Adicionar",
                    RightButtonContent = "Cancelar"
                };
                cmb.Dismissing += (s1, e1) =>
                {
                    switch (e1.Result)
                    {
                        case CustomMessageBoxResult.LeftButton:
                            try
                            {
                                if (string.IsNullOrWhiteSpace(tb.Text) || Convert.ToDecimal(tb.Text) == 0)
                                    e1.Cancel = true;
                                else if (!string.IsNullOrWhiteSpace(tb.Text))
                                {
                                    Receber novoReceber = new Receber();
                                    novoReceber.Vencimento = btAdicionarVencimento.Value ?? new DateTime();
                                    novoReceber.Valor = Convert.ToDecimal(tb.Text);
                                    novoPedido.Receber.Add(novoReceber);

                                    listVencimentos.ItemsSource = null;
                                    listVencimentos.ItemsSource = novoPedido.Receber;

                                    decimal tValor = 0;
                                    foreach (Receber item in novoPedido.Receber)
                                    {
                                        tValor += item.Valor;
                                    }
                                    tbTotalReceber.Text = tValor.ToString("0.00");
                                    tbTotalRestante.Text = ((string.IsNullOrWhiteSpace(tbTotalValor.Text)
                                        ? 0 : Convert.ToDecimal(tbTotalValor.Text)) - tValor).ToString("0.00");
                                }
                            }
                            catch(FormatException)
                            {
                                e1.Cancel = true;
                            }
                            break;
                    }
                };

                cmb.Show();
            }
        }