Example #1
0
        public string DL_Insertar_RequisitoPlan(int nOrdenIntervencionId, string cRequisitoDesc, int nCantidad)
        {
            string res = "";

            try
            {
                cmd.Connection  = NewConnection(strCon);
                cmd.CommandText = "GHS.USP_MNT_Plan_Intervencion";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                pAddParameter(cmd, "@nOrdenIntervencionId", nOrdenIntervencionId, SqlDbType.Int);
                pAddParameter(cmd, "@cRequisitoDesc", cRequisitoDesc, SqlDbType.VarChar);
                pAddParameter(cmd, "@nCantidad", nCantidad, SqlDbType.Int);

                res = fEjecutar(cmd);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(res);
        }
Example #2
0
        public string DL_registrarOrden(int habreposo, int nOrdenMedId)
        {
            string res = "";

            try
            {
                cmd.Connection  = NewConnection(strCon);
                cmd.CommandText = "GHS.USP_Insertar_Orden_Intervencion";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                pAddParameter(cmd, "@nOrdenMedId", nOrdenMedId, SqlDbType.Int);
                pAddParameter(cmd, "@nAmbienteId", habreposo, SqlDbType.Int);

                res = fEjecutar(cmd);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(res);
        }
Example #3
0
        public bool EsAdmin(int usuario_id)
        {
            var EsAdmin = false;

            using (var context = new RedSocialContext())
            {
                try
                {
                    var u = context.Usuario
                            .Where(x => x.id == usuario_id && x.Admin == 1)
                            .FirstOrDefault();

                    if (u != null)
                    {
                        EsAdmin = true;
                    }
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(EsAdmin);
        }
Example #4
0
        private void frmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!IsDesactivado)
            {
                string respuesta = Prompt.ShowDialog(text: "Indique Contraseña", caption: "Contraseña");

                if (respuesta == Pass)
                {
                    ELog.SaveString(titulo: "SpyScr Cerrado", mensaje: "Aplicación Cerrada");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Contaseña Incorrecta", "Contraseña Incorrecta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    ELog.SaveString(titulo: "Contaseña Incorrecta", mensaje: "Contaseña Incorrecta");
                    e.Cancel = true;
                }
            }
            else
            {
                try
                {
                    ELog.SaveString(titulo: "SpyScr Cerrado", mensaje: "Aplicación Cerrada");
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    ELog.Save(this, ex);
                }
            }
        }
Example #5
0
        public ResponseModel Acceder(Usuario usuario)
        {
            using (var context = new RedSocialContext())
            {
                try
                {
                    // Encriptamos la contraseña para comparar
                    usuario.Contrasena = HashHelper.MD5(usuario.Contrasena);

                    var _usuario = context.Usuario
                                   .Where(x =>
                                          x.Contrasena == usuario.Contrasena &&
                                          x.Correo == usuario.Correo
                                          ).SingleOrDefault();

                    if (_usuario != null)
                    {
                        SessionHelper.AddUserToSession(_usuario.id.ToString());

                        rm.SetResponse(true);
                        rm.href = "inicio";
                    }
                    else
                    {
                        rm.SetResponse(false, "El usuario ingresado no existe");
                    }
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(rm);
        }
Example #6
0
        /// <summary>
        /// Este método es usado para registrar la información básica del usuario, autentificar y redireccionar al home de nuestro aplicativo.
        /// </summary>
        /// <param name="usuario"></param>
        /// <returns></returns>
        public ResponseModel RegistroDeLogin(Usuario usuario)
        {
            using (var context = new RedSocialContext())
            {
                try
                {
                    // Guardamos la clave en formato MD5
                    usuario.Contrasena = HashHelper.MD5(usuario.Contrasena);

                    // Ignoramos la validacion para que la contraseña pase
                    context.Configuration.ValidateOnSaveEnabled = false;

                    context.Usuario.Add(usuario);
                    context.SaveChanges();

                    context.Database.ExecuteSqlCommand("UPDATE Usuario SET Url = @url WHERE id = @id",
                                                       new SqlParameter("url", ViewHelper.ConvertNameToUrl(usuario.Nombre, usuario.Apellido, usuario.id.ToString())),
                                                       new SqlParameter("id", usuario.id));

                    // Guardamos en session al usuario actual, solo necesitamos guardar su ID
                    SessionHelper.AddUserToSession(usuario.id.ToString());

                    rm.SetResponse(true);
                    rm.href = "inicio";
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(rm);
        }
Example #7
0
        public string DL_Insertar_SOAP(int nHistoriaClinica, string cSubjetivo, string cApreciacion)
        {
            string res = "";

            try
            {
                cmd.Connection  = NewConnection(strCon);
                cmd.CommandText = "GHS.USP_Insertar_SOAP";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                pAddParameter(cmd, "@nHistoriaClinica", nHistoriaClinica, SqlDbType.Int);
                pAddParameter(cmd, "@cSubjetivo", cSubjetivo, SqlDbType.VarChar);
                pAddParameter(cmd, "@cApreciacion", cApreciacion, SqlDbType.VarChar);

                res = fEjecutar(cmd);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(res);
        }
Example #8
0
        public ELUsuario ObtenerUsuarioLogeado(int id)
        {
            var usuario = new ELUsuario();

            try
            {
                using (var conn = new SqlConnection(strCon))
                {
                    conn.Open();

                    var query = new SqlCommand("select * from usuario where id = @id", conn);
                    query.Parameters.AddWithValue("@id", id);

                    using (var dr = query.ExecuteReader())
                    {
                        dr.Read();
                        if (dr.HasRows)
                        {
                            usuario.Nombre         = dr["Nombre"].ToString();
                            usuario.Apellido       = dr["Apellido"].ToString();
                            usuario.NombreCompleto = usuario.Nombre + " " + usuario.Apellido;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(usuario);
        }
Example #9
0
        public ResponseModel Acceder(ELUsuario usuario)
        {
            try
            {
                // Encriptamos la contraseña para comparar
                usuario.Password = HashHelper.MD5(usuario.Password);

                var _usuario = dl.DL_Autenticar(usuario);

                if (_usuario != null)
                {
                    SessionHelper.AddUserToSession(_usuario.Id.ToString());

                    rm.SetResponse(true);
                    rm.href = "inicio";
                }
                else
                {
                    rm.SetResponse(false, "El usuario ingresado no existe");
                }
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(rm);
        }
Example #10
0
        /* P R O C E S O S */

        private void InicializandoAplicacion()
        {
            try
            {
                this.Icon             = SpyScr.Properties.Resources.settings;
                this.IcoNotifica.Icon = SpyScr.Properties.Resources.settings;
                IsActivo                 = true;
                IsDesactivado            = false;
                BtnEstatus.MouseHover   += new EventHandler(BtnEstatus_MouseHover);
                BtnEstatus.MouseLeave   += new EventHandler(BtnEstatus_MouseLeave);
                BtnMinimizar.MouseHover += new EventHandler(BtnMinimizar_MouseHover);
                BtnMinimizar.MouseLeave += new EventHandler(BtnMinimizar_MouseLeave);
                BtnCerrar.MouseHover    += new EventHandler(BtnCerrar_MouseHover);
                BtnCerrar.MouseLeave    += new EventHandler(BtnCerrar_MouseLeave);
                this.FormClosing        += new FormClosingEventHandler(frmPrincipal_FormClosing);
                Pass = ConfigurationManager.AppSettings["Pass"].ToString();
                string Intervalo = ConfigurationManager.AppSettings["Intervalo"].ToString();
                Tiempo.Interval = int.Parse(Intervalo);
                Tiempo.Enabled  = true;
                Tiempo.Start();
                this.IcoNotifica.Text = "Proceso Activo";
            }
            catch (Exception ex)
            {
                ELog.Save(this, ex);
            }
        }
Example #11
0
        public List <Publicacion> Listar(int usuario_id = 0)
        {
            List <Publicacion> publicaciones = new List <Publicacion>();

            using (var context = new RedSocialContext())
            {
                try
                {
                    // Traemos las ultimoas 20 publicaciones
                    if (usuario_id == 0) // Si queremos traer todas las publicaciones
                    {
                        publicaciones = context.Publicacion
                                        .OrderByDescending(x => x.FechaRegistro)
                                        .Take(30).ToList();        //Take equivale a SELECT TOP 30
                    }
                    else // Si queremos traer las publicaciones de u nusuario especifico
                    {
                        publicaciones = context.Publicacion
                                        .OrderByDescending(x => x.FechaRegistro)
                                        .Where(x => x.Para == usuario_id)
                                        .Take(30).ToList();        //Take equivale a SELECT TOP 30
                    }

                    foreach (var p in publicaciones)
                    {
                        // Obtenemos el emisor y su foto
                        p.Emisor = context.Usuario
                                   .Where(x => x.id == p.De).SingleOrDefault();

                        p.Emisor.Foto = context.Foto
                                        .Where(x => x.Relacion == "U" + p.De).SingleOrDefault();


                        if (p.Emisor.Foto == null)
                        {
                            p.Emisor.Foto = new Foto();                        // Si no tiene foto agregamos una por defecto
                        }
                        // Obtenemos el receptor y su foto
                        p.Receptor = context.Usuario
                                     .Where(x => x.id == p.Para).SingleOrDefault();

                        p.Receptor.Foto = context.Foto
                                          .Where(x => x.Relacion == "U" + p.Para).SingleOrDefault();

                        if (p.Receptor.Foto == null)
                        {
                            p.Receptor.Foto = new Foto();                          // Si no tiene foto agregamos una por defecto
                        }
                    }
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(publicaciones);
        }
Example #12
0
        public ELPaciente DL_BuscarPaciente(string dni, string hc)
        {
            ELPaciente objPaciente = null;

            try
            {
                using (SqlConnection conn = new SqlConnection(strCon))
                {
                    conn.Open();

                    cmd.Connection  = conn;
                    cmd.CommandText = "GHS.USP_Consultar_Paciente";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();

                    cmd.Parameters.AddWithValue("@cNroDocumento", dni == "" ? "" : dni);
                    cmd.Parameters.AddWithValue("@cNroHistoriaClinica", hc == "" ? "" : hc);

                    SqlDataReader drSQL = fLeer(cmd);
                    if (drSQL.HasRows == false)
                    {
                        objPaciente = new ELPaciente();
                    }
                    else
                    {
                        while (drSQL.Read())
                        {
                            objPaciente                     = new ELPaciente();
                            objPaciente.nPacienteId         = drSQL["nPacienteId"].Equals(System.DBNull.Value) ? 0 : Convert.ToInt32(drSQL["nPacienteId"]);
                            objPaciente.cNomCompleto        = drSQL["cNomCompleto"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cNomCompleto"]);
                            objPaciente.cApePaterno         = drSQL["cApePaterno"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cApePaterno"]);
                            objPaciente.cApeMaterno         = drSQL["cApeMaterno"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cApeMaterno"]);
                            objPaciente.cNroHistoriaClinica = drSQL["cNroHistoriaClinica"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cNroHistoriaClinica"]);
                            objPaciente.cFechaNacimiento    = drSQL["cFechaNacimiento"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cFechaNacimiento"]);
                            objPaciente.cNombres            = drSQL["cNombres"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cNombres"]);
                            objPaciente.nEdad               = drSQL["nEdad"].Equals(System.DBNull.Value) ? 0 : Convert.ToInt32(drSQL["nEdad"]);
                            objPaciente.cSexo               = drSQL["cSexo"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cSexo"]);
                            objPaciente.cMaestroDescripcion = drSQL["cMaestroDescripcion"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cMaestroDescripcion"]);
                            objPaciente.cNroDocumento       = drSQL["cNroDocumento"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cNroDocumento"]);
                            objPaciente.cAlergias           = drSQL["cAlergias"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["cAlergias"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(objPaciente);
        }
Example #13
0
 private void Tiempo_Tick(object sender, EventArgs e)
 {
     try
     {
         CapturaPantalla();
     }
     catch (Exception ex)
     {
         ELog.Save(this, ex);
     }
 }
Example #14
0
        public string BL_registrarOrden(int habreposo, int nOrdenMedId)
        {
            //ELPaciente paciente = new ELPaciente();
            try
            {
                dlOrden.DL_registrarOrden(habreposo, nOrdenMedId);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return("Registro Exitoso");
        }
Example #15
0
        public string BL_Insertar_SOAP(int nHistoriaClinica, string cSubjetivo, string cApreciacion)
        {
            //ELPaciente paciente = new ELPaciente();
            try
            {
                dlOrden.DL_Insertar_SOAP(nHistoriaClinica, cSubjetivo, cApreciacion);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return("Registro Exitoso");
        }
Example #16
0
        public List <ELOrdenIntervencion> BL_ConsultarOI(string documento, int estado)
        {
            List <ELOrdenIntervencion> ordenIntervencion = new List <ELOrdenIntervencion>();

            try
            {
                ordenIntervencion = dlOrden.DL_ConsultarOI(documento, estado);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(ordenIntervencion);
        }
Example #17
0
        public List <ELTipoIntervencion> BL_ConsultarTipoIntervencion()
        {
            List <ELTipoIntervencion> lstTipoIntervencion = new List <ELTipoIntervencion>();

            try
            {
                lstTipoIntervencion = dlTipoIntervencion.DL_ConsultarTipoInternvencion();
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(lstTipoIntervencion);
        }
Example #18
0
        public List <ELAmbiente> BL_ConsultarAmbiente(int nTipoAmbienteId, int nAmbienteId)
        {
            List <ELAmbiente> lstAmbiente = new List <ELAmbiente>();

            try
            {
                lstAmbiente = dlAmbiente.DL_ConsultarAmbiente(nTipoAmbienteId, nAmbienteId);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(lstAmbiente);
        }
Example #19
0
        public List <ELMaestro> BL_ConsultarMaestro(int nTablaId)
        {
            List <ELMaestro> maestro = new List <ELMaestro>();

            try
            {
                maestro = dlOrden.DL_ConsultarMaestro(nTablaId);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(maestro);
        }
Example #20
0
        public List <ELOrdenMedica> BL_ConsultarOM(string dni)
        {
            List <ELOrdenMedica> ordenIntervencion = new List <ELOrdenMedica>();

            try
            {
                ordenIntervencion = dlOrden.DL_ConsultarOM(dni);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(ordenIntervencion);
        }
Example #21
0
        public List <ELPlanIntervencion> BL_ConsultarPlan(DateTime dtFecha, int nTipoInt)
        {
            List <ELPlanIntervencion> lstPlanIntervencion = new List <ELPlanIntervencion>();

            try
            {
                lstPlanIntervencion = dlPlanInt.DL_ConsultarPlan(dtFecha, nTipoInt);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(lstPlanIntervencion);
        }
Example #22
0
        public List <ELPriorizarAtencion> BL_ConsultarActividades(int nOrdenId)
        {
            List <ELPriorizarAtencion> lstPriorizados = new List <ELPriorizarAtencion>();

            try
            {
                lstPriorizados = dlPriori.DL_ConsultarActividades(nOrdenId);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(lstPriorizados);
        }
Example #23
0
        public List <ELPriorizarAtencion> BL_ConsultarPriorizados()
        {
            List <ELPriorizarAtencion> lstPriorizados = new List <ELPriorizarAtencion>();

            try
            {
                lstPriorizados = dlPriori.DL_ConsultarPriorizados();
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(lstPriorizados);
        }
Example #24
0
        public ELPaciente BL_BuscarPaciente(string dni, string hc)
        {
            ELPaciente paciente = new ELPaciente();

            try
            {
                paciente = dlOrden.DL_BuscarPaciente(dni, hc);
                paciente.lstOrdenMedica = dlOrden.DL_ConsultarOM(dni);
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(paciente);
        }
Example #25
0
        public Usuario Obtener(int id)
        {
            Usuario usuario = new Usuario();

            using (var context = new RedSocialContext())
            {
                try
                {
                    usuario = context.Usuario
                              .Where(x => x.id == id).Single();

                    // Damos formato a la fecha en yyyy/mm/dd
                    usuario.FechaNacimiento = ViewHelper.ConvertToDate(usuario.FechaNacimiento);

                    // Ahora obtenemos su foto
                    usuario.Foto = context.Foto.Where(
                        x => x.Relacion == FotoRelacion + usuario.id).SingleOrDefault();

                    // Si la foto no existe le ponemos una por defecto
                    if (usuario.Foto == null)
                    {
                        usuario.Foto = new Foto();
                    }

                    /* Ahora obtenemos los conocimientos de nuestro usuario, pero vamos a traerlos de la tabla conocimiento
                     * para esto haremos un LINQ INNER JOIN */
                    usuario.UsuarioConocimientos = (from c in context.Conocimientos.ToList()
                                                    join cu in context.UsuarioConocimiento.ToList()
                                                    on c.id equals cu.Conocimiento_id
                                                    where cu.Usuario_id == usuario.id
                                                    orderby c.Nombre select cu).ToList();

                    /* Como en nuestra entidad UsuarioConocimiento le hemos indicado que son llaves foraneas, el entity framework
                     * ha llegando los objetos Usuario y Conocimiento de esta clase automaticamente */
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(usuario);
        }
Example #26
0
        public int Total()
        {
            int t = 0;

            using (var context = new RedSocialContext())
            {
                try
                {
                    t = context.Usuario
                        .OrderBy(x => x.Nombre)
                        .Count();
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }
            return(t);
        }
Example #27
0
        public ELUsuario DL_Autenticar(ELUsuario elObj)
        {
            ELUsuario objUsuario = null;

            try
            {
                using (SqlConnection conn = new SqlConnection(strCon))
                {
                    conn.Open();

                    cmd.Connection  = conn;
                    cmd.CommandText = "USP_Autenticar";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();

                    cmd.Parameters.AddWithValue("@Login", elObj.Login == "" ? "" : elObj.Login);
                    cmd.Parameters.AddWithValue("@Password", elObj.Password == "" ? "" : elObj.Password);

                    SqlDataReader drSQL = fLeer(cmd);

                    while (drSQL.Read())
                    {
                        objUsuario                = new ELUsuario();
                        objUsuario.Id             = drSQL["id"].Equals(System.DBNull.Value) ? 0 : Convert.ToInt32(drSQL["id"]);
                        objUsuario.NombreCompleto = drSQL["NombreCompleto"].Equals(System.DBNull.Value) ? "" : Convert.ToString(drSQL["NombreCompleto"]);
                    }
                }
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(objUsuario);
        }
Example #28
0
        public List <ReportePublicacionesPorUsuario> ReportePublicacionesPorUsuario()
        {
            var reporte = new List <ReportePublicacionesPorUsuario>();

            using (var ctx = new RedSocialContext())
            {
                try
                {
                    reporte = ctx.Database
                              .SqlQuery <ReportePublicacionesPorUsuario>("[USP_ReportePublicacionesPorUsuario]")
                              .ToList();
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(reporte);
        }
Example #29
0
        public ResponseModel Eliminar(int id)
        {
            using (var context = new RedSocialContext())
            {
                try
                {
                    context.Entry(new Usuario {
                        id = id
                    }).State = EntityState.Deleted;
                    context.SaveChanges();

                    rm.SetResponse(true);
                }
                catch (Exception e)
                {
                    ELog.Save(this, e);
                }
            }

            return(rm);
        }
Example #30
0
        public List <Conocimiento> Listar()
        {
            List <Conocimiento> conocimientos = new List <Conocimiento>();

            try
            {
                using (var context = new RedSocialContext())
                {
                    // Otra forma de hacer Query, usando Linq
                    conocimientos = (from c in context.Conocimientos
                                     orderby c.Nombre
                                     select c).ToList();
                }
            }
            catch (Exception e)
            {
                ELog.Save(this, e);
            }

            return(conocimientos);
        }