Exemple #1
0
        /*  public void agregarRol(Afiliado afiliado)
         * {
         *    //calling a hash set's Add(item) method returns a Boolean value: true if the item was added,
         *    //and false otherwise (because it was already found in the set).
         *
         *    if(!this.roles.Add(afiliado)) throw new OverflowException("Ya existe el rol especificado en este usuario");
         *
         *    // Necesitamos los planes sepan quienes son sus afiliados asi que los notificaremos
         *    afiliado.notificarPlan(this);
         * }*/


        public Boolean existeUsuario()
        {
            SqlCommand sqlCommand = getSqlCommandQueryByUsername();

            try
            {
                SqlDataReader reader = sqlCommand.ExecuteReader();


                if (reader.HasRows)
                {
                    reader.Close();
                    return(true);
                }
                else
                {
                    reader.Close();
                    return(false);
                }
            }
            catch (SqlException e)
            {
                Interfaz.Interfaz.mostrarMensaje("Error al hacer consulta existeUsuario()" + e.Message);
            }

            ManejadorConexiones.desconectar();
            return(false);
        }
Exemple #2
0
        public int getId()
        {
            string     sqlQuery   = "SELECT Id_usuario FROM TRIGGER_EXPLOSION.Usuario WHERE Username = @user";
            SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());

            sqlCommand.Parameters.Add("@user", SqlDbType.VarChar).Value = this.Username;

            using (var reader = sqlCommand.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Int32 id = Convert.ToInt32(reader["Id_usuario"]);
                    sqlCommand.Dispose();
                    ManejadorConexiones.desconectar();
                    this.Id_usuario = id;
                    return(id);
                }
                else
                {
                    sqlCommand.Dispose();
                    ManejadorConexiones.desconectar();
                    return(0);
                }
            }
        }
Exemple #3
0
        public Boolean estaHabilitado()
        {
            try
            {
                string     sqlQuery   = "SELECT Habilitado FROM TRIGGER_EXPLOSION.Usuario WHERE Username = @user";
                SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());
                sqlCommand.Parameters.Add("@user", SqlDbType.VarChar).Value = this.Username;
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        Int32 habilitado = Convert.ToInt32(reader["Habilitado"]);
                        ManejadorConexiones.desconectar();
                        return(habilitado == 1);
                    }
                    else
                    {
                        ManejadorConexiones.desconectar();
                        return(false);
                    }
                }
            }
            catch (SqlException e)
            {
                Interfaz.Interfaz.mostrarMensaje("Se produjo un error al consultar usuario habilitado: " + e.Message);
            }

            ManejadorConexiones.desconectar();
            return(false);
        }
        /* public void compraBono(int cantidad) {
         *
         *   this.bonos = plan.venderBonos(cantidad);
         *
         *   // Lo siguiente se hace ya que segun el enunciado cada bono debe tener cierta info del
         *   // afiliado que lo utilizo, como el total_consultas
         *
         *   this.bonos.ForEach(b => b.setAfiliado(this));
         * }
         *
         * public void notificarPlan(Usuario usuarioNuevo)
         * {
         *   this.plan.agregarAfiliado(usuarioNuevo);
         * }
         *
         * public Boolean esAfiliado()
         * {
         *   return true;
         * }*/

        public void ActualizarGrid(DataGridView dg, String Query)
        {
            //conectarnos a la base de datos...

            this.miConector = ManejadorConexiones.conectar();

            //crear DataSet

            System.Data.DataSet MiDataSet = new System.Data.DataSet();

            //Crear Adaptador de datos
            SqlDataAdapter MiDataAdapter = new SqlDataAdapter(Query, miConector);


            //LLenar el DataSet
            MiDataAdapter.Fill(MiDataSet, "afiliado");

            //Asignarle el valor adecuado a las propiedades del DataGrid

            dg.DataSource = MiDataSet;
            dg.DataMember = "afiliado";

            //nos desconectamos de la base de datos...

            ManejadorConexiones.desconectar();
        }
Exemple #5
0
        public Boolean horarioEstaDentroDeLosLaborablesDelProfesional(DayOfWeek dia, DateTime fecha, String especialidad, int idAgenda)
        {
            if (dia == DayOfWeek.Sunday)
            {
                return(false);
            }

            String nombreDia = "";

            switch (dia)
            {
            case DayOfWeek.Friday: { nombreDia = "Viernes"; break; }

            case DayOfWeek.Monday: { nombreDia = "Lunes"; break; }

            case DayOfWeek.Saturday: { nombreDia = "Sábado"; break; }

            case DayOfWeek.Thursday: { nombreDia = "Jueves"; break; }

            case DayOfWeek.Tuesday: { nombreDia = "Martes"; break; }

            case DayOfWeek.Wednesday: { nombreDia = "Miércoles"; break; }
            }

            String     query = "select hora_inicio, hora_fin from TRIGGER_EXPLOSION.getHorarioDisponibleDelDia(@NombreEspecialidad,@NombreDia,@IdProfesional, @IdAgenda)";
            SqlCommand cmd   = new SqlCommand(query, ManejadorConexiones.conectar());


            cmd.Parameters.Add("@NombreEspecialidad", SqlDbType.VarChar).Value = especialidad;
            cmd.Parameters.Add("@NombreDia", SqlDbType.VarChar).Value          = nombreDia;
            cmd.Parameters.Add("@IdProfesional", SqlDbType.Int).Value          = this.id;
            cmd.Parameters.Add("@IdAgenda", SqlDbType.Int).Value = idAgenda;


            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    TimeSpan horaInicio = (TimeSpan)(reader["hora_inicio"]);
                    TimeSpan horaFin    = (TimeSpan)(reader["hora_fin"]);
                    cmd.Dispose();
                    ManejadorConexiones.desconectar();

                    if (fecha.Hour == horaFin.Hours && fecha.Minute == horaFin.Minutes)
                    {
                        return(false);
                    }
                    else
                    {
                        return(TimeBetween(fecha, horaInicio, horaFin));
                    }
                }
                else
                {
                    cmd.Dispose();
                    ManejadorConexiones.desconectar();
                    return(false);
                }
            }
        }
