Ejemplo n.º 1
0
        public JsonResult SalvarRegistro(fin_credito_debito pfincreditodebito)
        {
            string lMsg = "{0} Registrado com Sucesso!";

            try
            {
                fin_credito_debito lfincreditodebito = new fin_credito_debito();
                lfincreditodebito.FCD_DATA_CADASTRO = DateTime.Now;
                lfincreditodebito.FCD_VALOR         = decimal.Parse(pfincreditodebito.FCD_VALORS);
                lfincreditodebito.CAT_CODIGO        = pfincreditodebito.CAT_CODIGO;

                if (pfincreditodebito.FCD_TIPO.Equals("D"))
                {
                    lMsg = string.Format(lMsg, "Débito");
                }
                else
                {
                    lMsg = string.Format(lMsg, "Crédito");
                }

                db.Dbfin_credito_debito.Add(lfincreditodebito);
                db.SaveChanges().ToString();
            }
            catch (Exception e)
            {
                return(Json(gUtil.Mensagem(Util.TipoMensagem.Erro, "Não foi possível Salvar. <br /> Erro: " + e.Message)));

                throw;
            }

            return(Json(gUtil.Mensagem(Util.TipoMensagem.Sucesso, lMsg)));
        }
Ejemplo n.º 2
0
        public JsonResult CarregarRegistros(fin_credito_debito pfincreditodebito)
        {
            try
            {
                List <Relfin_credito_debitoDto> lList = new List <Relfin_credito_debitoDto>();
                var lConsulta = (from fcd in db.Dbfin_credito_debito
                                 join cat in db.Dbfin_categoria on new { fcd.CAT_CODIGO } equals new { cat.CAT_CODIGO }

                                 select new Relfin_credito_debitoDto()
                {
                    FCD_CODIGO = fcd.FCD_CODIGO,
                    MesAnoPesquisa = fcd.FCD_DATA_CADASTRO,
                    CAT_TIPO = cat.CAT_TIPO,
                    CAT_CODIGO = fcd.CAT_CODIGO,
                    CAT_NOME = cat.CAT_NOME,
                    FCD_VALOR = fcd.FCD_VALOR
                });

                if (!string.IsNullOrEmpty(pfincreditodebito.CAT_TIPO))
                {
                    lConsulta = lConsulta.Where(l => l.CAT_TIPO == pfincreditodebito.CAT_TIPO);
                }
                if (pfincreditodebito.CAT_CODIGO > 0)
                {
                    lConsulta = lConsulta.Where(l => l.CAT_CODIGO == pfincreditodebito.CAT_CODIGO);
                }
                if (!string.IsNullOrEmpty(pfincreditodebito.MesAnoPesquisa))
                {
                    String lteste = "03/2021";
                    String p      = lteste.Substring(3, 4);

                    lConsulta = lConsulta.Where(l => l.MesAnoPesquisa.ToString().Substring(5, 2) == pfincreditodebito.MesAnoPesquisa.Substring(0, 2) && l.MesAnoPesquisa.ToString().Substring(0, 4) == pfincreditodebito.MesAnoPesquisa.Substring(3, 4));
                }
                lList = lConsulta.OrderByDescending(l => l.FCD_CODIGO).ToList <Relfin_credito_debitoDto>();


                return(Json(lList, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json("Não foi possível Carregar. <br /> Erro: " + e.Message));
            }
        }
Ejemplo n.º 3
0
        public JsonResult DeletarPorFcdCodigo(string pFcdCodigo)
        {
            try
            {
                if (!string.IsNullOrEmpty(pFcdCodigo))
                {
                    int lFcdCodigo = int.Parse(pFcdCodigo);

                    fin_credito_debito Usuario = db.Dbfin_credito_debito.Find(lFcdCodigo);
                    db.Dbfin_credito_debito.Remove(Usuario);
                    db.SaveChanges();

                    return(Json(gUtil.Mensagem(Util.TipoMensagem.Sucesso, "Registro Excluído!")));
                }
                else
                {
                    return(Json(gUtil.Mensagem(Util.TipoMensagem.Alerta, "Não foi possível excluir o registro.")));
                }
            }
            catch (Exception e)
            {
                return(Json(gUtil.Mensagem(Util.TipoMensagem.Erro, "Não foi possível excluir o registro. <br /> Erro: " + e.Message)));
            }
        }