Imports BVSoftware.BVC.Core Public Class Products_ProductChoices_EditItem 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 btnCancel As System.Web.UI.WebControls.ImageButton Protected WithEvents btnOK As System.Web.UI.WebControls.ImageButton Protected WithEvents DisplayTextField As System.Web.UI.WebControls.TextBox Protected WithEvents DisplayValueField As System.Web.UI.WebControls.TextBox Protected WithEvents PriceAdjustmentField As System.Web.UI.WebControls.TextBox Protected WithEvents CostAdjustmentField As System.Web.UI.WebControls.TextBox Protected WithEvents chkSelected As System.Web.UI.WebControls.CheckBox Protected WithEvents ImageURLField As System.Web.UI.WebControls.TextBox Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents WeightAdjustmentField As System.Web.UI.WebControls.TextBox Protected WithEvents ShippingCostAdjustmentField As System.Web.UI.WebControls.TextBox Protected WithEvents chkNullItem As System.Web.UI.WebControls.CheckBox Protected WithEvents trPriceAdjustment As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents trCostAdjustment As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents trWeightAdjustment As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents trShipCost As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents trSKU As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents lblValue As System.Web.UI.WebControls.Label Protected WithEvents btnSelect As System.Web.UI.WebControls.ImageButton Protected WithEvents QuantityField 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 Protected WithEvents ProductPicker1 As ProductPicker Private pci As Catalog.ProductChoiceItem 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 If Not Request.Params("ID") Is Nothing Then ViewState("ID") = Request.Params("ID") Else ViewState("ID") = 0 End If If Not Request.Params("CID") Is Nothing Then ViewState("ChoiceID") = Request.Params("CID") Else ViewState("ChoiceID") = "0" End If If Not Request.Params("DOC") Is Nothing Then ViewState("DeleteOnCancel") = Request.Params("DOC") Else ViewState("DeleteOnCancel") = 0 End If If Not Request.Params("RTP") Is Nothing Then ViewState("ProductID") = Request.Params("RTP") Else ViewState("ProductID") = "0" End If End If pci = CatalogServices.ProductChoicesItems.GetProductChoiceItem(ViewState("ID")) If Not Page.IsPostBack Then LoadItem() End If End Sub Private Sub LoadItem() If Not pci Is Nothing Then Me.DisplayTextField.Text = pci.DisplayText Me.DisplayValueField.Text = pci.DisplayValue Me.chkSelected.Checked = pci.Selected Me.ImageURLField.Text = pci.ImageURL Me.PriceAdjustmentField.Text = pci.PriceAdjustment Me.CostAdjustmentField.Text = pci.CostAdjustment Me.ShippingCostAdjustmentField.Text = pci.ShippingCostAdjustment Me.WeightAdjustmentField.Text = pci.WeightAdjustment Me.chkNullItem.Checked = pci.NullItem Dim c As New Catalog.ProductChoice c = CatalogServices.ProductChoices.GetProductChoice(pci.ChoiceID) If Not c Is Nothing Then Select Case c.TypeCode Case Catalog.ProductChoiceType.AccessoryCheckBox, Catalog.ProductChoiceType.AccessoryDropdownList, Catalog.ProductChoiceType.AccessoryRadioButtonList Me.trShipCost.Visible = False Me.trPriceAdjustment.Visible = False Me.trCostAdjustment.Visible = False Me.trWeightAdjustment.Visible = False Me.trSKU.Visible = True Me.lblValue.Text = "Accessory Product SKU" Me.QuantityField.Text = pci.PriceAdjustment If Convert.ToInt32(Me.QuantityField.Text) < 1 Then Me.QuantityField.Text = 1 End If Case Else Me.trShipCost.Visible = True Me.trPriceAdjustment.Visible = True Me.trCostAdjustment.Visible = True Me.trWeightAdjustment.Visible = True Me.trSKU.Visible = False Me.lblValue.Text = "Value" End Select End If End If End Sub Private Function SaveSettings() As Boolean Dim result As Boolean = False If ViewState("ID") > 0 Then If Not pci Is Nothing Then pci.DisplayText = Me.DisplayTextField.Text.Trim pci.DisplayValue = Me.DisplayValueField.Text.Trim pci.Selected = Me.chkSelected.Checked pci.ImageURL = Me.ImageURLField.Text.Trim pci.PriceAdjustment = Me.PriceAdjustmentField.Text.Trim pci.CostAdjustment = Me.CostAdjustmentField.Text.Trim pci.ShippingCostAdjustment = Me.ShippingCostAdjustmentField.Text.Trim pci.WeightAdjustment = Me.WeightAdjustmentField.Text.Trim pci.NullItem = Me.chkNullItem.Checked If Me.trSKU.Visible = True Then pci.PriceAdjustment = Me.QuantityField.Text End If result = CatalogServices.ProductChoicesItems.Update(pci) End If End If Return result End Function Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCancel.Click msg.Clear() If ViewState("DeleteOnCancel") = 1 Then CatalogServices.ProductChoicesItems.Delete(ViewState("ID")) End If RedirectOnComplete() End Sub Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOK.Click msg.Clear() If SaveSettings() = True Then RedirectOnComplete() End If End Sub Private Sub RedirectOnComplete() If ViewState("ProductID") <> "0" Then Response.Redirect("Products_ProductChoices_Edit.aspx?ID=" & ViewState("ChoiceID") & "&RTP=" & Server.UrlEncode(ViewState("ProductID"))) Else Response.Redirect("Products_ProductChoices_Edit.aspx?ID=" & ViewState("ChoiceID")) End If End Sub Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSelect.Click If Me.ProductPicker1.SelectedProducts.Count > 0 Then Me.DisplayValueField.Text = Me.ProductPicker1.SelectedProducts(0) End If End Sub End Class