Exemple #1
0
        public ActionResult Nova(int empresaId)
        {
            ContasManterModel cmm = new ContasManterModel();

            cmm.EmpresaId  = empresaId;
            cmm.TempId     = Guid.NewGuid();
            cmm.Categorias = _icategoriaServicos.GetByEmpresa(empresaId).Select(p => new SelectListItem()
            {
                Text = p.Descricao, Value = p.Id.ToString()
            });
            return(View("Manter", cmm));
        }
Exemple #2
0
        public ActionResult Agendar(ContasManterModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Categorias = _icategoriaServicos.GetByEmpresa(model.EmpresaId).Select(p => new SelectListItem()
                {
                    Text = p.Descricao, Value = p.Id.ToString()
                });
                return(View("Manter", model));
            }
            try
            {
                Boleto b = new Boleto();
                b.DataVencimento = model.Validade.Value;
                b.Empresa        = new Empresa()
                {
                    Id = model.EmpresaId
                };
                b.Fornecedor = new Fornecedor()
                {
                    Id = model.FornecedorId
                };
                b.Numero = model.NumeroConta.Replace(".", "").Replace(" ", "");
                b.Valor  = model.Valor;

                if (!model.UploadFile)
                {
                    throw new Exception("O Arquivo não foi carregado");
                }
                FileInfo fi = new FileInfo(Path.Combine(ConfigurationFactory.Instance.PastaTemp, model.TempId + ".pdf"));
                fi.CopyTo(Path.Combine(ConfigurationFactory.Instance.PastaBoleto, model.TempId + ".pdf"));

                _boletoService.Insert(b, new FileInfo(Path.Combine(ConfigurationFactory.Instance.PastaBoleto, model.TempId + ".pdf")));
            }
            catch (Exception ex)
            {
                model.Erro       = ex.Message;
                model.Categorias = _icategoriaServicos.GetByEmpresa(model.EmpresaId).Select(p => new SelectListItem()
                {
                    Text = p.Descricao, Value = p.Id.ToString()
                });
                return(View("Manter", model));
            }

            return(View("Index", model.EmpresaId));
        }
Exemple #3
0
        public ActionResult Agendar(ContasManterModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Categorias = _icategoriaServicos.GetByEmpresa(model.EmpresaId).Select(p => new SelectListItem()
                {
                    Text = p.Descricao, Value = p.Id.ToString()
                });
                return(View("Manter", model));
            }
            try
            {
                Boleto b = new Boleto();
                b.DataVencimento = model.Validade.Value;
                b.Empresa        = new Empresa()
                {
                    Id = model.EmpresaId
                };
                b.Fornecedor = new Fornecedor()
                {
                    Id = model.FornecedorId
                };
                b.Numero = model.NumeroConta.Replace(".", "").Replace(" ", "");
                b.Valor  = model.Valor;

                if (!model.UploadFile)
                {
                    throw new Exception("O Arquivo não foi carregado");
                }
                FileInfo fi = new FileInfo(Path.Combine(ConfigurationFactory.Instance.PastaTemp, model.TempId + ".pdf"));



                try
                {
                    UnitOfWorkNHibernate.GetInstancia().IniciarTransacao();
                    _boletoService.Insert(b, fi, ConfigurationFactory.Instance.PastaBoleto);
                    UnitOfWorkNHibernate.GetInstancia().ConfirmarTransacao();
                }
                catch (ExceptionMessage em)
                {
                    UnitOfWorkNHibernate.GetInstancia().DesfazerTransacao();
                    throw em;
                }
                catch (Exception ex)
                {
                    UnitOfWorkNHibernate.GetInstancia().DesfazerTransacao();
                    throw new StatusException("Erro interno . Favor informe ao administrador.");
                }
            }
            catch (Exception ex)
            {
                model.Erro       = ex.Message;
                model.Categorias = _icategoriaServicos.GetByEmpresa(model.EmpresaId).Select(p => new SelectListItem()
                {
                    Text = p.Descricao, Value = p.Id.ToString()
                });
                return(View("Manter", model));
            }

            return(View("Index", model.EmpresaId));
        }