Exemple #1
0
        protected void ListViewActivities_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            actNo++;
            Label lblNo               = e.Item.FindControl("lblNo") as Label;
            Label lblPhone            = e.Item.FindControl("lblPhone") as Label;
            Label lblSub              = e.Item.FindControl("lblSub") as Label;
            Label lblAddress          = e.Item.FindControl("lblAddress") as Label;
            Label lblState            = e.Item.FindControl("lblState") as Label;
            Label lblPostCode         = e.Item.FindControl("lblPostCode") as Label;
            Label lblShortDescription = e.Item.FindControl("lblShortDescription") as Label;
            Label lblSaved            = e.Item.FindControl("lblSaved") as Label;

            HyperLink HlnkReadMore       = e.Item.FindControl("HlnkReadMore") as HyperLink;
            HyperLink HlnkActivitiesName = e.Item.FindControl("HlnkActivitiesName") as HyperLink;

            HiddenField hdnProviderID = e.Item.FindControl("hdnProviderID") as HiddenField;
            HiddenField hdnActivityID = e.Item.FindControl("hdnActivityID") as HiddenField;
            HiddenField hdnisSaved    = e.Item.FindControl("hdnisSaved") as HiddenField;

            LinkButton lnkSaved = e.Item.FindControl("lnkSaved") as LinkButton;

            System.Web.UI.WebControls.Image imgPreview = e.Item.FindControl("imgPreview") as System.Web.UI.WebControls.Image;

            string actName = HlnkActivitiesName.Text;

            actName = actName.Replace(" ", "-");
            actName = actName.Replace("/", "-or-");
            if (actName.EndsWith("."))
            {
                actName.TrimEnd('.');
            }
            HlnkActivitiesName.NavigateUrl = HlnkReadMore.NavigateUrl = "~/Activity/" + hdnActivityID.Value + "/" + actName;

            //lblPhone.Text = "Tel: " + lblPhone.Text;
            HtmlGenericControl divDescription = e.Item.FindControl("divDescription") as HtmlGenericControl;

            if (Regex.IsMatch(lblShortDescription.Text, @"([a-zA-Z]){20,}"))
            {
                divDescription.Attributes.Add("class", "breaking");
            }

            TimeViewer ScheduleViewerUC1 = e.Item.FindControl("ScheduleViewerUC") as TimeViewer;

            ScheduleViewerUC1.ActivityID      = Convert.ToInt32(hdnActivityID.Value);
            ScheduleViewerUC1.timetableFormat = (int)SystemConstants.TimetableFormat.Seasonal;

            if (string.IsNullOrEmpty(lblSub.Text))
            {
                lblAddress.Visible  = false;
                lblSub.Visible      = false;
                lblState.Visible    = false;
                lblPostCode.Visible = false;
            }
            lblSub.Text = lblSub.Text + ", ";
            //lblNo.Text = actNo.ToString() + ".";

            HiddenField hdnExpiryDate = e.Item.FindControl("hdnExpiryDate") as HiddenField;
            HiddenField hdnType       = e.Item.FindControl("hdnType") as HiddenField;

            System.Web.UI.WebControls.Image imgStatus   = e.Item.FindControl("imgStatus") as System.Web.UI.WebControls.Image;
            System.Web.UI.WebControls.Image imgCostIcon = e.Item.FindControl("imgCostIcon") as System.Web.UI.WebControls.Image;

            //Label lblType = e.Item.FindControl("lblType") as Label;
            //lblType.ForeColor = Color.Green;

            if (hdnType.Value == ((int)SystemConstants.ActivityFeeCategory.Private_Free).ToString() || hdnType.Value == ((int)SystemConstants.ActivityFeeCategory.Public_Free).ToString())
            {
                //lblType.Text = "Free Activity";
                //lblType.ForeColor = Color.Green; ;
                imgCostIcon.ImageUrl = "~/Content/StyleImages/free.png";
                imgCostIcon.ToolTip  = "This activity is free";
            }
            else if (hdnType.Value == ((int)SystemConstants.ActivityFeeCategory.Private_Paid).ToString() || hdnType.Value == ((int)SystemConstants.ActivityFeeCategory.Public_Paid).ToString())
            {
                imgCostIcon.ToolTip  = "This activity has a fee";
                imgCostIcon.ImageUrl = "~/Content/StyleImages/Paid.png";
            }
            var dr = new CustomerDAC().RetrieveActivityPrimaryImage(Convert.ToInt32(hdnActivityID.Value));

            if (dr != null && dr.ImageStream != null)
            {
                //imgPreview.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(dr.ImageStream);                 Convert byte directly, while its easier, its not suppose to be
                imgPreview.ImageUrl = "~/ImageHandler.ashx?" + SystemConstants.qs_ThumbImageID + "=" + dr.ID;
            }
            else
            {
                if (new CustomerDAC().IsUserImageExist(new Guid(hdnProviderID.Value)))
                {
                    int ImageID = new CustomerBFC().getProviderPrimaryImage(new Guid(hdnProviderID.Value));
                    if (ImageID != 0)
                    {
                        imgPreview.ImageUrl = "~/ImageHandler.ashx?" + SystemConstants.qs_UserImageID + "=" + ImageID;
                    }
                    else
                    {
                        imgPreview.Visible = false;
                    }
                }
            }
            if (WebSecurity.IsAuthenticated)
            {
                if (SavedList.Equals(string.Empty))
                {
                    hdnisSaved.Value = false.ToString();
                    lblSaved.Text    = "Save Activity";
                    lnkSaved.Attributes.Add("Class", "btn-icon btn-white btn-radius btn-star");
                }
                else
                {
                    List <string> SavedactList = SavedList.Split('|').ToList();

                    if (SavedactList.Contains(hdnActivityID.Value))
                    {
                        hdnisSaved.Value = true.ToString();
                        lblSaved.Text    = "Saved";
                        lnkSaved.Attributes.Add("Class", "btn-icon btn-white btn-radius btn-starred");
                    }
                    else
                    {
                        hdnisSaved.Value = false.ToString();
                        lblSaved.Text    = "Save Activity";
                        lnkSaved.Attributes.Add("Class", "btn-icon btn-white btn-radius btn-star btn-star");
                    }
                }
                lnkSaved.Attributes.Add("OnClick", "ToggleSave(" + hdnActivityID.Value + "," + lnkSaved.ClientID + "," + hdnisSaved.Value + ");");
                RetrieveSavedList();
            }

            else
            {
                lnkSaved.Visible = false;
            }
        }
