Exemplo n.º 1
0
        public ActionResult Inserir_Rendimento(OperacaoModel operacaoModel)
        {
            if (!this.ModelState.IsValid)
            {
                List <string> erros = (from item in ModelState.Values
                                       from error in item.Errors
                                       select error.ErrorMessage).ToList();
                Response.StatusCode = 400;

                ViewBag.ErroCadastro = string.Join(Environment.NewLine, erros);

                //Adicionar uma modal para tratamento de erro;
            }

            DTO.Id_Usuario      = LogarBLL.ConsultarUsuarioSessao();
            DTO.NomeOperacao    = operacaoModel.NomeOperacao;
            DTO.ValorParcela    = operacaoModel.ValorParcela;
            DTO.QtdParcela      = operacaoModel.QtdParcela;
            DTO.DataRecebimento = operacaoModel.DataOperacao;

            if (string.IsNullOrEmpty(operacaoModel.Descricao))
            {
                DTO.Descriacao = string.Empty;
            }
            else
            {
                DTO.Descriacao = operacaoModel.Descricao;
            }
            //BLL.InserirRendimento(DTO);

            //Implementar mensagem de sucesso !
            return(Redirect(Url.Action("Index", "Ativos")));
            //return View("Index");
        }
Exemplo n.º 2
0
        public ActionResult CalcularParcelas(OperacaoModel operacao)
        {
            if (!this.ModelState.IsValid)
            {
                return(RedirectToAction("~/Principal/_OperacaoModal", operacao));
            }

            try
            {
                OperacaoBLL operacaoBLL     = new OperacaoBLL();
                string      mensagemCritica = string.Empty;

                ListaParcelas = operacaoBLL.GerarParcelas(operacao);

                double total          = ListaParcelas.Sum(x => x.Valor_Parcela);
                var    valorFormatado = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "{0:C}", total);
                mensagemCritica = "Valor total da Operação " + valorFormatado;

                var result = new { Success = "True", Message = mensagemCritica };

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception erro)
            {
                var result = new { Success = "False", Message = erro.Message };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        public ActionResult PostTransferencia(OperacaoModel operacaoModel)
        {
            OperacaoApplication operacaoApplication = new OperacaoApplication();

            HttpResponseMessage response = operacaoApplication.Transferencia(operacaoModel);

            return(RedirectToAction("ListExtrato", new { id = operacaoModel.Num_idConta1 }));
        }
Exemplo n.º 4
0
        public ActionResult CreateTransferencia(int id)
        {
            OperacaoModel operacaoModel = new OperacaoModel
            {
                Num_idConta1     = id,
                Num_TipoOperacao = 3
            };

            return(View(operacaoModel));
        }
Exemplo n.º 5
0
        public ActionResult CreateSaque(int id)
        {
            OperacaoModel operacaoModel = new OperacaoModel
            {
                Num_idConta1     = id,
                Num_TipoOperacao = 1
            };

            return(View(operacaoModel));
        }
Exemplo n.º 6
0
 public List <OperacaoModel> Listar(OperacaoModel obj)
 {
     try
     {
         return(Selecionar(obj));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 7
0
 public OperacaoModel Consultar(OperacaoModel obj)
 {
     try
     {
         List <OperacaoModel> lst = Selecionar(obj);
         return(lst.Count > 0 ? lst.FirstOrDefault() : null);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 8
0
        public OperacaoModel Consultar(OperacaoModel obj = null)
        {
            OperacaoDAO operacaoDAO = null;

            try
            {
                operacaoDAO = new OperacaoDAO(GetSqlCommand());
                return(operacaoDAO.Consultar(obj));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        public void GravarParcelas(OperacaoModel operacao)
        {
            if (pTipoOperacaoDefinida == TipoOperacao.Passivo)
            {
                PassivosBLL passivo = new PassivosBLL();

                if (operacao.IdOperacao > 0)
                {
                    passivo.DeletarPassivo(operacao.IdOperacao);
                }

                string identity_Inserido;
                if (listaParcelasPassivo.Count > 0)
                {
                    identity_Inserido = passivo.InserirPassivo(passivo.ConvertModeltoObj(operacao), listaParcelasPassivo);

                    if (int.TryParse(identity_Inserido, out int identityInserido))
                    {
                        passivo.InserirParcela(listaParcelasPassivo, identityInserido);
                    }
                }
                else
                {
                }
            }
            else if (pTipoOperacaoDefinida == TipoOperacao.Rendimento)
            {
                RendimentoBLL redimento = new RendimentoBLL();
                if (operacao.IdOperacao > 0)
                {
                    redimento.DeletarRendimento(operacao.IdOperacao);
                }

                string identity_Inserido;
                if (listaParcelasRendimento.Count > 0)
                {
                    identity_Inserido = redimento.InserirRendimento(redimento.ConvertModeltoObj(operacao), listaParcelasRendimento);

                    if (int.TryParse(identity_Inserido, out int identityInserido))
                    {
                        redimento.InserirParcela(listaParcelasRendimento, identityInserido);
                    }
                }
            }
        }
Exemplo n.º 10
0
        public string CalcularParcelas(OperacaoModel operacao)
        {
            PassivosBLL passivo = new PassivosBLL();

            string mensagemCritica = string.Empty;

            if (!this.ModelState.IsValid)
            {
                List <string> erros = (from item in ModelState.Values
                                       from error in item.Errors
                                       select error.ErrorMessage).ToList();

                mensagemCritica = string.Join(Environment.NewLine, erros);

                return(mensagemCritica);
            }

            PassivosDTO objPassivo = passivo.ConvertModeltoObj(operacao);

            if (pTipoOperacaoDefinida == TipoOperacao.Passivo)
            {
                listaParcelasPassivo = passivo.GerarParcelas(objPassivo);
            }
            else if (pTipoOperacaoDefinida == TipoOperacao.Rendimento)
            {
                listaParcelasRendimento = passivo.GerarParcelas(objPassivo);
            }

            double total;

            if (operacao.TipodeCalculo == TipodeCalculo.parcela)
            {
                total = listaParcelasRendimento.Sum(x => x.Valor_Parcela);
                var valorFormatado = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "{0:C}", total);
                mensagemCritica = "Valor total da Operação " + valorFormatado;
            }
            else if (operacao.TipodeCalculo == TipodeCalculo.opercacao)
            {
                total = listaParcelasRendimento[0].Valor_Parcela;
                var valorFormatado = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "{0:C}", total);
                mensagemCritica = "Valor da parcela " + valorFormatado;
            }

            return(mensagemCritica);
        }
        public HttpResponseMessage Transferencia(OperacaoModel operacaoModel)
        {
            string URL = "http://localhost:19868/api/Operacao/Transferencia";

            HttpResponseMessage response = client.PostAsync(URL, operacaoModel, new JsonMediaTypeFormatter
            {
                SerializerSettings = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Include,
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                    ContractResolver      = new DefaultContractResolver
                    {
                        IgnoreSerializableAttribute = true
                    }
                }
            }).Result;


            return(response);
        }
Exemplo n.º 12
0
        public List <OperacaoParcelasDTO> GerarParcelas(OperacaoModel pOperacao)
        {
            List <OperacaoParcelasDTO> lista = new List <OperacaoParcelasDTO>();

            for (int x = 1; x <= pOperacao.QtdParcela; x++)
            {
                OperacaoParcelasDTO objParcela = new OperacaoParcelasDTO();

                objParcela.Numero_Parcela = x;
                // Sera ajustado no Futuro !
                // decimal valorParcela = pOperacao.TipodeCalculo == TipodeCalculo.Parcela ? (decimal)pOperacao.ValorParcela : (decimal)pOperacao.ValorParcela / pOperacao.QtdParcela;
                decimal valorParcela = (decimal)pOperacao.ValorParcela;

                objParcela.Valor_Parcela         = (double)valorParcela;
                objParcela.DataVencimentoParcela = x == 1 ? pOperacao.DataOperacao : pOperacao.DataOperacao.AddMonths(x - 1);
                objParcela.Status = StatusParcela.EmAberto;

                lista.Add(objParcela);
            }

            return(lista);
        }
Exemplo n.º 13
0
        public ActionResult GravarParcelas(OperacaoModel operacao)
        {
            if (!this.ModelState.IsValid)
            {
                return(RedirectToAction("~/Principal/_OperacaoModal", operacao));
            }

            try
            {
                if (operacao.IdOperacao > 0)
                {
                    operacaoBLL.DeletarOperacao(operacao.IdOperacao);
                }

                string identity_Inserido;
                if (ListaParcelas.Count > 0)
                {
                    OperacaoDTO objOperacao = operacaoBLL.ConvertModeltoObj(operacao);

                    objOperacao.ValorOperacao = ListaParcelas.Sum(x => x.Valor_Parcela);
                    identity_Inserido         = operacaoBLL.InserirOperacao(objOperacao);

                    if (int.TryParse(identity_Inserido, out int identityInserido))
                    {
                        operacaoBLL.InserirParcela(ListaParcelas, identityInserido);
                    }
                }

                var result = new { Success = "True", Message = "Operação registrada." };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception erro)
            {
                var result = new { Success = "False", Message = erro.Message };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 14
0
 public PartialViewResult _OperacaoModal(OperacaoModel operacaoModel)
 {
     return(PartialView(operacaoModel));
 }
Exemplo n.º 15
0
        private List <OperacaoModel> Selecionar(OperacaoModel obj)
        {
            List <OperacaoModel> lst = null;

            try
            {
                objSbSelect = new StringBuilder();

                objSbSelect.AppendLine(@"
                                            SELECT Operacao.IdOperacao
                                                 , Operacao.Descricao
                                                 , Operacao.Sigla
                                                 , Operacao.Custo
                                            FROM DBBanco.dbo.Operacao
                                            WHERE 1 = 1 ");

                if (obj != null)
                {
                    GetSqlCommand().Parameters.Clear();
                    if (obj.Id > 0)
                    {
                        objSbSelect.AppendLine(@" AND Operacao.IdOperacao = @IdOperacao");
                        GetSqlCommand().Parameters.Add("IdOperacao", SqlDbType.Int).Value = obj.Id;
                    }
                    if (!string.IsNullOrEmpty(obj.Descricao))
                    {
                        objSbSelect.AppendLine(@" AND Operacao.Descricao = @Descricao");
                        GetSqlCommand().Parameters.Add("Descricao", SqlDbType.VarChar).Value = obj.Descricao;
                    }
                    if (!string.IsNullOrEmpty(obj.Sigla))
                    {
                        objSbSelect.AppendLine(@" AND Operacao.Sigla = @Sigla");
                        GetSqlCommand().Parameters.Add("Sigla", SqlDbType.VarChar).Value = obj.Sigla;
                    }
                }

                GetSqlCommand().CommandText = "";
                GetSqlCommand().CommandText = objSbSelect.ToString();

                lst = new List <OperacaoModel>();

                while (GetSqlDataReader().Read())
                {
                    OperacaoModel item = new OperacaoModel();

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("IdOperacao"))))
                    {
                        item.Id = Convert.ToInt32(GetSqlDataReader()["IdOperacao"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Descricao"))))
                    {
                        item.Descricao = Convert.ToString(GetSqlDataReader()["Descricao"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Sigla"))))
                    {
                        item.Sigla = Convert.ToString(GetSqlDataReader()["Sigla"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Custo"))))
                    {
                        item.Custo = Convert.ToDecimal(GetSqlDataReader()["Custo"]);
                    }

                    lst.Add(item);
                }

                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objSbSelect != null)
                {
                    objSbSelect = null;
                }
                Close();
            }
        }