public bool SaveFooterTemplate(FooterTemplateManageModel model) { if (model.ID > 0) { var dataUpdate = new FooterTemplate() { ID = model.ID.Value, Content = model.Content, ContentEnglish = model.ContentEnglish, IsDefaultTemplate = model.IsDefaultTemplate }; return(_footerRepository.UpdateFooterTemplate(dataUpdate)); } else { FooterTemplate data = new FooterTemplate() { Name = model.Name, Content = model.Content, ContentEnglish = model.ContentEnglish, IsDefaultTemplate = model.IsDefaultTemplate, Created = DateTime.Now, CreatedBy = "Admin", LastUpdate = DateTime.Now, LastUpdateBy = "Admin", RecordActive = true, RecordDeleted = false, RecordOrder = 1 }; return(_footerRepository.AddFooterTemplate(data)); } }
public bool UpdateFooterTemplate(FooterTemplate headerTemplate) { using (var db = new KentEntities()) { try { var template = db.FooterTemplates.Where(d => d.ID == headerTemplate.ID).FirstOrDefault(); if (template == null) { return(false); } template.Content = headerTemplate.Content; template.ContentEnglish = headerTemplate.ContentEnglish; template.IsDefaultTemplate = headerTemplate.IsDefaultTemplate; template.LastUpdate = DateTime.Now; return(db.SaveChanges() > 0 ? true : false); } catch (SqlException sqlEx) { Logger.ErrorException(sqlEx); } catch (Exception ex) { Logger.ErrorException(ex); } } return(false); }
public FooterTemplate GetFooterTemplateDefault() { FooterTemplate result = new FooterTemplate(); using (IDbConnection conn = Connection) { string sql = "select * from FooterTemplates where IsDefaultTemplate = 1"; try { conn.Open(); result = conn.Query <FooterTemplate>(sql).AsQueryable().FirstOrDefault(); } catch (SqlException sqlEx) { Logger.ErrorException(sqlEx); } catch (Exception ex) { Logger.ErrorException(ex); } finally { if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } } } return(result); }
protected override void CreateChildControls() { Controls.Clear(); rptList = new Repeater(); plhHeader = new WebPlaceHolder(); plhFooter = new WebPlaceHolder(); if (ItemTemplate != null) { rptList.ItemTemplate = ItemTemplate; } if (AlternatingItemTemplate != null) { rptList.ItemTemplate = AlternatingItemTemplate; } if (SeparatorTemplate != null) { rptList.SeparatorTemplate = SeparatorTemplate; } PopulateListControls(); if (HeaderTemplate != null) { HeaderTemplate.InstantiateIn(plhHeader); } if (FooterTemplate != null) { FooterTemplate.InstantiateIn(plhFooter); } rptList.ItemCreated += ListItemCreated; rptList.ItemDataBound += ListItemDataBound; }
public FooterTemplateModel GetFooterTemplateDefault() { FooterTemplate data = _footerRepository.GetFooterTemplateDefault(); if (data != null) { return(Mapping(data)); } return(new FooterTemplateModel()); }
public FooterTemplateManageModel GetFooterTemplateById(int id) { FooterTemplate data = _footerRepository.GetFooterTemplateById(id); if (data != null) { return(MappingManageModel(data)); } return(new FooterTemplateManageModel()); }
private FooterTemplateManageModel MappingManageModel(FooterTemplate data) { return(new FooterTemplateManageModel() { ID = data.ID, Name = data.Name, Content = data.Content, ContentEnglish = data.ContentEnglish, IsDefaultTemplate = data.IsDefaultTemplate }); }
protected override void CreateChildControls() { base.CreateChildControls(); // header if (HeaderTemplate != null) { _headerTemplate = new HtmlGenericControl("header"); _headerTemplate.Attributes.Add("class", "modal-header"); HtmlGenericControl h2 = new HtmlGenericControl("h2"); h2.Attributes.Add("class", "modal-title"); _headerTemplate.Controls.Add(h2); this.Controls.Add(_headerTemplate); HeaderTemplate.InstantiateIn(h2); } // body with empty content by default _bodyTemplate = new HtmlGenericControl("div"); _bodyTemplate.Attributes.Add("class", "modal-body"); this.Controls.Add(_bodyTemplate); if (BodyTemplate != null) { BodyTemplate.InstantiateIn(_bodyTemplate); } // footer if (FooterTemplate != null) { _footerTemplate = new HtmlGenericControl("div"); _footerTemplate.Attributes.Add("class", "modal-footer"); this.Controls.Add(_footerTemplate); FooterTemplate.InstantiateIn(_footerTemplate); } try { Control target = Page.FindControlRecursive(this.AssociateControlID); if (target is WebControl wc) { wc.Attributes["href"] = "#" + this.ClientID; wc.AddCssClass(IsClosable ? "wb-lbx" : "wb-lbx lbx-modal"); } } catch (Exception) { throw new Exception("AssociateControlID property for WetModal with ID " + this.ID + " should refer to an html control with the href attribute."); } }
private FooterTemplateModel Mapping(FooterTemplate data) { return(new FooterTemplateModel() { ID = data.ID, Name = data.Name, Content = data.Content, ContentEnglish = data.ContentEnglish, IsDefaultTemplate = data.IsDefaultTemplate, Created = data.Created, CreatedBy = data.CreatedBy, LastUpdate = data.LastUpdate, LastUpdateBy = data.LastUpdateBy }); }
private async void setItemsSource(IList items) { if (!initialized) { if (HeaderTemplate != null) { ContentPanel.Children.Add((FrameworkElement)HeaderTemplate.LoadContent()); } if (FooterTemplate != null) { ContentPanel.Children.Add((FrameworkElement)FooterTemplate.LoadContent()); } initialized = true; } if (items == null) { items = new object[0]; } int headerCount = HeaderTemplate != null ? 1 : 0; int footerCount = FooterTemplate != null ? 1 : 0; int itemsCount = ContentPanel.Children.Count - headerCount - footerCount; int changeableCount = Math.Min(itemsCount, items.Count); int addableCount = items.Count - changeableCount; int removableCount = itemsCount - changeableCount; var itemTemplate = this.ItemTemplate; for (int i = 0; i < changeableCount; i++) { ((FrameworkElement)(((Border)ContentPanel.Children[headerCount + i]).Child)).DataContext = items[i]; } for (int i = 0; i < addableCount; i++) { object newItem = items[changeableCount + i]; FrameworkElement newElement = (FrameworkElement)itemTemplate.LoadContent(); newElement.DataContext = newItem; var newElementContainer = new Border { Child = newElement, Background = new SolidColorBrush(Colors.Transparent) }; newElementContainer.Tapped += elementContainer_Tapped; ContentPanel.Children.Insert(ContentPanel.Children.Count - footerCount, newElementContainer); } for (int i = removableCount - 1; i >= 0; i--) { ContentPanel.Children.RemoveAt(headerCount + changeableCount + i); } }
public override void RenderFooter(TableCell container) { if (container == null) { throw new ArgumentNullException("container"); } if (FooterTemplate == null) { base.RenderFooter(container); } else { FooterTemplate.InstantiateIn(container); container.ApplyStyle(FooterStyle); } }
private void CreateControlHierarchy() { if (HeaderTemplate != null) { BasicTemplateContainer header = new BasicTemplateContainer(); HeaderTemplate.InstantiateIn(header); Controls.Add(header); Controls.Add(new LiteralControl("<br>")); } int count = menuData.Count; for (int index = 0; index < count; index++) { MenuItemData itemdata = (MenuItemData)menuData[index]; CreateMenuItem(itemdata.Title, itemdata.Url, itemdata.ImageUrl, itemdata.Target); if (index != count - 1) { if (SeparatorTemplate != null) { BasicTemplateContainer separator = new BasicTemplateContainer(); SeparatorTemplate.InstantiateIn(separator); Controls.Add(separator); } else { Controls.Add(new LiteralControl(" | ")); } } } if (FooterTemplate != null) { Controls.Add(new LiteralControl("<br>")); BasicTemplateContainer footer = new BasicTemplateContainer(); FooterTemplate.InstantiateIn(footer); Controls.Add(footer); } }
public bool AddFooterTemplate(FooterTemplate headerTemplate) { using (var db = new KentEntities()) { try { db.FooterTemplates.Add(headerTemplate); return(db.SaveChanges() > 0 ? true : false); } catch (SqlException sqlEx) { Logger.ErrorException(sqlEx); } catch (Exception ex) { Logger.ErrorException(ex); } } return(false); }
/// <summary> /// Creates the child controls in a control derived from System.Web.UI.WebControls.CompositeControl. /// </summary> protected override void CreateChildControls() { Controls.Clear(); IntializeControlsDefaultValues(); /********************************/ /******** CREATE CONTROLS *******/ /********************************/ //*********************// //*** USE TEMPLATES ***// //*********************// //outer box string style = string.Empty; style = "shopping_cart"; Controls.Add(new LiteralControl("<table style='width: 100%' cellpadding='0' cellspacing='0' border='0'>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td class=\"" + style + "\" >")); //if the page developer does not explicitly add a <HeaderTemplate> tag //in ShoppingCartControl's declarative syntax if (HeaderTemplate == null) { if (this.DesignMode) { ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete"); defaultTemplate.InstantiateIn(this); } else { if (this.DataSource != null) { CartItemCollection cic = this.DataSource; if (cic.Count != 0) { ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete"); defaultTemplate.InstantiateIn(this); } else { Topic emptyCartTopic = new Topic(this.EmptyCartTopicName); ITemplate defaultTemplate = new MobileDefaultHeaderTemplate(emptyCartTopic.Contents); defaultTemplate.InstantiateIn(this); } } else { ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete"); defaultTemplate.InstantiateIn(this); } } } else { if (this.DataSource != null) { CartItemCollection cic = (CartItemCollection)this.DataSource; if (cic.Count != 0) { CustomTemplate headerTemplateItem = new CustomTemplate(); headerTemplateItem.ID = "headerTemplateItem"; HeaderTemplate.InstantiateIn(headerTemplateItem); Controls.Add(new LiteralControl(" <table style='width : 100%;' cellpadding='0' cellspacing='0' border='0'>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>")); Controls.Add(headerTemplateItem); Controls.Add(new LiteralControl(" </td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" </table>")); } else { Topic emptyCartTopic = new Topic(this.EmptyCartTopicName); ITemplate defaultTemplate = new MobileDefaultHeaderTemplate(emptyCartTopic.Contents); defaultTemplate.InstantiateIn(this); } } else { CustomTemplate headerTemplateItem = new CustomTemplate(); headerTemplateItem.ID = "headerTemplateItem"; HeaderTemplate.InstantiateIn(headerTemplateItem); Controls.Add(new LiteralControl(" <table style='width : 100%;' cellpadding='0' cellspacing='0' border='0'>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>")); Controls.Add(headerTemplateItem); Controls.Add(new LiteralControl(" </td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" </table>")); } } ShoppingCart cart = null; //ITEMS Template if (DataSource != null) { Items.Clear(); int alternateItem = 0; CartItemCollection sortedCartItemForMinicart = new CartItemCollection(); sortedCartItemForMinicart = this.DataSource; Panel pnlItems = new Panel(); pnlItems.ID = "pnlCartItems"; pnlItems.CssClass = "cart_items"; foreach (CartItem cItem in sortedCartItemForMinicart) { cart = cItem.ThisShoppingCart; if (alternateItem > 0) { // alternating separator pnlItems.Controls.Add(new LiteralControl("<div style='border-top: solid 1px #444444'></div>")); } item = new MobileShoppingCartControlItem(this.LineItemSettings); item.CartItem = cItem; item.AllowEdit = this.AllowEdit; item.DisplayMode = this.DisplayMode; if (cItem.ThisShoppingCart.CartType == CartTypeEnum.Deleted) { item.IsDeleted = true; } Items.Add(item); pnlItems.Controls.Add(item); alternateItem++; } Controls.Add(pnlItems); } if (DesignMode) { Controls.Add(new LiteralControl("<table style='width: 100%;' cellpadding='0' cellspacing='0' border='0'>")); Controls.Add(new LiteralControl(" <tr>")); //dummy line item description Controls.Add(new LiteralControl(" <td style='width:60%' valign='top'>")); Controls.Add(new LiteralControl(" <table style='width: 100%;' cellpadding='0' cellspacing='0' border='0'>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>Product Name : Unbound</td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>SKU : Unbound</td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>Size : Unbound</td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" <tr>")); Controls.Add(new LiteralControl(" <td>Color : Unbound</td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl(" </table>")); Controls.Add(new LiteralControl(" </td>")); //dummy quantity & delete button TextBox txtQuantity = new TextBox(); txtQuantity.Text = "Unbound"; LinkButton lnkDelete = new LinkButton(); lnkDelete.Text = "shoppingcart.cs.107".StringResource(); Controls.Add(new LiteralControl(" <td style='width:15%' valign='top'>")); Controls.Add(txtQuantity); Controls.Add(lnkDelete); Controls.Add(new LiteralControl(" </td>")); //dummy extended price Controls.Add(new LiteralControl(" <td style='width:25%;' align='right' valign='top'>Unbound")); Controls.Add(new LiteralControl(" </td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl("</table>")); } else { if (FooterTemplate == null) { ITemplate defaultTemplate = new DefaulFooterTemplate(); defaultTemplate.InstantiateIn(this); } else { CustomTemplate footerTemplateItem = new CustomTemplate(); footerTemplateItem.ID = "footerTemplateItem"; FooterTemplate.InstantiateIn(footerTemplateItem); Controls.Add(new LiteralControl("<div>")); Controls.Add(footerTemplateItem); Controls.Add(new LiteralControl("</div>")); } } //end outer box Controls.Add(new LiteralControl(" </td>")); Controls.Add(new LiteralControl(" </tr>")); Controls.Add(new LiteralControl("</table>")); }
protected override void OnInit(EventArgs e) { base.OnInit(e); uxMessagePlaceHolder.Controls.Clear(); uxValidationSummaryPlaceHolder.Controls.Clear(); uxValidationDenotePlaceHolder.Controls.Clear(); uxLanguageControlPlaceHolder.Controls.Clear(); uxButtonEventPlaceHolder.Controls.Clear(); uxButtonCommandPlaceHolder.Controls.Clear(); uxTopContentBoxPlaceHolder.Controls.Clear(); uxFooterPlaceHolder.Controls.Clear(); uxFilterPlaceHolder.Controls.Clear(); uxPageNumberPlaceHolder.Controls.Clear(); uxGridPlaceHolder.Controls.Clear(); uxBottomContentBoxPlaceHolder.Controls.Clear(); uxContentPlaceHolder.Controls.Clear(); // Message. ContentContainer container = new ContentContainer(); if (MessageTemplate != null) { MessageTemplate.InstantiateIn(container); uxMessagePlaceHolder.Controls.Add(container); uxMessagePlaceHolder.Visible = true; } else { uxMessagePlaceHolder.Controls.Add(new LiteralControl("No Message Defined")); uxMessagePlaceHolder.Visible = false; } // Validation Summary container = new ContentContainer(); if (ValidationSummaryTemplate != null) { ValidationSummaryTemplate.InstantiateIn(container); uxValidationSummaryPlaceHolder.Controls.Add(container); uxValidationSummaryPanel.Visible = true; } else { uxValidationSummaryPlaceHolder.Controls.Add(new LiteralControl("No Validation Summary Defined")); uxValidationSummaryPanel.Visible = false; } // Validation Denotes container = new ContentContainer(); if (ValidationDenotesTemplate != null) { ValidationDenotesTemplate.InstantiateIn(container); uxValidationDenotePlaceHolder.Controls.Add(container); uxValidationDenotePanel.Visible = true; } else { uxValidationDenotePlaceHolder.Controls.Add(new LiteralControl("No Validation Denotes Defined")); uxValidationDenotePanel.Visible = false; } // If all message disapear message panel will not show. if (!uxMessagePlaceHolder.Visible & !uxValidationSummaryPanel.Visible & !uxValidationDenotePanel.Visible) { uxMessagePanel.Visible = false; } else { uxMessagePanel.Visible = true; } container = new ContentContainer(); if (LanguageControlTemplate != null) { LanguageControlTemplate.InstantiateIn(container); uxLanguageControlPlaceHolder.Controls.Add(container); uxLanguageControlPanel.Visible = true; } else { uxLanguageControlPlaceHolder.Controls.Add(new LiteralControl("No Language Control Defined")); uxLanguageControlPanel.Visible = false; } // If don't have any language and message top panel will not show. if (!uxMessagePanel.Visible & !uxLanguageControlPanel.Visible) { uxTopPagePanel.Visible = false; } else { uxTopPagePanel.Visible = true; } if (ButtonEventTemplate == null) { uxButtonEventPanel.Visible = false; } else { container = new ContentContainer(); ButtonEventTemplate.InstantiateIn(container); uxButtonEventPlaceHolder.Controls.Add(container); uxButtonEventPanel.Visible = true; } if (ButtonCommandTemplate == null) { uxButtonCommandPanel.Visible = false; } else { container = new ContentContainer(); ButtonCommandTemplate.InstantiateIn(container); uxButtonCommandPlaceHolder.Controls.Add(container); uxButtonCommandPanel.Visible = true; } container = new ContentContainer(); if (TopContentBoxTemplate != null) { TopContentBoxTemplate.InstantiateIn(container); uxTopContentBoxPlaceHolder.Controls.Add(container); uxTopContentBoxPlaceHolder.Visible = true; } else { uxTopContentBoxPlaceHolder.Controls.Add(new LiteralControl("No TopContentBox Content Defined")); uxTopContentBoxPlaceHolder.Visible = false; uxTopContentBoxPanel.Visible = false; } container = new ContentContainer(); if (ContentTemplate != null) { ContentTemplate.InstantiateIn(container); uxContentPlaceHolder.Controls.Add(container); uxContentPanel.Visible = true; } else { uxContentPlaceHolder.Controls.Add(new LiteralControl("No Template Defined")); uxContentPanel.Visible = false; } if (FilterTemplate == null) { uxFilterPanel.Visible = false; } else { container = new ContentContainer(); FilterTemplate.InstantiateIn(container); uxFilterPlaceHolder.Controls.Add(container); uxFilterPanel.Visible = true; } if (PageNumberTemplate == null) { uxPageNumberPanel.Visible = false; } else { container = new ContentContainer(); PageNumberTemplate.InstantiateIn(container); uxPageNumberPlaceHolder.Controls.Add(container); uxPageNumberPanel.Visible = true; } if (GridTemplate == null) { uxGridPanel.Visible = false; } else { container = new ContentContainer(); GridTemplate.InstantiateIn(container); uxGridPlaceHolder.Controls.Add(container); uxGridPanel.Visible = true; } if (uxGridPanel.Visible || uxPageNumberPanel.Visible || uxFilterPanel.Visible || uxTopContentBoxPlaceHolder.Visible) { uxTopContentBoxSet.Visible = true; } else { uxTopContentBoxSet.Visible = false; } if (BottomContentBoxTemplate == null) { uxBottomContentBoxPlaceHolder.Visible = false; uxBottomContentBoxPanel.Visible = false; } else { container = new ContentContainer(); BottomContentBoxTemplate.InstantiateIn(container); uxBottomContentBoxPlaceHolder.Controls.Add(container); uxBottomContentBoxPlaceHolder.Visible = true; } if (FooterTemplate != null) { container = new ContentContainer(); FooterTemplate.InstantiateIn(container); uxFooterPlaceHolder.Controls.Add(container); } uxBackToTopHyperLink.Visible = BackToTopLink; }