Exemplo n.º 1
0
        public DENUNCIA Crear(DENUNCIA denuncia)
        {
            int      ID_DENUNCIA    = 0;
            DENUNCIA DENUNCIACreado = null;
            string   sql            = "INSERT INTO [DENUNCIA] (ID_USUARIO,TIPODENUNCIA,FECHADENUNCIA,DESCRIPCION,ESTADO) VALUES (@ID_USUARIO,@TIPODENUNCIA,@FECHADENUNCIA,@DESCRIPCION,@ESTADO);"
                                      + "SELECT SCOPE_IDENTITY()";

            using (SqlConnection conexion = new SqlConnection(CadenaConexion))
            {
                conexion.Open();
                using (SqlCommand comando = new SqlCommand(sql, conexion))
                {
                    comando.Parameters.Add(new SqlParameter("@ID_USUARIO", denuncia.ID_USUARIO));
                    comando.Parameters.Add(new SqlParameter("@TIPODENUNCIA", denuncia.TIPODENUNCIA));
                    comando.Parameters.Add(new SqlParameter("@FECHADENUNCIA", denuncia.FECHADENUNCIA));
                    comando.Parameters.Add(new SqlParameter("@DESCRIPCION", denuncia.DESCRIPCION));
                    comando.Parameters.Add(new SqlParameter("@ESTADO", denuncia.ESTADO));
                    ID_DENUNCIA = (int)(decimal)comando.ExecuteScalar();
                }
            }

            denuncia.DETALLE_FOTOS.ForEach(x => x.ID_DENUNCIA = ID_DENUNCIA);

            CrearDetalleFoto(denuncia.DETALLE_FOTOS);

            DENUNCIACreado = Obtener(ID_DENUNCIA);
            return(DENUNCIACreado);
        }
Exemplo n.º 2
0
        public List <DENUNCIA> ListarTodos()
        {
            List <DENUNCIA> DENUNCIAesEncontrado = new List <DENUNCIA>();
            DENUNCIA        DENUNCIAEncontrado   = null;
            string          sql = "SELECT * FROM DENUNCIA";

            using (SqlConnection conexion = new SqlConnection(CadenaConexion))
            {
                conexion.Open();
                using (SqlCommand comando = new SqlCommand(sql, conexion))
                {
                    using (SqlDataReader resultado = comando.ExecuteReader())
                    {
                        while (resultado.Read())
                        {
                            DENUNCIAEncontrado = new DENUNCIA()
                            {
                                ID_DENUNCIA   = (int)resultado["ID_DENUNCIA"],
                                ID_USUARIO    = (int)resultado["ID_USUARIO"],
                                TIPODENUNCIA  = (string)resultado["TIPODENUNCIA"],
                                FECHADENUNCIA = (DateTime)resultado["FECHADENUNCIA"],
                                DESCRIPCION   = (string)resultado["DESCRIPCION"],
                                ESTADO        = (string)resultado["ESTADO"],
                            };

                            DENUNCIAesEncontrado.Add(DENUNCIAEncontrado);
                        }
                    }
                }
            }
            return(DENUNCIAesEncontrado);
        }
Exemplo n.º 3
0
        public DENUNCIA Obtener(int ID_DENUNCIA)
        {
            DENUNCIA DENUNCIAEncontrado = null;
            string   sql = "SELECT * FROM DENUNCIA WHERE ID_DENUNCIA=@ID_DENUNCIA";

            using (SqlConnection conexion = new SqlConnection(CadenaConexion))
            {
                conexion.Open();
                using (SqlCommand comando = new SqlCommand(sql, conexion))
                {
                    comando.Parameters.Add(new SqlParameter("@ID_DENUNCIA", ID_DENUNCIA));
                    using (SqlDataReader resultado = comando.ExecuteReader())
                    {
                        if (resultado.Read())
                        {
                            DENUNCIAEncontrado = new DENUNCIA()
                            {
                                ID_DENUNCIA   = (int)resultado["ID_DENUNCIA"],
                                ID_USUARIO    = (int)resultado["ID_USUARIO"],
                                TIPODENUNCIA  = (string)resultado["TIPODENUNCIA"],
                                FECHADENUNCIA = (DateTime)resultado["FECHADENUNCIA"],
                                DESCRIPCION   = (string)resultado["DESCRIPCION"],
                                ESTADO        = (string)resultado["ESTADO"],
                            };
                            var fotos = ObtenerDetalleFoto(DENUNCIAEncontrado.ID_DENUNCIA);
                            DENUNCIAEncontrado.DETALLE_FOTOS = fotos;
                        }
                    }
                }
            }
            return(DENUNCIAEncontrado);
        }
