private void setFlag(int recordId, bool value, string flagName) { try { PigeonCms.Section o1 = new PigeonCms.Section(); o1 = new SectionsManager().GetByKey(recordId); switch (flagName.ToLower()) { case "enabled": o1.Enabled = value; break; default: break; } new SectionsManager(true, true).Update(o1); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } finally { } }
protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var item = new PigeonCms.Section(); item = (PigeonCms.Section)e.Row.DataItem; LinkButton LnkTitle = (LinkButton)e.Row.FindControl("LnkTitle"); LnkTitle.Text = "<i class='fa fa-pgn_edit fa-fw'></i>"; LnkTitle.Text += Utility.Html.GetTextPreview(item.Title, 30, ""); if (string.IsNullOrEmpty(LnkTitle.Text)) LnkTitle.Text += Utility.GetLabel("NO_VALUE", "<no value>"); var LitItemInfo = (Literal)e.Row.FindControl("LitItemInfo"); if (!string.IsNullOrEmpty(item.ExtId)) LitItemInfo.Text += base.GetLabel("ExtId", "ExtId") + ": " + item.ExtId + "<br>"; LitItemInfo.Text += item.ItemType; if (item.Enabled) { var img1 = e.Row.FindControl("ImgEnabledOk"); img1.Visible = true; } else { var img1 = e.Row.FindControl("ImgEnabledKo"); img1.Visible = true; } //permissions //read string readAccessLevel = item.ReadAccessCode; if (item.ReadAccessLevel > 0) readAccessLevel += " " + item.ReadAccessLevel.ToString(); if (!string.IsNullOrEmpty(readAccessLevel)) readAccessLevel = " - " + readAccessLevel; //write string writeAccessLevel = item.WriteAccessCode; if (item.WriteAccessLevel > 0) writeAccessLevel += " " + item.WriteAccessLevel.ToString(); if (!string.IsNullOrEmpty(writeAccessLevel)) writeAccessLevel = " - " + writeAccessLevel; Literal LitAccessTypeDesc = (Literal)e.Row.FindControl("LitAccessTypeDesc"); //read LitAccessTypeDesc.Text = item.ReadAccessType.ToString(); if (item.ReadAccessType != MenuAccesstype.Public) { string roles = ""; foreach (string role in item.ReadRolenames) { roles += role + ", "; } if (roles.EndsWith(", ")) roles = roles.Substring(0, roles.Length - 2); if (roles.Length > 0) roles = " (" + roles + ")"; LitAccessTypeDesc.Text += Utility.Html.GetTextPreview(roles, 80, ""); LitAccessTypeDesc.Text += readAccessLevel; } if (LitAccessTypeDesc.Text != "") LitAccessTypeDesc.Text += "<br />"; //write LitAccessTypeDesc.Text += item.WriteAccessType.ToString(); if (item.WriteAccessType != MenuAccesstype.Public) { string roles = ""; foreach (string role in item.WriteRolenames) { roles += role + ", "; } if (roles.EndsWith(", ")) roles = roles.Substring(0, roles.Length - 2); if (roles.Length > 0) roles = " (" + roles + ")"; LitAccessTypeDesc.Text += Utility.Html.GetTextPreview(roles, 80, ""); LitAccessTypeDesc.Text += writeAccessLevel; } //files upload var LnkUploadFiles = (HyperLink)e.Row.FindControl("LnkUploadFiles"); LnkUploadFiles.NavigateUrl = this.FilesUploadUrl + "?type=sections&id=" + item.Id.ToString(); 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"; } //images upload var LnkUploadImg = (HyperLink)e.Row.FindControl("LnkUploadImg"); LnkUploadImg.NavigateUrl = this.ImagesUploadUrl + "?type=sections&id=" + item.Id.ToString(); 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"; } //items inserted/allowed var LitItems = (Literal)e.Row.FindControl("LitItems"); string itemsAllowed = ""; string numOfItems = "0"; if (item.MaxItems > 0) itemsAllowed = " / " + item.MaxItems.ToString(); numOfItems = item.NumOfItems.ToString(); LitItems.Text = numOfItems + itemsAllowed; if (LitItems.Text == "0") LitItems.Text = ""; //space used/allowed var LitDiskSpace = (Literal)e.Row.FindControl("LitDiskSpace"); LitDiskSpace.Text = Utility.GetFileHumanLength(item.SizeOfItems); if (item.MaxAttachSizeKB > 0) LitDiskSpace.Text += " / " + Utility.GetFileHumanLength(item.MaxAttachSizeKB*1024); } }