Ejemplo n.º 1
0
 public void SalvarSubserieIndiceValor(SubserieIndiceValor _subserieIndiceValor)
 {
     try
     {
         if (_subserieIndiceValor.Registro == 0)
         {
             _DAO.Add(_subserieIndiceValor);
             _DAO.SaveChanges();
         }
         else
         {
             _DAO.Atualizar(_subserieIndiceValor, _subserieIndiceValor.Registro);
         }
     }
     catch (DbEntityValidationException dbex)
     {
         throw new Erros.ErroDeValidacao(dbex);
     }
     catch (DbUpdateException dbuex)
     {
         throw new Erros.ErroGeral("Não foi possível concluir a operação. Verifique se o item não foi cadastrado previamente.");
     }
     catch (Exception ex)
     {
         throw new Erros.ErroGeral("Erro inesperado. " + ex.Message);
     }
 }
Ejemplo n.º 2
0
        public ActionResult EditarIndexacao(int Registro, List <int> regIndex, List <string> valor, List <int> regValor)
        {
            bool sucesso = false;

            //using (TransactionScope scope = new TransactionScope())
            //{
            try
            {
                SubserieIndiceValor _valorIndice = new SubserieIndiceValor();
                for (int i = 0; i < regIndex.Count; i++)
                {
                    _valorIndice       = _DAO.GetByRegistro(regValor[i]);
                    _valorIndice.Valor = valor[i];
                    _DAO.SalvarSubserieIndiceValor(_valorIndice);
                }

                sucesso = true;
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Editar", new { _registroDocumento = Registro }).ComMensagemDeErro(ex.Message));
            }
            if (sucesso)
            {
                //  scope.Complete();
                return(RedirectToAction("Revisar", "Documento", new { _registroDocumento = Registro }).ComMensagemDeSucesso("Indexadores atualizados com sucesso"));
            }
            return(RedirectToAction("Index", "Home"));
            //}
        }
Ejemplo n.º 3
0
        public ActionResult Indexar(int Registro, List <int> regIndex, List <string> valor)
        {
            bool sucesso = false;

            if (!ModelState.IsValid)
            {
                return(View("Indexacao", new DocumentoBO().GetByRegistro(Registro)));
            }
            //using (TransactionScope scope = new TransactionScope())
            //{
            try
            {
                SubserieIndiceValor _valorIndice;
                for (int i = 0; i < regIndex.Count; i++)
                {
                    _valorIndice = new SubserieIndiceValor(Registro, regIndex[i], valor[i]);
                    SalvarIndice(_valorIndice);
                }

                new DocumentoBO().RegistrarIndexacaoDocumento(Registro, Seguranca.UsuarioLogado().Registro);

                sucesso = true;
            }
            catch (Exception ex)
            {
                sucesso = false;

                // MetodosUtilidadeGeral.MensagemDeErro(ex.Message, Response);
                valor = new List <string>();
                return(RedirectToAction("Indexacao", new { _registroDocumento = Registro }).ComMensagemDeErro(ex.Message));
            }

            if (sucesso)
            {
                //scope.Complete();
                return(RedirectToAction("ConcluirCaptura", "Documento", new { _registroDocumento = Registro }));
            }
            //else
            //{
            //    scope.Dispose();
            return(View("Indexacao", new DocumentoBO().GetByRegistro(Registro)));
            //}
            // }
        }
Ejemplo n.º 4
0
 private void SalvarIndice(SubserieIndiceValor _valorIndice)
 {
     if (new SubserieIndiceBO().GetByRegistro(_valorIndice.Indice).Obrigatorio)
     {
         if (_valorIndice.Valor.Trim() != string.Empty && _valorIndice.Valor.Trim() != null)
         {
             _DAO.SalvarSubserieIndiceValor(_valorIndice);
         }
         else
         {
             throw new Erros.ErroGeral("Um indexador obrigatório não foi preenchido");
         }
     }
     else
     if (_valorIndice.Valor.Trim() != string.Empty && _valorIndice.Valor.Trim() != null)
     {
         _DAO.SalvarSubserieIndiceValor(_valorIndice);
     }
 }