Exemplo n.º 4
0
        //public void Controle(int id)
        //{

        //}

        public void Alterar(DENUNCIA oDenuncia, bool attach = true)
        {
            if (attach)
            {
                odb.Entry(oDenuncia).State = System.Data.Entity.EntityState.Modified;
            }
            odb.SaveChanges();
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "IDD,Denunciante,TextoDenuncia,Email,CEP,TipoLogradouro,NomeLogradouro,Numero,Complemento,Bairro,Cidade,UF,Data,DataResposta")] DENUNCIA oDenuncia)
        {
            if (ModelState.IsValid)
            {
                _repositoryDenuncia.Incluir(oDenuncia);
                return(RedirectToAction("Index", "Home"));
            }

            return(View(oDenuncia));
        }
Exemplo n.º 6
0
        public DENUNCIA CrearDenuncia(DENUNCIA denuncia)
        {
            DENUNCIA oDENUNCIA = new DENUNCIA();

            denuncia.FECHADENUNCIA = DateTime.Now;

            //Validacion de usuario existente
            var oUsuario = oUsuarioDAO.ObtenerPorId(denuncia.ID_USUARIO);

            if (oUsuario == null)
            {
                throw new WebFaultException <string>("Usuario no se encuentra registrado", HttpStatusCode.InternalServerError);
            }

            //validacion de dos denuncias maximas por usuario al dia
            List <DENUNCIA> denuciaAcumulada = oDAO.ObtenerXUsuario(denuncia.ID_USUARIO);
            string          hoy            = DateTime.Now.Date.ToShortDateString();
            var             nunDenunciaDia = denuciaAcumulada.Where(x => x.FECHADENUNCIA.ToShortDateString() == hoy).Count();

            if (nunDenunciaDia >= 2)
            {
                throw new WebFaultException <string>("Excedio el numero maximo de denuncia por dia", HttpStatusCode.InternalServerError);
            }

            TimeSpan timeOfDay = denuncia.FECHADENUNCIA.TimeOfDay;
            int      hour      = timeOfDay.Hours;

            if (hour < 5 || hour > 23)
            {
                throw new WebFaultException <string>("No se puede procesar la denuncia porque se encuentra fuera de límite de horario", HttpStatusCode.InternalServerError);
            }

            if (denuncia.TIPODENUNCIA.Trim().ToUpper().Equals("VANDALISMO"))
            {
                if (!MessageQueue.Exists(rutaCola))
                {
                    MessageQueue.Create(rutaCola);
                }

                MessageQueue cola    = new MessageQueue(rutaCola);
                Message      mensaje = new Message();
                mensaje.Label = "Enviando Cola Denuncia tipo Vandalismo";
                mensaje.Body  = denuncia;

                cola.Send(mensaje);
            }
            else
            {
                oDENUNCIA = oDAO.Crear(denuncia);
            }

            return(oDENUNCIA);
        }
Exemplo n.º 7
0
        private void BtnExcluir_Click(object sender, EventArgs e)
        {
            DENUNCIA oDenuncia;

            oDenuncia = _Control.SelecionarID(Convert.ToInt32(TxtIDD.Text));
            if (Mensagens.MsgPerguntaExclusao() == DialogResult.Yes)
            {
                _Control.Excluir(oDenuncia);
                LimpaDados();
                Mensagens.MsgExcluido();
                this.Close();
            }
        }
Exemplo n.º 8
0
        private void GrdDenuncia_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DENUNCIA oDenuncia = ((DENUNCIA)GrdDenuncia.Rows[e.RowIndex].DataBoundItem);

            if (GrdDenuncia.Rows[e.RowIndex].DataBoundItem != null)
            {
                if (GrdDenuncia.Columns[e.ColumnIndex].Name == "BtnEscolher")
                {
                    TelaDenuncia frmDenuncia = new TelaDenuncia(oDenuncia);
                    frmDenuncia.MdiParent = this.MdiParent;
                    frmDenuncia.Show();
                    this.Close();
                }
            }
        }
