Exemplo n.º 1
0
    private void editRow(int recordId)
    {
        var obj = new PigeonCms.Shop.ProductItem();
        LblOk.Text = RenderSuccess("");
        LblErr.Text = RenderError("");

        if (!PgnUserCurrent.IsAuthenticated)
            throw new Exception("user not authenticated");

        clearForm();
        clearQuickForm();
        CurrentId = recordId;
        if (CurrentId == 0)
        {
            loadDropCategories(PRODUCT_SECTION); //TODO with settings.
            obj.ItemDate = DateTime.Now;
            obj.ValidFrom = DateTime.Now;
            obj.ValidTo = DateTime.MinValue;
            int defaultCategoryId = 0;
            int.TryParse(DropCategoriesFilter.SelectedValue, out defaultCategoryId);
            obj.CategoryId = defaultCategoryId;
            obj.AttributeSet = 0;
            obj2form(obj);
            LitItemType.Text = obj.ItemTypeName;
            obj.IsDraft = true;
            var currentProd = new ProductItemsManager().Insert(obj);
            this.CurrentId = currentProd.Id;
        }
        else
        {
            obj = new ProductItemsManager(true, true).GetByKey(CurrentId);
            loadDropCategories(obj.SectionId);

            // QUI nascondere le dropdown in più
            hideAttributes(obj.AttributeSet);
            hideAttributes(obj.AttributeSet, true);

            obj2form(obj);
        }
        GridRelated.DataBind();
        GridViewSimple.DataBind();
        MultiView1.ActiveViewIndex = VIEW_INSERT;
    }
Exemplo n.º 2
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            PigeonCms.Shop.ProductItem item = new PigeonCms.Shop.ProductItem();
            item = (PigeonCms.Shop.ProductItem)e.Row.DataItem;

            //item.IsThreadRoot = true;

            if (item.IsThreadRoot)
                lastRowDataboundRoot = e.Row;
            else
            {
                if (lastRowDataboundRoot != null)
                    e.Row.RowState = lastRowDataboundRoot.RowState; //keeps same style of thread root
            }

            int threadId = 0;
            int.TryParse(base.CurrentKey, out threadId);

            LinkButton LnkShowVariants = (LinkButton)e.Row.FindControl("LnkShowVariants");
            if (!item.IsDraft && item.ProductType == ProductItem.ProductTypeEnum.Configurable && item.IsThreadRoot && (bool)item.HasThreads)
            {
                if (threadId > 0)
                {
                    LnkShowVariants.Text = "<i class='fa fa-minus fa-fw'></i>";
                    LnkShowVariants.CommandName = "HideThreads";
                }
                else
                {
                    LnkShowVariants.Text = "<i class='fa fa-plus fa-fw'></i>";
                    LnkShowVariants.CommandName = "ShowThreads";
                }
            }
            else
            {
                LnkShowVariants.Visible = false;
            }

            var LnkTitle = (LinkButton)e.Row.FindControl("LnkTitle");
            LnkTitle.Text = "<i class='fa fa-pgn_edit fa-fw'></i>";
            if (!item.IsThreadRoot)
                LnkTitle.Text += "--";
            LnkTitle.Text += Utility.Html.GetTextPreview(item.Title, 50, "");
            if (string.IsNullOrEmpty(item.Title))
                LnkTitle.Text += Utility.GetLabel("NO_VALUE", "<no value>");

            if (base.ShowSecurity && Roles.IsUserInRole("debug"))
                LnkTitle.Text += " [" + item.Id.ToString() + "]";

            var LitItemInfo = (Literal)e.Row.FindControl("LitItemInfo");
            if (this.ShowType)
                LitItemInfo.Text += item.ProductType.ToString() +"<br>";
            if (!string.IsNullOrEmpty(item.CssClass))
                LitItemInfo.Text += "class: " + item.CssClass +"<br>";
            if (item.ThreadItems.Count > 0)
                LitItemInfo.Text += "variants compiled: " + item.ThreadItems.Count;

            if (item.CategoryId > 0)
            {
                var mgr = new CategoriesManager();
                var cat = mgr.GetByKey(item.CategoryId);
                var LitCategoryTitle = (Literal)e.Row.FindControl("LitCategoryTitle");
                LitCategoryTitle.Text = cat.Title;
            }

            if (item.Enabled)
            {
                var img1 = e.Row.FindControl("ImgEnabledOk");
                img1.Visible = true;
            }
            else
            {
                var img1 = e.Row.FindControl("ImgEnabledKo");
                img1.Visible = true;
            }

            //permissions
            var LitAccessTypeDesc = (Literal)e.Row.FindControl("LitAccessTypeDesc");
            LitAccessTypeDesc.Text = RenderAccessTypeSummary(item);

            //files upload
            var LnkUploadFiles = (HyperLink)e.Row.FindControl("LnkUploadFiles");
            LnkUploadFiles.NavigateUrl = this.FilesUploadUrl
                + "?type=items&id=" + item.Id.ToString();
            LnkUploadFiles.Visible = this.TargetFilesUpload > 0;
            if (this.IsMobileDevice == false)
                LnkUploadFiles.CssClass = "fancyRefresh";
            var LitFilesCount = (Literal)e.Row.FindControl("LitFilesCount");
            int filesCount = item.Files.Count;
            if (filesCount > 0)
            {
                LitFilesCount.Text = filesCount.ToString();
                LitFilesCount.Text += filesCount == 1 ? " file" : " files";
                LitFilesCount.Text += "<br />(" + Utility.GetFileHumanLength(item.FilesSize) + ")";
            }

            //images upload
            var LnkUploadImg = (HyperLink)e.Row.FindControl("LnkUploadImg");
            LnkUploadImg.NavigateUrl = this.ImagesUploadUrl
                + "?type=items&id=" + item.Id.ToString();
            LnkUploadImg.Visible = this.TargetImagesUpload > 0;
            if (this.IsMobileDevice == false)
                LnkUploadImg.CssClass = "fancyRefresh";
            var LitImgCount = (Literal)e.Row.FindControl("LitImgCount");
            int imgCount = item.Images.Count;
            if (imgCount > 0)
            {
                LitImgCount.Text = imgCount.ToString();
                LitImgCount.Text += imgCount == 1 ? " file" : " files";
                LitImgCount.Text += "<br />(" + Utility.GetFileHumanLength(item.ImagesSize) + ")";
            }

        }
    }