Exemple #6
0
        //devuelve un SqlCommand con la consulta del usuario por Username, recordar desconectar
        private SqlCommand getSqlCommandQueryByUsername()
        {
            string     sqlQuery   = "SELECT Username FROM TRIGGER_EXPLOSION.Usuario WHERE Username = @user";
            SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());

            sqlCommand.Parameters.Add("@user", SqlDbType.VarChar).Value = this.Username;
            return(sqlCommand);
        }
Exemple #7
0
        public void resetearIntentos()
        {
            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {
                using (SqlCommand cmd = new SqlCommand("TRIGGER_EXPLOSION.SP_ResetIntentos", sqlConnection)){
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Id_usuario", SqlDbType.VarChar).Value = this.Id_usuario;

                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemple #8
0
        public Boolean getPrimerLogin()
        {
            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {
                string     sqlQuery   = "SELECT Primer_login FROM TRIGGER_EXPLOSION.Usuario WHERE Id_usuario = @ID";
                SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());
                sqlCommand.Parameters.Add("@ID", SqlDbType.Int).Value = this.Id_usuario;

                using (var reader = sqlCommand.ExecuteReader())
                {
                    reader.Read();
                    this.primerLogin = Convert.ToInt32(reader["Primer_login"]) == 1;
                    return(this.primerLogin);
                }
            }
        }
Exemple #9
0
        public DateTime getFechaInicio(String especialidad)
        {
            DateTime   date  = new DateTime();
            String     query = "SELECT Fecha_inicio FROM TRIGGER_EXPLOSION.Agenda where Id_profesional = @id and Especialidad = @especialidad";
            SqlCommand cmd   = new SqlCommand(query, ManejadorConexiones.conectar());

            cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;
            cmd.Parameters.Add("@especialidad", especialidad);

            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    date = Convert.ToDateTime(reader["Fecha_inicio"]);
                }
                cmd.Dispose();
                ManejadorConexiones.desconectar();
            }
            return(date);
        }
Exemple #10
0
        //Devuelve todos los ID de agenda para los cuales el profesional tiene una agenda registrada en esa especialidad
        public List <Int64> getIdDeAgendasDelProfesional(String especialidad)
        {
            List <Int64> lista = new List <Int64>();
            String       query = "select Id FROM TRIGGER_EXPLOSION.getIdDeAgendasPorEspecialidad(@profesional,@especialidad,@fecha)";
            SqlCommand   cmd   = new SqlCommand(query, ManejadorConexiones.conectar());

            cmd.Parameters.Add("@profesional", SqlDbType.Int).Value      = this.id;
            cmd.Parameters.Add("@especialidad", SqlDbType.VarChar).Value = especialidad;
            cmd.Parameters.Add("@fecha", SqlDbType.Date).Value           = ConfigurationManager.AppSettings["fechaSistema"];

            using (SqlDataReader reader = cmd.ExecuteReader()){
                while (reader.Read())
                {
                    lista.Add(Convert.ToInt64(reader["Id"]));
                }
                cmd.Dispose();
                ManejadorConexiones.desconectar();
            }
            return(lista);
        }
Exemple #11
0
        public Boolean checkPassword()
        {
            if (this.Id_usuario == 0)
            {
                getId();
            }



            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {
                string     sqlQuery   = "SELECT 1 FROM TRIGGER_EXPLOSION.Usuario WHERE Id_usuario = @ID AND Contrasenia = @Pass";
                SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());
                sqlCommand.Parameters.Add("@ID", SqlDbType.Int).Value       = this.Id_usuario;
                sqlCommand.Parameters.Add("@Pass", SqlDbType.VarChar).Value = this.Password;

                using (var reader = sqlCommand.ExecuteReader())
                {
                    reader.Read();
                    return(reader.HasRows);
                }
            }
        }
Exemple #12
0
        //La idea es obtener una lista de todas las fechas en las que el profesional tiene un turno asignado
        //No deberia importarme de que especialidad es ese turno ya que sea de cual sea esa fecha no estara disponible
        //no me interesan las fechas que ya vencieron, paso por parametro la fecha del sistema
        public List <DateTime> getFechasOcupado()
        {
            List <DateTime> lista = new List <DateTime>();

            String     query = "select Fecha from TRIGGER_EXPLOSION.getFechasDeTurnos(@afiliado,  @fecha)";
            SqlCommand cmd   = new SqlCommand(query, ManejadorConexiones.conectar());

            cmd.Parameters.Add("@afiliado", SqlDbType.Int).Value = this.id;
            String fechaSistema = ConfigurationManager.AppSettings["fechaSistema"];

            cmd.Parameters.Add("@fecha", fechaSistema);

            using (SqlDataReader reader = cmd.ExecuteReader()){
                while (reader.Read())
                {
                    lista.Add(Convert.ToDateTime(reader["Fecha"]));
                }

                cmd.Dispose();
                ManejadorConexiones.desconectar();
            }

            return(lista);
        }