private int CreateStaticBlock() { // Validation MsgErr(true); if (!ValidateInput()) { return(0); } var part = new StaticBlock { Content = CKEditorControl1.Text, InnerName = txtPageTitle.Text, Key = txtKey.Text, Enabled = chbEnabled.Checked }; var id = StaticBlockService.AddStaticBlock(part); if (id != 0) { return(id); } return(0); }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteBlock") { StaticBlockService.DeleteBlock(SQLDataHelper.GetInt(e.CommandArgument)); } }
private void SaveStaticBlock() { if (_mode == eStaicBlockMode.Err) { return; } if (!ValidateInput()) { return; } var part = new StaticBlock(_staticBlockId) { Content = CKEditorControl1.Text, InnerName = txtPageTitle.Text, Key = txtKey.Text, Enabled = chbEnabled.Checked }; if (!StaticBlockService.UpdatePagePart(part)) { MsgErr("Failed to save page part"); } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteBlock") { StaticBlockService.DeleteBlock(Convert.ToInt32(e.CommandArgument)); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(SourceKey)) { sb = StaticBlockService.GetPagePartByKeyWithCache(SourceKey); } this.Visible = sb != null && sb.Enabled; }
protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var part = StaticBlockService.GetPagePart(SQLDataHelper.GetInt(grid.UpdatedRow["ID"])); part.InnerName = grid.UpdatedRow["InnerName"]; part.Key = grid.UpdatedRow["[Key]"]; part.Enabled = SQLDataHelper.GetBoolean(grid.UpdatedRow["Enabled"]); if (part.InnerName.IsNotEmpty() && part.Key.IsNotEmpty()) { StaticBlockService.UpdatePagePart(part); } } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
public string RenderLiveCounter() { if (this.Visible) { var block = StaticBlockService.GetPagePartByKey("LiveCounter"); if (block != null && block.Enabled) { return(block.Content); } } return(string.Empty); }
private bool ValidateInput() { if (string.IsNullOrEmpty(txtKey.Text)) { MsgErr(Resource.Admin_PageParts_KeyRequired); return(false); } if (StaticBlockService.IsPagePartKeyExist(_staticBlockId, txtKey.Text)) { MsgErr(Resource.Admin_PageParts_KeyDuplicate); return(false); } return(true); }
private void LoadStaticBlock() { try { var part = StaticBlockService.GetPagePart(_staticBlockId); txtKey.Text = part.Key; txtPageTitle.Text = part.InnerName; CKEditorControl1.Text = part.Content; chbEnabled.Checked = part.Enabled; lblSubHead.Text = Resource.Admin_PagePart_Edit; } catch (Exception ex) { MsgErr(ex.Message + " at LoadStaticBlock"); //Debug.LogError(ex, _staticBlockId); Debug.LogError(ex, "at LoadStaticBlock"); } }
protected void lbSetDeactive_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (var id in _selectionFilter.Values) { StaticBlockService.SetStaticBlockActivity(SQLDataHelper.GetInt(id), false); } } else { var itemsIds = _paging.ItemsIds <int>("StaticBlockID as ID"); foreach (int id in itemsIds.Where(cId => !_selectionFilter.Values.Contains(cId.ToString(CultureInfo.InvariantCulture)))) { StaticBlockService.SetStaticBlockActivity(SQLDataHelper.GetInt(id), false); } } } }
protected void lbDeleteSelected_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (var id in _selectionFilter.Values) { StaticBlockService.DeleteBlock(Convert.ToInt32(id)); } } else { var itemsIds = _paging.ItemsIds <int>("StaticBlockID as ID"); foreach (int id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString(CultureInfo.InvariantCulture)))) { StaticBlockService.DeleteBlock(id); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(SourceKey)) { //const string staticBlock = "<div class=\"staticBlock\">{0}</div>"; //var temp = StaticBlockService.GetPagePartByKeyWithCache(SourceKey); //if (temp != null && temp.Enabled) //{ // ltOutputString.Text = CustomerSession.CurrentCustomer.IsAdmin ? string.Format(staticBlock, temp.Content) : temp.Content; //} //else if (CustomerSession.CurrentCustomer.IsAdmin) //{ // ltOutputString.Text = string.Format(staticBlock, "<div style=\"padding:10px;text-align:center;\">ѕустой статический блок</div>"); //} var temp = StaticBlockService.GetPagePartByKeyWithCache(SourceKey); if (temp != null && temp.Enabled) { ltOutputString.Text = temp.Content; } } }
protected void Page_Load(object sender, EventArgs e) { _paging = new SqlPaging { TableName = "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId" }; _paging.AddFieldsRange( new List <Field> { new Field { Name = "[Product].[ProductID]", IsDistinct = true }, //new Field {Name = "PhotoName AS Photo"}, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select Count(PhotoName) From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select Count(PhotoName) From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) END) AS CountPhoto" }, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS Photo" }, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc" }, new Field { Name = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors" }, //new Field {Name = "[Photo].[Description] AS PhotoDesc"}, new Field { Name = "[ProductCategories].[CategoryID]", NotInQuery = true }, new Field { Name = "BriefDescription" }, new Field { Name = "Product.ArtNo" }, new Field { Name = "Name" }, new Field { Name = "(CASE WHEN Price=0 THEN 0 ELSE 1 END) as TempSort", Sorting = SortDirection.Descending }, new Field { Name = "Recomended" }, new Field { Name = "Bestseller" }, new Field { Name = "New" }, new Field { Name = "OnSale" }, new Field { Name = "Discount" }, new Field { Name = "Offer.Main", NotInQuery = true }, new Field { Name = "Offer.OfferID" }, new Field { Name = "Offer.Amount" }, new Field { Name = "(CASE WHEN Offer.Amount=0 OR Offer.Amount < IsNull(MinAmount,0) THEN 0 ELSE 1 END) as TempAmountSort", Sorting = SortDirection.Descending }, new Field { Name = "MinAmount" }, new Field { Name = "MaxAmount" }, new Field { Name = "Enabled" }, new Field { Name = "AllowPreOrder" }, new Field { Name = "Ratio" }, new Field { Name = "RatioID" }, new Field { Name = "DateModified" }, new Field { Name = "ShoppingCartItemId" }, new Field { Name = "UrlPath" }, new Field { Name = "[ProductCategories].[SortOrder]" }, new Field { Name = "[ShoppingCart].[CustomerID]", NotInQuery = true }, new Field { Name = "BrandID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Size_ProductID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Color_ProductID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Price_ProductID", NotInQuery = true }, new Field { Name = "Offer.ColorID" }, new Field { Name = "CategoryEnabled", NotInQuery = true }, }); if (SettingsCatalog.ComplexFilter) { _paging.AddFieldsRange(new List <Field> { new Field { Name = "(select max (price) - min (price) from catalog.offer where offer.productid=product.productid) as MultiPrices" }, new Field { Name = "(select min (price) from catalog.offer where offer.productid=product.productid) as Price" }, }); } else { _paging.AddFieldsRange(new List <Field> { new Field { Name = "0 as MultiPrices" }, new Field { Name = "Price" }, }); } _paging.AddParam(new SqlParam { ParameterName = "@CustomerId", Value = CustomerContext.CustomerId.ToString() }); _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.Product.ToString() }); if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId)) { _categoryId = 0; var sbMainPage = StaticBlockService.GetPagePartByKeyWithCache("MainPageSocial"); if (sbMainPage != null && sbMainPage.Enabled) { MainPageText = sbMainPage.Content; } } if (!string.IsNullOrEmpty(MainPageText)) { SetMeta(null, string.Empty); return; } category = CategoryService.GetCategory(_categoryId); if (category == null || category.Enabled == false || category.ParentsEnabled == false) { Error404(); return; } ProductsCount = category.GetProductCount(); categoryView.CategoryID = _categoryId; categoryView.Visible = true; pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog; //lblCategoryDescription.Text = category.Description; //imgCategoryImage.ImageUrl = string.IsNullOrEmpty(category.Picture) ? "" : string.Format("{0}", ImageFolders.GetImageCategoryPath(false, category.Picture)); breadCrumbs.Items = CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs { Name = parent.Name, Url = "social/catalogsocial.aspx?categoryid=" + parent.CategoryId }).Reverse().ToList(); breadCrumbs.Items.Insert(0, new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("social/catalogsocial.aspx") }); SetMeta(category.Meta, category.Name); if (category.DisplayChildProducts) { var cfilter = new InChildCategoriesFieldFilter { CategoryId = _categoryId.ToString(), ParamName = "@CategoryID" }; _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } else { var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" }; _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } _paging.Fields["Enabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" };; _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@CategoryEnabled" }; var logicalFilter = new LogicalFilter { ParamName = "@Main", HideInCustomData = true }; logicalFilter.AddFilter(new EqualFieldFilter { Value = "1", ParamName = "@Main1", HideInCustomData = true }); logicalFilter.AddLogicalOperation("OR"); logicalFilter.AddFilter(new NullFieldFilter { Null = true, ParamName = "@Main2", HideInCustomData = true }); _paging.Fields["Offer.Main"].Filter = logicalFilter; BuildSorting(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack || OrderID == 0 || (Order = OrderService.GetOrder(OrderID)) == null) { return; } var sb = StaticBlockService.GetPagePartByKeyWithCache("OrderSuccessTop"); if (sb == null || (!CustomerContext.CurrentCustomer.IsAdmin && !sb.Enabled)) { SbOrderSuccessTopText = string.Empty; } else { SbOrderSuccessTopId = sb.StaticBlockId; SbOrderSuccessTopText = sb.Content ?? string.Empty; SbOrderSuccessTopText = SbOrderSuccessTopText.Replace("#ORDER_ID#", OrderID.ToString()); } if (SettingsOrderConfirmation.SuccessOrderScript.IsNotEmpty()) { string orderScript = SettingsOrderConfirmation.SuccessOrderScript .Replace("#ORDER_ID#", Order.OrderID.ToString()) .Replace("#ORDER_SUM#", Order.Sum.ToString("#.##")) .Replace("#CUSTOMER_EMAIL#", HttpUtility.HtmlEncode(Order.OrderCustomer.Email)) .Replace("#CUSTOMER_FIRSTNAME#", HttpUtility.HtmlEncode(Order.OrderCustomer.FirstName)) .Replace("#CUSTOMER_LASTNAME#", HttpUtility.HtmlEncode(Order.OrderCustomer.LastName)) .Replace("#CUSTOMER_PHONE#", HttpUtility.HtmlEncode(Order.OrderCustomer.MobilePhone)) .Replace("#CUSTOMER_ID#", Order.OrderCustomer.CustomerID.ToString()); var regex = new Regex("<<(.*)>>"); var match = regex.Match(orderScript); var products = new StringBuilder(); if (match.Groups.Count > 0 && match.Groups[1].Value.IsNotEmpty()) { var productLine = match.Groups[1].Value; foreach (var item in Order.OrderItems) { products.Append( productLine.Replace("#PRODUCT_ARTNO#", HttpUtility.HtmlEncode(item.ArtNo)) .Replace("#PRODUCT_NAME#", HttpUtility.HtmlEncode(item.Name)) .Replace("#PRODUCT_PRICE#", item.Price.ToString("#.##")) .Replace("#PRODUCT_AMOUNT#", item.Amount.ToString("#.##"))); } orderScript = orderScript.Replace("<<" + productLine + ">>", products.ToString()); } lSuccessScript.Text = orderScript; } LoadGoogleAnalytics(Order); if (GoogleTagManager.Enabled) { TagManager.PageType = GoogleTagManager.ePageType.purchase; TagManager.TotalValue = Order.OrderItems.Sum(item => item.Price * item.Amount); TagManager.Transaction = new Transaction() { TransactionAffiliation = SettingsMain.ShopName, TransactionId = Order.OrderID, TransactionTotal = Order.Sum - Order.ShippingCost, TransactionShipping = Order.ShippingCost, TransactionProducts = new List <TransactionProduct>( Order.OrderItems.Select( item => new TransactionProduct() { Name = item.Name, Price = item.Price, Quantity = item.Amount, SKU = item.ArtNo, Category = CategoryService.GetCategory( ProductService.GetFirstCategoryIdByProductId((int)item.ProductID)).Name })) }; } TrialService.TrackEvent(TrialEvents.CheckoutOrder, OrderID.ToString()); }