Exemplo n.º 9
0
        public List <DENUNCIA> ObtenerXAdministrador()
        {
            List <DENUNCIA> DENUNCIAesEncontrado = new List <DENUNCIA>();
            DENUNCIA        DENUNCIAEncontrado   = null;
            string          sql = "SELECT * FROM DENUNCIA a INNER JOIN SEG_USUARIO b ON B.ID_USUARIO= a.ID_USUARIO";

            using (SqlConnection conexion = new SqlConnection(CadenaConexion))
            {
                conexion.Open();
                using (SqlCommand comando = new SqlCommand(sql, conexion))
                {
                    using (SqlDataReader resultado = comando.ExecuteReader())
                    {
                        while (resultado.Read())
                        {
                            DENUNCIAEncontrado = new DENUNCIA()
                            {
                                ID_DENUNCIA   = (int)resultado["ID_DENUNCIA"],
                                ID_USUARIO    = (int)resultado["ID_USUARIO"],
                                TIPODENUNCIA  = (string)resultado["TIPODENUNCIA"],
                                FECHADENUNCIA = (DateTime)resultado["FECHADENUNCIA"],
                                DESCRIPCION   = (string)resultado["DESCRIPCION"],
                                ESTADO        = (string)resultado["ESTADO"],
                            };

                            DENUNCIAEncontrado.USUARIO = new USUARIO
                            {
                                ID_USUARIO    = (int)resultado["ID_USUARIO"],
                                NOMBRE        = (string)resultado["NOMBRE"],
                                APE_PAT       = (string)resultado["APE_PAT"],
                                APE_MAT       = (string)resultado["APE_MAT"],
                                TIPOPROFESION = (string)resultado["TIPOPROFESION"],
                                SEXO          = (string)resultado["SEXO"],
                                EMAIL         = (string)resultado["EMAIL"],
                                COD_PERFIL    = (string)resultado["COD_PERFIL"],
                                NombreFull    = string.Format("{0} {1}, {2}", (string)resultado["APE_PAT"], (string)resultado["APE_MAT"], (string)resultado["NOMBRE"]),
                            };

                            DENUNCIAEncontrado.DETALLE_FOTOS = ObtenerDetalleFoto(DENUNCIAEncontrado.ID_DENUNCIA);

                            DENUNCIAesEncontrado.Add(DENUNCIAEncontrado);
                        }
                    }
                }
            }
            return(DENUNCIAesEncontrado);
        }
Exemplo n.º 10
0
        public DENUNCIA ModificarDenuncia(DENUNCIA denuncia)
        {
            //Validacion de usuario existente
            var oUsuario = oUsuarioDAO.ObtenerPorId(denuncia.ID_USUARIO);

            if (oUsuario == null)
            {
                throw new WebFaultException <string>("Usuario no se encuentra registrado", HttpStatusCode.InternalServerError);
            }

            if (oUsuario.COD_PERFIL.Equals("USU"))
            {
                throw new WebFaultException <string>("Usuario no tiene permisos para modificar denuncia", HttpStatusCode.InternalServerError);
            }

            return(oDAO.Modificar(denuncia));
        }
Exemplo n.º 11
0
        public DENUNCIA RegistrarDenuncia(DENUNCIA DENUNCIAACrear)
        {
            List <DENUNCIA> denuciaAcumulada = oDAO.ObtenerXUsuario(DENUNCIAACrear.ID_USUARIO);
            DateTime        hoy            = DateTime.Now.Date;
            var             nunDenunciaDia = denuciaAcumulada.Where(x => x.FECHADENUNCIA >= hoy).Count();

            if (nunDenunciaDia > 5)
            {
                throw new FaultException <ExceptionBase>(
                          new ExceptionBase()
                {
                    Codigo      = "101",
                    Descripcion = "Exedio el numero maximo de denuncia por dia",
                }, new FaultReason("Error al intentar creacion"));
            }

            return(oDAO.Crear(DENUNCIAACrear));
        }
Exemplo n.º 12
0
        public void TestCrearDenuncia()
        {
            DENUNCIA oenvio = new DENUNCIA()
            {
                ID_USUARIO    = 2,
                TIPODENUNCIA  = "Urgente",
                FECHADENUNCIA = DateTime.Now,
                DESCRIPCION   = "Unos rateros golpearon a un ancia para robarle su celular",
                ESTADO        = "ENVIADO",
            };

            var postdata = new JavaScriptSerializer().Serialize(oenvio);

            string rpt = Rest(postdata, "POST", "DenunciasService.svc/CrearDenuncia");

            JavaScriptSerializer js   = new JavaScriptSerializer();
            DENUNCIA             ORPT = js.Deserialize <DENUNCIA>(rpt);

            Assert.AreEqual(2, ORPT.ID_USUARIO);
            Assert.AreEqual("Urgente", ORPT.TIPODENUNCIA);
        }
