Пример #1
0
        protected void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var product = e.Item.DataItem as SueetieProduct;

            if (base.CurrentSueetieProduct.ProductTypeID == 1)
            {
                var breadcrumb = e.Item.FindControl("CommerceCrumbs1") as CommerceBreadCrumbs;
                if (breadcrumb != null)
                {
                    breadcrumb.CurrentCategoryID = base.CurrentSueetieProduct.CategoryID;
                }

                var sizeLiteral = e.Item.FindControl("ltSize") as Literal;
                if (sizeLiteral != null)
                {
                    var filePath = product.ResolveFilePath(this.Server);
                    var fileInfo = new FileInfo(filePath);
                    var fileSize = fileInfo.Length;

                    if (fileSize >= 1000 * 1000)
                    {
                        sizeLiteral.Text = string.Format("{0:#.##} Mo", (float)fileSize / (1000 * 1000));
                    }
                    else
                    {
                        sizeLiteral.Text = string.Format("{0:#.##} Ko", fileSize / 1000);
                    }
                }
            }
            else
            {
                HtmlTableRow row = e.Item.FindControl("rwSize") as HtmlTableRow;
                row.Visible = false;
            }

            if (base.CurrentSueetieProduct.ProductTypeID != 5)
            {
                Literal literal2 = e.Item.FindControl("ltPrice") as Literal;
                literal2.Text = CommerceHelper.FreeIt(base.CurrentSueetieProduct.Price);
            }
            else
            {
                HtmlTableRow row2 = e.Item.FindControl("rwPrice") as HtmlTableRow;
                row2.Visible = false;
            }

            if (product != null)
            {
                this.hyperlinkTitle.Text        = product.Title;
                this.hyperlinkTitle.NavigateUrl = string.Format("ShowProduct.aspx?id={0}", product.ProductID);
                this.SubTitleLabel.Text         = product.SubTitle;
                if (product.StatusTypeID == 100)
                {
                    if (base.CurrentSueetieUser.UserID != product.UserID)
                    {
                        Products.UpdateProductViewCount(this.ProductID);
                    }
                }
                else
                {
                    this.AdActions.Visible = false;
                }
            }
        }