Exemple #2
0
        public void Refresh()
        {
            if (WebSecurity.IsAuthenticated)
            {
                RetrieveSavedList();
            }

            lblKeyword.Visible = false;
            int amount = 0;

            if (!SavedList.Equals(string.Empty))
            {
                string[] savedActsArr = SavedList.Split('|');

                HashSet <int> savedActs = new HashSet <int>(savedActsArr.Select(x => Convert.ToInt32(x)));
                CustomerEDSC.v_ActivityExplorerDTDataTable dt = new CustomerDAC().RetrieveActivityExplorersbyIDs(savedActs, "");
                ListViewActivities.DataSource = dt;
                ListViewActivities.DataBind();
                SortProducts();

                amount = new CustomerDAC().RetrieveActivityExplorersbyIDsCount(savedActs);
            }
            else
            {
                CustomerEDSC.v_ActivityExplorerDTDataTable dt = null;
                ListViewActivities.DataSource = dt;
                ListViewActivities.DataBind();
            }

            lblAmount.Text = amount.ToString();
            if (Convert.ToInt32(lblAmount.Text) <= Convert.ToInt32(PageSize + StartRow))
            {
                lblEndIndex.Text = lblAmount.Text;
            }
            else
            {
                lblEndIndex.Text = (StartRow + PageSize).ToString();
            }

            lblStartIndex.Text = (StartRow + 1).ToString();

            if (Convert.ToInt32(lblStartIndex.Text) >= Convert.ToInt32(lblEndIndex.Text))
            {
                lblStartIndex.Text = lblEndIndex.Text;
            }

            lblEndIndex1.Text   = lblEndIndex.Text;
            lblStartIndex1.Text = lblStartIndex.Text;
            lblAmount1.Text     = lblAmount.Text;


            if (amount == 0)
            {
                ItemCountBottom.Visible = false;
            }
            else
            {
                if (amount <= PageSize)
                {
                    divPager.Visible        = false;
                    ItemCountBottom.Visible = true;
                }
                else
                {
                    divPager.Visible = ItemCountBottom.Visible = true;
                }
            }
        }