productreviewcontrol.ascx.vb
来自「C#语言制作asp.net网上商店的」· VB 代码 · 共 100 行
VB
100 行
Imports NetShopForge.Library.Product
Partial Class Shop_Product_Controls_ProductReviewControl
Inherits System.Web.UI.UserControl
Private Sub BindData()
Dim objPR As ProductReviewInfo = ProductReviewController.GetProductReview(hfProductID.Value, My.User.Name)
If IsNothing(objPR) Then
mvReview.ActiveViewIndex = 0
Else
lbFinishMessage.Text = "此件商品你已经评论过了。下面是你的评论信息。"
mvReview.ActiveViewIndex = 2
SetProductReview(objPR)
pReviewed.Visible = True
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
hfProductID.Value = NetShopForge.Common.Utility.GetParameter("pID")
Dim URL As String = String.Format("~/ProductDetail.aspx?pID={0}", hfProductID.Value)
NetShopForge.Common.UserAuthenticated(Page, URL)
If (Not Page.IsPostBack) Then
Dim ProductName As String = NetShopForge.Common.Utility.GetParameter("ProductName")
lbProductName.Text = HttpUtility.UrlDecode(ProductName)
hlBackProduct.NavigateUrl = String.Format("~/ProductDetail.aspx?pID={0}", hfProductID.Value)
pReviewed.Visible = False
BindData()
Else
End If
End Sub
Protected Sub btnReview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReview.Click
rvRating.DisplayValue = Rater1.Value
mvReview.ActiveViewIndex = 1
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click
mvReview.ActiveViewIndex = 0
End Sub
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
mvReview.ActiveViewIndex = 2
lbFinishMessage.Text = "你的评论已经取消。"
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
mvReview.ActiveViewIndex = 2
ProductReviewController.AddProductReview(GetProductReview())
lbFinishMessage.Text = "你的评论内容将在提交后的72小时之内被审核。感谢你的参与评论。"
End Sub
Private Sub SetProductReview(ByVal pr As ProductReviewInfo)
txtComments.Text = pr.Comments
txtLocation.Text = pr.Location
txtReviewer.Text = pr.ReviewerName
rvRating.DisplayValue = CDbl(pr.Rating)
Rater2.DisplayValue = CDbl(pr.Rating)
txtTitle.Text = pr.Title
rbComment.SelectedValue = IIf(pr.IsRecommend, -1, 0)
hfReviewDate.Value = String.Format("{0:f}", pr.ReviewDate)
End Sub
Private Function GetProductReview() As ProductReviewInfo
Dim pr As New ProductReviewInfo
pr.IsApproved = False
pr.IsRecommend = IIf(rbComment.SelectedValue = 0, False, True)
pr.Comments = txtComments.Text
pr.Location = txtLocation.Text
pr.ProductID = hfProductID.Value
pr.ReviewerName = txtReviewer.Text
pr.Rating = Rater1.Value
pr.Title = txtTitle.Text
pr.UserID = My.User.Name
Return pr
End Function
Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
mvReview.ActiveViewIndex = 2
lbFinishMessage.Text = "你的评论已经取消。"
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?