Exemple #1
0
        public static void addPerito(Perito perito)
        {
            SqlConnection connection = null;

            try
            {
                connection = ConexionBD.getConnection();
                if (connection != null)
                {
                    SqlCommand command;
                    String     nombre = perito.Nombre;
                    String     correo = perito.Correo;
                    String     estado = perito.Estado;
                    String     query  = String.Format("INSERT INTO Perito (nombre, correo, estado) VALUES ('{0}', '{1}', '{2}')",
                                                      nombre, correo, estado);
                    command = new SqlCommand(query, connection);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #2
0
        public static void removePerito(Perito perito)
        {
            SqlConnection connection = null;

            try
            {
                connection = ConexionBD.getConnection();
                if (connection != null)
                {
                    SqlCommand command;
                    int        idPerito = perito.IdPerito;
                    String     query    = String.Format("UPDATE Perito SET estado = 'Eliminado' WHERE idPerito = {0}", idPerito);
                    command = new SqlCommand(query, connection);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
        private void llenarCampos()
        {
            Dictamen dictamen = DictamenDAO.getDictamenByIdReporte(idReporte);

            folio   = dictamen.Folio;
            peritos = PeritoDAO.getAllPeritos();
            cb_perito.ItemsSource = peritos;
            dp_fecha.SelectedDate = dictamen.Fecha;
            tb_Folio.Text         = dictamen.IdReporte.ToString();

            if (dictamen.Estado == "Inactivo")
            {
                tb_Descripcion.Text = dictamen.Descripcion;
                for (int i = 0; i < peritos.Count; i++)
                {
                    cb_perito.SelectedIndex = i;
                    Perito perito = (Perito)cb_perito.SelectedItem;
                    if (perito.IdPerito == dictamen.IdPerito)
                    {
                        break;
                    }
                    tb_Descripcion.IsEnabled = false;
                    cb_perito.IsEnabled      = false;
                }
            }
            else
            {
                MessageBox.Show("Dictamen en curso");
                this.Close();
            }
        }
        private void button_RegistrarDictamen_Click(object sender, RoutedEventArgs e)
        {
            if (validarCampos())
            {
                Dictamen dictamen = new Dictamen();
                dictamen.Folio       = folio;
                dictamen.Descripcion = tb_Descripcion.Text;
                peritoSeleccionado   = (Perito)cb_perito.SelectedItem;
                dictamen.IdPerito    = peritoSeleccionado.IdPerito;
                dictamen.Estado      = "Inactivo";
                string hora = DateTime.Now.ToString("t");
                dictamen.Hora = hora;

                try
                {
                    DictamenDAO.updateDictamen(dictamen);
                    MessageBox.Show("Dictamen realizado de manera exitosa.");
                    this.Close();
                }
                catch (Exception x)
                {
                    MessageBox.Show("Ocurrió un error, inténtelo de nuevo." + x.Message);
                }
            }
            else
            {
                MessageBox.Show("Asegúrese de llenar todos los campos.");
            }
        }
Exemple #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Perito perito = db.Perito.Find(id);

            db.Perito.Remove(perito);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "PeritoId")] Perito perito)
 {
     if (ModelState.IsValid)
     {
         db.Entry(perito).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(perito));
 }
Exemple #7
0
        public ActionResult Create(Perito perito)
        {
            if (ModelState.IsValid)
            {
                db.Perito.Add(perito);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(perito));
        }
Exemple #8
0
        // GET: Perito/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Perito perito = db.Perito.Find(id);

            if (perito == null)
            {
                return(HttpNotFound());
            }
            return(View(perito));
        }
 public String Eliminar(int idPerito)
 {
     using (TransitoContext dbSS =
                new TransitoContext())
     {
         Perito perito = new Perito();
         perito.IdPerito = idPerito;
         dbSS.Perito.Remove(perito);
         if (dbSS.SaveChanges() == 1)
         {
             return("{\"correcto\": \"si\"}");
         }
         else
         {
             return("{\"correcto\": \"no\"}");
         }
     }
 }
        public ActionResult Alta(int id, string tipo)
        {
            if (tipo.Equals("Agente"))
            {
                Agente agente = db.Agente.Find(id);
                agente.Estado = (Estado)Enum.Parse(typeof(Estado), "Aceptado");
                db.SaveChanges();
                enviarCorreo(id);
            }

            if (tipo.Equals("Abogado"))
            {
                Abogado abogado = db.Abogado.Find(id);
                abogado.Estado = (Estado)Enum.Parse(typeof(Estado), "Aceptado");
                db.SaveChanges();
                // enviarCorreo(id);
            }

            if (tipo.Equals("Perito"))
            {
                Perito perito = db.Perito.Find(id);
                perito.Estado = (Estado)Enum.Parse(typeof(Estado), "Aceptado");
                db.SaveChanges();
                // enviarCorreo(id);
            }

            if (tipo.Equals("AgenteIns"))
            {
                AgenteIns agenteIns = db.AgenteIns.Find(id);
                agenteIns.Estado = (Estado)Enum.Parse(typeof(Estado), "Aceptado");
                db.SaveChanges();
                // enviarCorreo(id);
            }

            if (tipo.Equals("Hipoteca"))
            {
                Hipoteca hipoteca = db.Hipoteca.Find(id);
                hipoteca.Estado = (Estado)Enum.Parse(typeof(Estado), "Aceptado");
                db.SaveChanges();
                //enviarCorreo(id);
            }
            return(RedirectToAction("Index"));
        }
Exemple #11
0
        public static List <Perito> getAllPeritos()
        {
            List <Perito> peritos    = new List <Perito>();
            SqlConnection connection = null;

            try
            {
                connection = ConexionBD.getConnection();
                if (connection != null)
                {
                    SqlCommand    command;
                    SqlDataReader dataReader;
                    String        query = "SELECT * FROM Perito WHERE estado = 'Activo'";
                    command    = new SqlCommand(query, connection);
                    dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        Perito perito = new Perito();
                        perito.IdPerito = (!dataReader.IsDBNull(0)) ? dataReader.GetInt32(0) : 0;
                        perito.Nombre   = (!dataReader.IsDBNull(1)) ? dataReader.GetString(1) : "";
                        perito.Correo   = (!dataReader.IsDBNull(2)) ? dataReader.GetString(2) : "";
                        perito.Estado   = (!dataReader.IsDBNull(3)) ? dataReader.GetString(2) : "";
                        peritos.Add(perito);
                    }
                    dataReader.Close();
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
            return(peritos);
        }
 public String Registro(String nombre, String cargo, String usuario
                        , String contrasenia)
 {
     if (ValidarExistencia(usuario) == 0)
     {
         using (TransitoContext dbSS =
                    new TransitoContext())
         {
             Perito perito = new Perito();
             perito.Usuario     = usuario;
             perito.Nombre      = nombre;
             perito.Contrasenia = contrasenia;
             perito.Cargo       = cargo;
             dbSS.Perito.Add(perito);
             dbSS.SaveChanges();
             return("{\"correcto\": \"si\"}");
         }
     }
     else
     {
         return("{\"correcto\": \"no\"}");
     }
 }
        public IActionResult Principal()
        {
            byte[] arr = new byte[100];
            if (HttpContext.Session.TryGetValue("SesionPerito", out arr))
            {
                int idSesion = BitConverter.ToInt32(arr, 0);
                HttpContext.Session.TryGetValue("Perito", out arr);
                String nombre = Encoding.ASCII.GetString(arr);

                using (TransitoContext dbSS = new TransitoContext())
                {
                    BitacoraPerito registro =
                        dbSS.BitacoraPerito
                        .FirstOrDefault(b => b.IdBitacora == idSesion);
                    if (registro != null && registro.Activa == true)
                    {
                        Perito perito = dbSS.Perito
                                        .FirstOrDefault(a => a.IdPerito == registro.IdPerito);
                        ViewBag.idSesion = idSesion;
                        ViewBag.Perito   = perito;

                        //TcpClient cliente = usuarioChat(perito.Usuario);
                        ViewBag.mensajes = mensajes;
                        //ViewBag.Cliente = cliente;
                        return(View("Principal"));
                    }
                    else
                    {
                        return(new RedirectResult("/"));
                    }
                }
            }
            else
            {
                return(new RedirectResult("/"));
            }
        }
Exemple #14
0
        public static Perito getPeritoById(int idPerito)
        {
            Perito        perito     = new Perito();
            SqlConnection connection = null;

            try
            {
                connection = ConexionBD.getConnection();
                if (connection != null)
                {
                    SqlCommand    command;
                    SqlDataReader dataReader;
                    String        query = String.Format("SELECT * FROM Perito WHERE idPerito = {0}", idPerito);
                    command    = new SqlCommand(query, connection);
                    dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        perito.IdPerito = (!dataReader.IsDBNull(0)) ? dataReader.GetInt32(0) : 0;
                        perito.Nombre   = (!dataReader.IsDBNull(1)) ? dataReader.GetString(1) : "";
                        perito.Correo   = (!dataReader.IsDBNull(2)) ? dataReader.GetString(2) : "";
                        perito.Estado   = (!dataReader.IsDBNull(3)) ? dataReader.GetString(2) : "";
                    }
                    dataReader.Close();
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
            finally
            {
                connection.Close();
            }
            return(perito);
        }
        public IActionResult Validar(String usuario, String password)
        {
            Perito perito = ValidarUsuario(usuario, password);
            bool   valido = perito != null;

            if (valido)
            {
                using (TransitoContext dbSS = new TransitoContext())
                {
                    String token = "";
                    do
                    {
                        token = GenerarToken();
                    } while (dbSS.BitacoraPerito.Any(a => a.Token.Equals(token)));

                    BitacoraPerito registroAcceso = new BitacoraPerito();
                    registroAcceso.Fecha    = DateTime.Now;
                    registroAcceso.IdPerito = perito.IdPerito;
                    registroAcceso.Token    = token;
                    registroAcceso.Activa   = true;
                    dbSS.BitacoraPerito.Add(registroAcceso);
                    dbSS.SaveChanges();

                    byte[] arr = BitConverter.GetBytes(registroAcceso.IdPerito);
                    HttpContext.Session.Set("SesionPerito", arr);
                    HttpContext.Session.Set("Perito",
                                            Encoding.ASCII
                                            .GetBytes($"{perito.Nombre}"));
                    return(new RedirectResult("/Perito/Principal"));
                }
            }
            else
            {
                return(new RedirectResult("/"));
            }
        }
Exemple #16
0
        private void button_Registrar_Click(object sender, RoutedEventArgs e)
        {
            if (validarCampos())
            {
                if (pb_password.Password == pb_confirmarPassword.Password)
                {
                    Usuario usuario = new Usuario();
                    usuario.Username   = tb_username.Text;
                    usuario.Contraseña = pb_password.Password;
                    usuario.Cargo      = cb_cargo.SelectedItem.ToString();
                    Delegacion delegacion = (Delegacion)cb_delegacion.SelectedItem;
                    usuario.IdDelegacion = delegacion.IdDelegacion;
                    usuario.Correo       = tb_correo.Text;
                    usuario.Estado       = "Activo";
                    UsuarioDAO.addUsuario(usuario);
                    switch (usuario.Cargo)
                    {
                    case "Administrativo":
                        Administrativo administrativo = new Administrativo();
                        administrativo.Nombre = tb_username.Text;
                        administrativo.Correo = tb_correo.Text;
                        administrativo.Estado = "Activo";
                        AdministrativoDAO.addAdministrativo(administrativo);
                        break;

                    case "Soporte":
                        Soporte soporte = new Soporte();
                        soporte.Nombre = tb_username.Text;
                        soporte.Correo = tb_correo.Text;
                        soporte.Estado = "Activo";
                        SoporteDAO.addSoporte(soporte);
                        break;

                    case "Agente de Tránsito":
                        AgenteDeTransito agenteDeTransito = new AgenteDeTransito();
                        agenteDeTransito.Nombre = tb_username.Text;
                        agenteDeTransito.Correo = tb_correo.Text;
                        agenteDeTransito.Estado = "Activo";
                        AgenteDeTransitoDAO.addAgenteDeTransito(agenteDeTransito);
                        break;

                    case "Perito":
                        Perito perito = new Perito();
                        perito.Nombre = tb_username.Text;
                        perito.Correo = tb_correo.Text;
                        perito.Estado = "Activo";
                        PeritoDAO.addPerito(perito);
                        break;
                    }
                    MessageBox.Show("Se ha registrado al usuario de manera exitosa.");
                    vaciarCampos();
                }
                else
                {
                    MessageBox.Show("Las contraseñas deben coincidir");
                }
            }
            else
            {
                MessageBox.Show("Asegúrese de llenar todos los campos.");
            }
        }