Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.Cookies["SNID"] != null)
        {
            LogStatus.DeleteCookies();
        }

        if (LogStatus.IsLoggedIn() <= 0)
        {
            Response.Redirect("home.aspx");
        }

        randomizer = random.Next(1, 46);

        SqlConnection conn = new SqlConnection(@"Data Source=(local)\sqlexpress;Initial Catalog=friendsforever;Integrated Security=True"); //Create Connection

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT quote FROM quotes WHERE q_id = @q_id", conn))
        {
            command.CommandType = CommandType.Text;
            command.Parameters.AddWithValue("@q_id", randomizer);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                quote = reader["quote"].ToString();
            }
        }

        conn.Close();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.Cookies["SNID"] != null)
        {
            LogStatus.DeleteCookies();
        }

        if (LogStatus.IsLoggedIn() <= 0)
        {
            Response.Redirect("home.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.Cookies["SNID"] != null)
        {
            LogStatus.DeleteCookies();
        }

        if (LogStatus.IsLoggedIn() <= 0)
        {
            Response.Redirect("home.aspx");
        }

        SqlConnection conn = new SqlConnection(@"Data Source=(local)\sqlexpress;Initial Catalog=friendsforever;Integrated Security=True"); //Create Connection

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT COUNT(u_name) AS count FROM users WHERE u_id <> @user_id", conn))
        {
            command.Parameters.AddWithValue("@user_id", LogStatus.IsLoggedIn());
            command.CommandType = CommandType.Text;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                count = Convert.ToInt32(reader["count"].ToString());
            }
        }

        conn.Close();

        users = new string[count];

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT u_name FROM users WHERE u_id <> @user_id", conn))
        {
            command.Parameters.AddWithValue("@user_id", LogStatus.IsLoggedIn());
            command.CommandType = CommandType.Text;
            SqlDataReader reader = command.ExecuteReader();

            int i = 0;
            while (reader.Read())
            {
                users[i] = reader["u_name"].ToString();
                i++;
            }
        }

        conn.Close();
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.Cookies["SNID"] != null)
        {
            LogStatus.DeleteCookies();
        }

        if (LogStatus.IsLoggedIn() <= 0)
        {
            Response.Redirect("home.aspx");
        }

        SqlConnection conn = new SqlConnection(@"Data Source=(local)\sqlexpress;Initial Catalog=friendsforever;Integrated Security=True"); //Create Connection

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT f_name, l_name, u_name, email, dob, gender FROM users WHERE u_id = @user_id", conn))
        {
            command.Parameters.AddWithValue("@user_id", LogStatus.IsLoggedIn());
            command.CommandType = CommandType.Text;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                f_name = reader["f_name"].ToString();
                l_name = reader["l_name"].ToString();
                u_name = reader["u_name"].ToString();
                email  = reader["email"].ToString();
                dob    = reader["dob"].ToString();
                gender = reader["gender"].ToString();
            }
        }

        conn.Close();

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT COUNT(following) AS following FROM follow WHERE following=@user_id", conn))
        {
            command.Parameters.AddWithValue("@user_id", LogStatus.IsLoggedIn());
            command.CommandType = CommandType.Text;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                following = Convert.ToInt32(reader["following"].ToString());
            }
        }

        conn.Close();

        conn.Open();

        using (SqlCommand command = new SqlCommand("SELECT COUNT(being_followed) AS followers FROM follow WHERE being_followed=@user_id", conn))
        {
            command.Parameters.AddWithValue("@user_id", LogStatus.IsLoggedIn());
            command.CommandType = CommandType.Text;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                followers = Convert.ToInt32(reader["followers"].ToString());
            }
        }

        conn.Close();
    }