Esempio n. 1
0
        //Cadastro do erro no banco
        protected void Save(object sender, DirectEventArgs e)
        {
            MA_ERRO erro = new MA_ERRO();

            erro.tipo             = this.tipoId.Text;
            erro.aconteceu        = this.aconteceuId.Text;
            erro.incidencia       = Int32.Parse(this.incidenciaId.Text);
            erro.dt_acontecimento = (DateTime)this.dt_acontecimentoId.Value;

            //Caso o form não possui código, será inserido um novo usuário
            if (this.cod_erroId.Text == "")
            {
                this.GestorDeErro.InserirErro(erro);
                this.ErroWindowId.Close();
                this.LimpaForm();
            }
            //Caso contrário, o form será atualizado
            else
            {
                erro.cod_erro = Int32.Parse(this.cod_erroId.Text);
                this.GestorDeErro.AtualizarErro(erro);
                this.ErroWindowId.Close();
                LimpaForm();
            }
        }
Esempio n. 2
0
        //Exclui determinado erro do banco de dados
        protected void Delete(object sender, DirectEventArgs e)
        {
            MA_ERRO erro = this.GestorDeErro.ObterErroPorId(Int32.Parse(cod_erroId.Text));

            this.GestorDeErro.RemoverErro(erro);
            LimpaForm();
        }
Esempio n. 3
0
        public ActionResult Add(List <Erro> listaerro)
        {
            JsonResult jsonResult;

            //Verifica se o registro é inválido e se sim, retorna com erro.
            if (listaerro == null)
            {
                jsonResult = Json(new
                {
                    codigo = -1
                }, JsonRequestBehavior.AllowGet);

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            else
            {
                try
                {
                    MA_ERRO erro = new MA_ERRO();

                    erro.tipo             = listaerro[0].Tipo;
                    erro.aconteceu        = listaerro[0].Aconteceu;
                    erro.incidencia       = listaerro[0].Incidencia;
                    erro.dt_acontecimento = DateTime.Now;

                    if (GestorDeErro.InserirErroComRetorno(erro))
                    {
                        jsonResult = Json(new
                        {
                            codigo = erro.cod_erro
                        }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        jsonResult = Json(new
                        {
                            codigo = -1
                        }, JsonRequestBehavior.AllowGet);
                    }
                }
                catch (Exception e)
                {
                    jsonResult = Json(new
                    {
                        erro   = e.InnerException.ToString(),
                        codigo = -1
                    }, JsonRequestBehavior.AllowGet);
                }
            }

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Esempio n. 4
0
        public Boolean AtualizarErroComRetorno(MA_ERRO erro)
        {
            try
            {
                this.Contexto.Entry(erro).State = EntityState.Modified;
                this.Contexto.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 5
0
        public Boolean InserirErroComRetorno(MA_ERRO erro)
        {
            try
            {
                this.Contexto.MA_ERRO.Add(erro);
                this.Contexto.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 6
0
 public void AtualizarErro(MA_ERRO erro)
 {
     this.Contexto.Entry(erro).State = EntityState.Modified;
     this.Contexto.SaveChanges();
 }
Esempio n. 7
0
 public void RemoverErro(MA_ERRO erro)
 {
     this.Contexto.MA_ERRO.Remove(erro);
     this.Contexto.SaveChanges();
 }
Esempio n. 8
0
 public void InserirErro(MA_ERRO erro)
 {
     this.Contexto.MA_ERRO.Add(erro);
     this.Contexto.SaveChanges();
 }
Esempio n. 9
0
 public Boolean AtualizarErroComRetorno(MA_ERRO erro)
 {
     return(this.RepositorioDeErro.AtualizarErroComRetorno(erro));
 }
Esempio n. 10
0
 public void AtualizarErro(MA_ERRO erro)
 {
     this.RepositorioDeErro.AtualizarErro(erro);
 }
Esempio n. 11
0
 public void RemoverErro(MA_ERRO erro)
 {
     this.RepositorioDeErro.RemoverErro(erro);
 }
Esempio n. 12
0
 public Boolean InserirErroComRetorno(MA_ERRO erro)
 {
     return(this.RepositorioDeErro.InserirErroComRetorno(erro));
 }
Esempio n. 13
0
 public void InserirErro(MA_ERRO erro)
 {
     this.RepositorioDeErro.InserirErro(erro);
 }