protected void Page_Load(object sender, EventArgs e)
 {
     if (!User.Identity.IsAuthenticated)
     {
         PostingCRUD postingCrud = new PostingCRUD();
         List<Posting> postings = postingCrud.GetList()
             .Where(x => x.Show == true)
             .OrderByDescending(x => x.PostedDate)
             .Skip((PageNumber - 1) * RowsPerPage)
             .Take(RowsPerPage)
             .ToList();
         rptData.DataSource = postings;
         rptData.DataBind();
     }
     else
     {
         cntrlPostings.Visible = false;
         PostingCRUD postingCrud = new PostingCRUD();
         List<Posting> postings = postingCrud.GetList()
             .OrderByDescending(x => x.PostedDate)
             .Skip((PageNumber - 1) * RowsPerPage)
             .Take(RowsPerPage)
             .ToList();
         rptData.DataSource = postings;
         rptData.DataBind();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     PostingCRUD postingsCrud = new PostingCRUD();
     List<Posting> postings = postingsCrud.GetList();
     rptPostings.DataSource = postings;
     rptPostings.DataBind();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            PostingCRUD postingCrud = new PostingCRUD();
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                postings.TotalRows = postingCrud.GetList().Count;
            }
            else
            {
                postings.TotalRows = postingCrud.GetList().Where(x=>x.Show==true).Count();
            }
            if (postings.TotalRows > 3)
            {
                int pagesCount = (int)Math.Ceiling((double)postings.TotalRows / postings.RowsPerPage);
                List<string> pages = new List<string>();
                if (PageNumber > 4)
                {
                    pages.Add("1");
                    pages.Add("..");
                }
                else
                {
                    pages.Add("1");
                }
                for (int i = 2; i < pagesCount; i++)
                {
                    if (i <= (PageNumber + 2) && i >= (PageNumber - 2))
                    {
                        pages.Add(i.ToString());
                    }
                }
                if (PageNumber < pagesCount - 3)
                {
                    pages.Add("..");
                    pages.Add(pagesCount.ToString());
                }
                else
                {
                    pages.Add(pagesCount.ToString());
                }
                rptPager.DataSource = pages;
                rptPager.DataBind();

                if (PageNumber > 1)
                {
                    lnkPrev.NavigateUrl = string.Format("../Postings.aspx?Page={0}", PageNumber - 1);
                    lnkPrev.Visible = true;
                }
                if (PageNumber < pagesCount)
                {
                    lnkNext.NavigateUrl = string.Format("~/Postings.aspx?Page={0}", PageNumber + 1);
                    lnkNext.Visible = true;
                }
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PostingCRUD postingCrud = new PostingCRUD();
                postings = postingCrud.GetList()
                .Where(x => x.Show == true)
                .OrderByDescending(x => x.PostedDate)
                .ToList();
                postings = GetEveryThirdPosting(postings);
                rptData.DataSource = postings;
            rptData.DataBind();

            FillScrollingString();
        }
 public void btnSubmit_Click(object sender, EventArgs e)
 {
     PostingCRUD postings = new PostingCRUD();
     if (PageID == 0)
     {
         if (ValidateDescription())
         {
             int result = postings.Add(new Posting
                    {
                        Description = txtDescription.Text,
                        Show = checkShow.Checked,
                        PostedDate = DateTime.Now,
                        UserName = txtUserName.Text,
                        Id = new PostingCRUD().GetNextNumber(),
                        IPAddress = GetIPAddress()
                    });
             if (result != 0)
             {
                 Response.Redirect("~/Postings.aspx?IsSuccess=PostingSuccess");
             }
             else
             {
                 Response.Redirect("~/Postings.aspx?IsSuccess=PostingError");
             }
         }
         else
         {
             Response.Redirect("~/Postings.aspx?IsSuccess=Forbidden");
         }
     }
     else
     {
         postings.Update(new Posting
                 {
                     Description = txtDescription.Text,
                     Show = checkShow.Checked,
                     UserName = txtUserName.Text,
                     Id = PageID
                 });
         Response.Redirect("~/BE/NewPosting.aspx");
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            PostingCRUD postingCrud = new PostingCRUD();
            if (!IsPostBack && PageID != 0)
            {
                Posting postings = postingCrud.GetList()
                    .Where(x => x.Id == PageID)
                    .FirstOrDefault();

                txtUserName.Text = postings.UserName;
                txtDescription.Text = postings.Description;
                checkShow.Checked = postings.Show;
            }

            if (DeleteID != 0)
            {
                postingCrud.Delete(DeleteID);
                Response.Redirect("~/Postings.aspx");
            }
        }