Imports BVSoftware.BVC.Core Public Class Products_ProductChoices Inherits BaseAdminPage #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents btnNew As System.Web.UI.WebControls.ImageButton Protected WithEvents lstChoiceType As System.Web.UI.WebControls.DropDownList Protected WithEvents btnEdit As System.Web.UI.WebControls.ImageButton Protected WithEvents btnDelete As System.Web.UI.WebControls.ImageButton Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents dgChoices As System.Web.UI.WebControls.DataGrid Protected WithEvents btnClone As System.Web.UI.WebControls.ImageButton Protected WithEvents CloneIDField As System.Web.UI.WebControls.TextBox 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessProductArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription FillList() End If End Sub Private Sub FillList() Dim dtShared As DataTable = CatalogServices.ProductChoices.GetAllShared If Not dtShared Is Nothing Then dtShared.Columns.Add("TypeCodeName", System.Type.GetType("System.String")) Dim prefix As String = "" For i As Integer = 0 To dtShared.Rows.Count - 1 prefix = "?" Select Case dtShared.Rows(i).Item("TypeCode") Case 1 prefix = "Text Input" Case 2 prefix = "Drop Down List" Case 8 prefix = "Radio Button List" Case 9 prefix = "HTML Area" Case 21 prefix = "Accessory Checkbox" Case 22 prefix = "Accessory Radio Button List" Case 23 prefix = "Accessory Drop Down List" Case Else prefix = "?" End Select dtShared.Rows(i).Item("TypeCodeName") = prefix Next Me.dgChoices.DataSource = dtShared Me.dgChoices.DataBind() End If dtShared = Nothing End Sub Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnNew.Click Dim pc As New Catalog.ProductChoice pc.IsShared = True pc.DisplayName = "New Shared Choice" Select Case Me.lstChoiceType.SelectedValue Case 1 pc.PropertyName = "New Text Input" pc.TypeCode = Catalog.ProductChoiceType.TextField pc.TextColumns = 20 Case 2 pc.PropertyName = "New Drop Down List" pc.TypeCode = Catalog.ProductChoiceType.MultipleChoiceField pc.TextColumns = 1 Case 8 pc.PropertyName = "New Radio Button List" pc.TypeCode = Catalog.ProductChoiceType.RadioButtonList pc.TextColumns = 1 Case 9 pc.PropertyName = "New HTML Area" pc.TypeCode = Catalog.ProductChoiceType.HtmlArea pc.TextColumns = 1 Case 21 ' Accessory Checkbox pc.PropertyName = "New Accessory Checkbox" pc.TypeCode = Catalog.ProductChoiceType.AccessoryCheckBox pc.TextColumns = 1 Case 22 ' Accessory Radio Button List pc.PropertyName = "New Accessory Radio Button List" pc.TypeCode = Catalog.ProductChoiceType.AccessoryRadioButtonList pc.TextColumns = 1 Case 23 ' Accessory Dropdown List pc.PropertyName = "New Accessory Dropdown List" pc.TypeCode = Catalog.ProductChoiceType.AccessoryDropdownList pc.TextColumns = 1 Case Else pc.PropertyName = "New Text Input" pc.TypeCode = Catalog.ProductChoiceType.TextField pc.TextColumns = 20 End Select pc.TextRows = 1 pc.TextWrap = True If CatalogServices.ProductChoices.CreateNew(pc) = True Then Response.Redirect("Products_ProductChoices_Edit.aspx?id=" & pc.ID & "&DOC=1") Else msg.ShowError("Couldn't Create New Choice!") Trace.Write("Coudn't Create New Property!") End If End Sub Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnEdit.Click msg.Clear() Dim selected As ArrayList = GetSelectedChoices() If selected.Count < 1 Then msg.ShowWarning("Please select an item first.") Else Response.Redirect("Products_ProductChoices_edit.aspx?id=" & selected(0)) End If End Sub Private Function GetSelectedChoices() As ArrayList Dim result As New ArrayList Dim rsc As MetaBuilders.WebControls.RowSelectorColumn = dgChoices.Columns(0) For Each i As Integer In rsc.SelectedIndexes() result.Add(dgChoices.DataKeys(i)) Next Return result End Function Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDelete.Click Dim selected As ArrayList = GetSelectedChoices() For i As Integer = 0 To selected.Count - 1 Try CatalogServices.ProductChoices.Delete(selected(i)) Catch ex As Exception EventLog.LogEvent(ex) End Try Next FillList() End Sub Private Sub btnClone_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnClone.Click Dim selected As ArrayList = GetSelectedChoices() If selected.Count < 1 Then msg.ShowWarning("Please select a choice to clone first.") Else If Me.CloneIDField.Text.Trim.Length < 1 Then msg.ShowWarning("Please enter a new choice name to clone a choice") Else If CatalogServices.ProductChoices.Clone(Me.CloneIDField.Text.Trim, selected(0)) = True Then msg.ShowOK("Choice Cloned") Else msg.ShowError("Error while cloning!") End If End If End If FillList() End Sub End Class