Exemplo n.º 13
0
        public List <DENUNCIA> ObtenerDenunciaPorUsuario(int ID_USUARIO)
        {
            List <DENUNCIA> oLista   = null;
            var             oUsuario = oUsuarioDAO.ObtenerPorId(ID_USUARIO);

            if (oUsuario == null)
            {
                throw new WebFaultException <string>("Usuario no se encuentra registrado", HttpStatusCode.InternalServerError);
            }

            if (oUsuario.COD_PERFIL.Equals("ADM"))
            {
                //Obtenemos las denuncias de la cola
                DENUNCIA oDenuncia = null;
                if (MessageQueue.Exists(rutaCola))
                {
                    MessageQueue cola = new MessageQueue(rutaCola);
                    cola.Formatter = new XmlMessageFormatter(new Type[] { typeof(DENUNCIA) });
                    var contador = cola.GetAllMessages().Count();
                    if (contador > 0)
                    {
                        while (contador-- > 0)
                        {
                            Message mensajeIn = cola.Receive();
                            oDenuncia = (DENUNCIA)mensajeIn.Body;
                            var oCreada = oDAO.Crear(oDenuncia);
                        }
                    }
                }


                oLista = oDAO.ObtenerXAdministrador();
            }
            else
            {
                oLista = oDAO.ObtenerXUsuario(ID_USUARIO);
            }

            return(oLista);
        }
Exemplo n.º 14
0
        public DENUNCIA Modificar(DENUNCIA denuncia)
        {
            DENUNCIA SEG_USUARIOModificado = null;
            string   sql = "UPDATE DENUNCIA SET ID_USUARIO=@ID_USUARIO, TIPODENUNCIA=@TIPODENUNCIA, FECHADENUNCIA=@FECHADENUNCIA, DESCRIPCION=@DESCRIPCION, ESTADO=@ESTADO WHERE ID_DENUNCIA=@ID_DENUNCIA";

            using (SqlConnection conexion = new SqlConnection(CadenaConexion))
            {
                conexion.Open();
                using (SqlCommand comando = new SqlCommand(sql, conexion))
                {
                    comando.Parameters.Add(new SqlParameter("@ID_USUARIO", denuncia.ID_USUARIO));
                    comando.Parameters.Add(new SqlParameter("@TIPODENUNCIA", denuncia.TIPODENUNCIA));
                    comando.Parameters.Add(new SqlParameter("@FECHADENUNCIA", denuncia.FECHADENUNCIA));
                    comando.Parameters.Add(new SqlParameter("@DESCRIPCION", denuncia.DESCRIPCION));
                    comando.Parameters.Add(new SqlParameter("@ESTADO", denuncia.ESTADO));
                    comando.Parameters.Add(new SqlParameter("@ID_DENUNCIA", denuncia.ID_DENUNCIA));
                    comando.ExecuteNonQuery();
                }
            }
            SEG_USUARIOModificado = Obtener(denuncia.ID_DENUNCIA);
            return(SEG_USUARIOModificado);
        }
 public DENUNCIA RegistrarDenuncia(DENUNCIA denuncia)
 {
     return(oBL.RegistrarDenuncia(denuncia));
 }
Exemplo n.º 16
0
 public TelaDenuncia(DENUNCIA denuncia)
 {
     InitializeComponent();
     _denuncia = denuncia;
     PopulaCampos();
 }
Exemplo n.º 17
0
 public DENUNCIA CrearDenuncia(DENUNCIA denuncia)
 {
     return(oBL.CrearDENUNCIA(denuncia));
 }
Exemplo n.º 18
0
 public DENUNCIA CrearDENUNCIA(DENUNCIA DENUNCIAACrear)
 {
     return(oDAO.Crear(DENUNCIAACrear));
 }
Exemplo n.º 19
0
 public void Excluir(DENUNCIA oDenuncia)
 {
     odb.DENUNCIA.Attach(oDenuncia);
     odb.DENUNCIA.Remove(oDenuncia);
     odb.SaveChanges();
 }
 public DENUNCIA ModificarDenuncia(DENUNCIA DenunciaModificar)
 {
     return(oBL.ModificarDenuncia(DenunciaModificar));
 }
Exemplo n.º 21
0
 public void Incluir(DENUNCIA oDenuncia)
 {
     _Repository.Incluir(oDenuncia);
 }
Exemplo n.º 22
0
 public void Alterar(DENUNCIA oDenuncia, bool attach = true)
 {
     _Repository.Alterar(oDenuncia, attach);
 }
Exemplo n.º 23
0
 public void Excluir(DENUNCIA oDenuncia)
 {
     _Repository.Excluir(oDenuncia);
 }
Exemplo n.º 24
0
 public void Incluir(DENUNCIA oDenuncia)
 {
     odb.DENUNCIA.Add(oDenuncia);
     odb.SaveChanges();
 }