示例#1
0
    protected void btnPostReply_Click(object sender, EventArgs e)
    {
        sc.Open();
        SqlCommand login = new SqlCommand();

        login.Connection  = sc;
        login.CommandText = "SELECT PersonID from Account where Username = '******'";
        int accountID = (int)login.ExecuteScalar();

        sc.Close();


        GridViewRow row = (sender as Button).NamingContainer as GridViewRow;
        Label       lblchildCommentid = (Label)row.FindControl("lblPostId");
        TextBox     txtCommentParent  = (TextBox)row.FindControl("txtCommentReply");
        SqlCommand  cmd = new SqlCommand("Insert into Comment(CommentDescription, DateCreated, PostID, PersonID) values (@Description, @DateCreated, @PostID, @PersonID)", sc);

        cmd.Parameters.Add(new SqlParameter("@Description", txtCommentParent.Text));
        cmd.Parameters.Add(new SqlParameter("@DateCreated", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@PostID", lblchildCommentid.Text));
        cmd.Parameters.Add(new SqlParameter("@PersonID", accountID));
        // cmd.Parameters.AddWithValue("@UserName", Request.QueryString["User_name"].ToString());
        sc.Open();
        cmd.ExecuteNonQuery();
        sc.Close();

        // Binds the Comments to the Post
        int selectedSort = SortDropDown.SelectedIndex;

        GridViewPosts.DataSource = Post.getAllPostInfo(selectedSort);
        GridViewPosts.DataBind();
    }
示例#2
0
    // Binds current comments from the database to the page
    //public void bindComments()
    //{
    //    String connection = "Data Source=localhost;Initial Catalog=Cued-In;Integrated Security=True";
    //    SqlConnection sc = new SqlConnection(connection);
    //    SqlDataAdapter sqlDA = new SqlDataAdapter("Select * from Comment", sc);
    //    DataSet commentSet = new DataSet();
    //    sqlDA.Fill(commentSet);
    //    GridViewPosts.DataSource = commentSet;
    //    GridViewPosts.DataBind();

    //}

    // Allows user to publish posts and have them added to the timeline
    protected void btnPublishPost_Click(object sender, EventArgs e)
    {
        Post       newPost = new Post(txtNewPost.Text);
        SqlCommand cmd     = new SqlCommand("Insert into Post(PostDescription,DateCreated,Deadline,PersonID,OpportunityID,ModifiedDate) values(@Description,@DateCreated,@Deadline,@PersonID,@OpportunityID,@ModifiedDate)", sc);

        cmd.Parameters.Add(new SqlParameter("@Description", newPost.getPostDesc()));
        cmd.Parameters.Add(new SqlParameter("@DateCreated", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@Deadline", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@PersonID", 14));
        cmd.Parameters.Add(new SqlParameter("@OpportunityID", 1));
        cmd.Parameters.Add(new SqlParameter("@ModifiedDate", DateTime.Now));
        sc.Open();
        cmd.ExecuteNonQuery();
        sc.Close();
        GridViewPosts.DataSource = Post.getAllPostInfo();
        GridViewPosts.DataBind();
        txtNewPost.Text = "";
    }
示例#3
0
    // Allows user to publish posts and have them added to the timeline
    protected void btnPublishPost_Click(object sender, EventArgs e)
    {
        Post newPost = new Post(txtNewPost.Text);

        sc.Open();
        System.Data.SqlClient.SqlCommand getdbPersonID = new System.Data.SqlClient.SqlCommand();
        getdbPersonID.Connection = sc;
        //Gets the personid for the username
        getdbPersonID.CommandText = "SELECT PersonID from Account where Username = '******'";
        int accountID = (int)getdbPersonID.ExecuteScalar();

        sc.Close();

        //Display current name
        sc.Open();
        SqlCommand getEmpID = new SqlCommand();

        getEmpID.Connection  = sc;
        getEmpID.CommandText = "Select EmployerID from Person where PersonID = " + accountID;
        Int32 EmpID = Convert.ToInt32(getEmpID.ExecuteScalar());

        sc.Close();

        sc.Open();
        SqlCommand cmd = new SqlCommand("Insert into Post(PostDescription, DateCreated, Deadline, PersonID, EmployerID, OpportunityID,ModifiedDate) values(@Description,@DateCreated,@Deadline,@PersonID, @EmployerID, @OpportunityID,@ModifiedDate)", sc);

        cmd.Parameters.Add(new SqlParameter("@Description", newPost.getPostDesc()));
        cmd.Parameters.Add(new SqlParameter("@DateCreated", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@Deadline", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@PersonID", accountID));
        cmd.Parameters.Add(new SqlParameter("@EmployerID", EmpID));
        cmd.Parameters.Add(new SqlParameter("@OpportunityID", 1));
        cmd.Parameters.Add(new SqlParameter("@ModifiedDate", DateTime.Now));

        cmd.ExecuteNonQuery();
        sc.Close();
        int selectedSort = SortDropDown.SelectedIndex;

        GridViewPosts.DataSource = Post.getAllPostInfo(selectedSort);
        GridViewPosts.DataBind();
        txtNewPost.Text = "";
    }
示例#4
0
    protected void btnPostReply_Click(object sender, EventArgs e)
    {
        GridViewRow row = (sender as Button).NamingContainer as GridViewRow;
        Label       lblchildCommentid = (Label)row.FindControl("lblPostId");
        TextBox     txtCommentParent  = (TextBox)row.FindControl("txtCommentReply");
        SqlCommand  cmd = new SqlCommand("Insert into Comment(CommentDescription, DateCreated, PostID, PersonID) values (@Description, @DateCreated, @PostID, @PersonID)", sc);

        cmd.Parameters.Add(new SqlParameter("@Description", txtCommentParent.Text));
        cmd.Parameters.Add(new SqlParameter("@DateCreated", DateTime.Now));
        cmd.Parameters.Add(new SqlParameter("@PostID", lblchildCommentid.Text));
        cmd.Parameters.Add(new SqlParameter("@PersonID", 14));
        // cmd.Parameters.AddWithValue("@UserName", Request.QueryString["User_name"].ToString());
        sc.Open();
        cmd.ExecuteNonQuery();
        sc.Close();

        // Binds the Comments to the Post
        GridViewPosts.DataSource = Post.getAllPostInfo();
        GridViewPosts.DataBind();
    }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int selectedSort = SortDropDown.SelectedIndex;

        // Bind current posts from the database to the page
        GridViewPosts.DataSource = Post.getAllPostInfo(selectedSort);
        GridViewPosts.DataBind();

        sc.Open();
        System.Data.SqlClient.SqlCommand getdbPersonID = new System.Data.SqlClient.SqlCommand();
        getdbPersonID.Connection = sc;
        //Gets the personid for the username
        getdbPersonID.CommandText = "SELECT PersonID from Account where Username = '******'";

        int accountID = (int)getdbPersonID.ExecuteScalar();

        sc.Close();
        //lblDisplayName.Text = accountID.ToString();

        sc.Open();
        System.Data.SqlClient.SqlCommand getFName = new System.Data.SqlClient.SqlCommand();
        getFName.Connection = sc;
        //gets the firstname for the user
        //getFName.CommandText = "select Person.FirstName FROM Person INNER JOIN Account ON Person.PersonID = Account.PersonID where Person.PersonID = @AccountPersonID";
        getFName.CommandText = "Select FirstName from Person where Email = @FirstNamePerson";
        getFName.Parameters.Add(new SqlParameter("@FirstNamePerson", (string)(Session)["loginUser"]));
        // getdbPersonID.ExecuteNonQuery();
        string accountFName = (string)getFName.ExecuteScalar();

        sc.Close();

        sc.Open();
        System.Data.SqlClient.SqlCommand getLName = new System.Data.SqlClient.SqlCommand();
        getLName.Connection = sc;
        //gets the lastname for the user
        getLName.CommandText = "Select LastName FROM Person where Email = @AccountPersonName";
        getLName.Parameters.Add(new SqlParameter("@AccountPersonName", (string)(Session)["loginUser"]));
        string accountLName = (string)getLName.ExecuteScalar();

        sc.Close();

        LoginName.Text = accountFName + " " + accountLName;

        //Display current employer's username/email
        UserName.Text = (string)(Session)["loginUser"];

        sc.Open();
        System.Data.SqlClient.SqlCommand getCompName = new System.Data.SqlClient.SqlCommand();
        getCompName.Connection  = sc;
        getCompName.CommandText = "Select EmployerName from Employer Inner Join Person on Employer.EmployerID = Person.PersonID where PersonID = @EmployerID";
        getCompName.Parameters.Add(new SqlParameter("@EmployerID", Session["employerID"]));
        String Company = (String)getCompName.ExecuteScalar();

        CompanyName.Text = Company;
        sc.Close();

        sc.Open();
        System.Data.SqlClient.SqlCommand getSummary = new System.Data.SqlClient.SqlCommand();
        getSummary.Connection  = sc;
        getSummary.CommandText = "Select PersonalSummary from Person where Email = @Email";
        getSummary.Parameters.Add(new SqlParameter("@Email", (string)(Session)["loginUser"]));
        String Summary = (String)getSummary.ExecuteScalar();

        SumLblDesc.Text = Summary;
        sc.Close();

        sc.Open();
        System.Data.SqlClient.SqlCommand getLocation = new System.Data.SqlClient.SqlCommand();
        getLocation.Connection  = sc;
        getLocation.CommandText = "Select City from Address INNER JOIN Person on Address.AddressID  = Person.AddressID where Person.Email = @PersonEmail";
        getLocation.Parameters.Add(new SqlParameter("@PersonEmail", (string)(Session)["loginUser"]));
        String Location = (String)getLocation.ExecuteScalar();

        LocLblResult.Text = Location;
        sc.Close();

        GridViewPosts.CellPadding = 0;
        GridViewPosts.CellSpacing = 0;
    }
示例#6
0
    //Localhost Connection
    // System.Data.SqlClient.SqlConnection sc = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["LocalhostConnectionString"].ToString());

    protected void Page_Load(object sender, EventArgs e)
    {
        // Bind current posts from the database to the page
        GridViewPosts.DataSource = Post.getAllPostInfo();
        GridViewPosts.DataBind();
    }