bonusescontrol.ascx.vb
来自「C#语言制作asp.net网上商店的」· VB 代码 · 共 394 行 · 第 1/2 页
VB
394 行
Imports NetShopForge.Library.SpecialOffer
Imports NetShopForge.Library.Product
Imports System
Imports System.Collections.Generic
Partial Class Admin_Merchandising_Controls_BonusesControl
Inherits System.Web.UI.UserControl
' Public SpecailOffer As SpecialOffer.SpecialOfferInfo
Private Const GIVEDISCOUNT As String = "打折"
Private Const SPECIALPRICE As String = "特价或免费商品"
Private Const OFFERFREESHIPPING As String = "免费送货"
Private Const GIVEBONUSPOINT As String = "奖励积分"
Private Const OFFERMEMBErShip As String = ""
Private Const GIVECOUPON As String = ""
Private Const INCOMPLETE As String = "未完成"
Public Property BonusType() As BonusType
Get
Return rblBonuses.SelectedValue
End Get
Set(ByVal value As BonusType)
rblBonuses.SelectedValue = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim offerID As String = Request("offerid")
If IsNothing(offerID) Then My.Response.Redirect("~/Admin/Merchandising/Offers.aspx")
hfOfferID.Value = offerID
Dim so As SpecialOfferInfo
so = SpecialOfferController.GetSpecialOffer(hfOfferID.Value)
SpecialOfferNavControl1.Enabled = (so.Status <> SpecialOfferStatus.Incomplete)
BonusType = so.BonusType
BindData()
NetShopForge.Library.Category.CategoryTree.Instance.SetCategoryList(ddlCategory, "")
End If
End Sub
Protected Sub rblBonuses_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblBonuses.SelectedIndexChanged
'mvConditions.ActiveViewIndex = rblBonuses.SelectedValue
pChooseProducts.Visible = (CInt(rblBonuses.SelectedValue) < 3)
' rblProductCategory.Visible = CInt(rblBonuses.SelectedValue) <> 1
Dim objSPC As New SpecialOfferController
objSPC.UpdateSpecailOfferType(CInt(hfOfferID.Value), "B", CInt(rblBonuses.SelectedValue))
BindData()
End Sub
Protected Sub ChooseProductsControl1_ProductSelected1(ByVal selectedProducts As System.Collections.Generic.List(Of NetShopForge.Library.Product.ProductSelectedInfo)) Handles ChooseProductsControl1.ProductSelected
Dim objSPC As New SpecialOfferController
Dim offerID As Integer = CInt(hfOfferID.Value)
Dim ps As ProductSelectedInfo
Select Case BonusType
Case BonusType.GiveDiscount
For Each ps In selectedProducts
Dim Product As New SpecialOfferProductsInfo
Product.OfferID = offerID
Product.ProductID = ps.ProductID
Product.Quantity = 0
Product.CategoryID = 0
Product.Type = "B"
Product.Type2 = BonusType
objSPC.AddSpecialOfferProducts(Product)
Next
Case BonusType.OfferFreeShipping
For Each ps In selectedProducts
Dim Product As New SpecialOfferProductsInfo
Product.OfferID = offerID
Product.ProductID = ps.ProductID
Product.Quantity = 0
Product.CategoryID = 0
Product.Type = "B"
Product.Type2 = BonusType
objSPC.AddSpecialOfferProducts(Product)
Next
Case BonusType.SpecialPrice
For Each ps In selectedProducts
Dim Product As New SpecialOfferBonusPriceInfo
Product.OfferID = offerID
Product.ProductID = ps.ProductID
Product.ProductName = ps.productName
Product.Price = ps.Price
Product.AdjustPrice = ps.Price
objSPC.AddSpecailOffersBonusPrice(Product)
Next
End Select
BindData()
End Sub
Protected Sub btnAddCategory_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddCategory.Click
Dim offerID As Integer = CInt(hfOfferID.Value)
Dim objSPC As New SpecialOfferController
Dim Product As New SpecialOfferProductsInfo
Dim objSOP As New SpecialOfferProductsInfo
Product.OfferID = offerID
Product.ProductID = 0
Product.Quantity = 0
Product.CategoryID = ddlCategory.SelectedValue
Product.Type = "B"
Product.Type2 = BonusType
' objSOP.CategoryName = ddlCategoryList.CategoryName
objSPC.AddSpecialOfferProducts(Product)
Select Case BonusType
Case BonusType.GiveDiscount
BindDiscountProducts()
Case BonusType.OfferFreeShipping
BindFreeShippingProducts()
End Select
End Sub
Protected Sub btnDeleteProducts_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeleteDiscountProducts.Click
Dim objSPC As New SpecialOfferController
For Each row As GridViewRow In gvDiscountProducts.Rows
Dim cbSelect As CheckBox = CType(row.Cells(0).FindControl("cbSelect"), CheckBox)
If cbSelect.Checked Then
Dim hfCategoryID As HiddenField = CType(row.FindControl("hfCategoryID"), HiddenField)
Dim hfProductID As HiddenField = CType(row.FindControl("hfProductID"), HiddenField)
objSPC.DeleteSpecialOfferProducts(hfOfferID.Value, hfProductID.Value, hfCategoryID.Value, "B", BonusType)
End If
Next
BindData()
End Sub
Protected Sub btnDeleteFreeShipping_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeleteFreeShipping.Click
Dim objSPC As New SpecialOfferController
For Each row As GridViewRow In gvFreeShippingProducts.Rows
Dim cbSelect As CheckBox = CType(row.Cells(0).FindControl("cbSelect"), CheckBox)
If cbSelect.Checked Then
Dim hfCategoryID As HiddenField = CType(row.FindControl("hfCategoryID"), HiddenField)
Dim hfProductID As HiddenField = CType(row.FindControl("hfProductID"), HiddenField)
objSPC.DeleteSpecialOfferProducts(hfOfferID.Value, hfProductID.Value, hfCategoryID.Value, "B", BonusType)
End If
Next
BindData()
End Sub
Protected Sub btnDeleteSpecialPrice_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeleteSpecialPrice.Click
Dim objSPC As New SpecialOfferController
For Each row As GridViewRow In gvSpecailPriceProducts.Rows
Dim cbSelect As CheckBox = CType(row.FindControl("cbSelect"), CheckBox)
If cbSelect.Checked Then
Dim hfProductID As HiddenField = CType(row.FindControl("hfProductID"), HiddenField)
objSPC.DeleteSpecailOffersBonusPrice(hfOfferID.Value, hfProductID.Value)
End If
Next
BindData()
End Sub
Protected Sub gvCertainProducts_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvDiscountProducts.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbProductName As Label = CType(e.Row.FindControl("lbProductName"), Label)
Dim lbCategoryName As Label = CType(e.Row.FindControl("lbCategoryName"), Label)
If lbCategoryName.Text.Length > 0 Then
lbCategoryName.Visible = True
lbProductName.Visible = False
lbCategoryName.Text = String.Format("[类别中的所有商品]{0}", lbCategoryName.Text)
Else
lbCategoryName.Visible = False
lbProductName.Visible = True
lbProductName.Text = String.Format("[商品]{0}", lbProductName.Text)
End If
End If
End Sub
Protected Sub gvFreeShippingProducts_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvFreeShippingProducts.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbProductName As Label = CType(e.Row.FindControl("lbProductName"), Label)
Dim lbCategoryName As Label = CType(e.Row.FindControl("lbCategoryName"), Label)
If lbCategoryName.Text.Length > 0 Then
lbCategoryName.Visible = True
lbProductName.Visible = False
lbCategoryName.Text = String.Format("[类别中的所有商品]{0}", lbCategoryName.Text)
Else
lbCategoryName.Visible = False
lbProductName.Visible = True
lbProductName.Text = String.Format("[商品]{0}", lbProductName.Text)
End If
End If
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?