//******************************************************* // // The Page_Load event on this user control is used to obtain // from a database a list of reviews about a specified // product and then databind it to an asp:datalist control. // //******************************************************* protected void Page_Load(object sender, EventArgs e) { // Obtain and databind a list of all reviews of a product // Obtain ProductID from Page State _nav = new CatalogNavigation(Request.QueryString); ReviewController controller = new ReviewController(); lstReviews.DataSource = controller.GetReviewsByProduct(PortalId, _nav.ProductID, ReviewController.StatusFilter.Approved); lstReviews.DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { _nav = new AdminNavigation(Request.QueryString); try { // Get the Review ID ReviewInfo review = new ReviewInfo(); if (!Page.IsPostBack) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); if (!Null.IsNull(_nav.ReviewID)) { ReviewController controller = new ReviewController(); review = controller.GetReview(_nav.ReviewID); if (review != null) { cmdDelete.Visible = true; txtUserName.Text = review.UserName; cmbRating.SelectedValue = review.Rating.ToString(); txtComments.Text = review.Comments; chkAuthorized.Checked = review.Authorized; } } plhRating.Controls.Clear(); plhRating.Controls.Add(GetRatingImages(int.Parse(cmbRating.SelectedValue))); } // Which controls do we display? if (string.Compare(_nav.PageID, "ReviewAdmin", true) == 0) { txtUserName.Enabled = false; cmbRating.Enabled = false; labelAuthorized.Visible = true; chkAuthorized.Visible = true; } } catch(Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void cmdUpdate_Click(object sender, EventArgs e) { try { if (Page.IsValid == true) { PortalSecurity security = new PortalSecurity(); ReviewInfo review = new ReviewInfo(); review = ((ReviewInfo)CBO.InitializeObject(review, typeof(ReviewInfo))); review.ReviewID = _nav.ReviewID; review.PortalID = this.PortalId; review.ProductID = _nav.ProductID; //review.UserID = this.UserId; review.UserName = security.InputFilter(txtUserName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);; review.Rating = int.Parse(cmbRating.SelectedValue); review.Comments = security.InputFilter(txtComments.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);; review.Authorized = chkAuthorized.Checked; review.CreatedDate = DateTime.Now; ReviewController controller = new ReviewController(); if (_nav.ReviewID == 0) { controller.AddReview(review); } else { controller.UpdateReview(review); } invokeEditComplete(); } } catch(Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(_nav.ReviewID)) { ReviewController controller = new ReviewController(); controller.DeleteReview(_nav.ReviewID); _nav.ReviewID = Null.NullInteger; } invokeEditComplete(); } catch(Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void FillReviewGrid() { panelList.Visible = true; panelEdit.Visible = false; grdReviews.DataSource = null; // Get the status filter ReviewController.StatusFilter filter = ReviewController.StatusFilter.All; if (cmbStatus.SelectedValue == "0") { filter = ReviewController.StatusFilter.NotApproved; } else if (cmbStatus.SelectedValue == "1") { filter = ReviewController.StatusFilter.Approved; } // Get the product list... ArrayList reviewList; ReviewController controller = new ReviewController(); if (cmbProduct.SelectedValue != Null.NullInteger.ToString()) { // Select by product reviewList = controller.GetReviewsByProduct(this.PortalId, int.Parse(cmbProduct.SelectedValue), filter); } else if (cmbCategory.SelectedValue != Null.NullInteger.ToString()) { // Select by category reviewList = controller.GetReviewsByCategory(this.PortalId, int.Parse(cmbCategory.SelectedValue), filter); } else { // Select all reviews reviewList = controller.GetReviews(this.PortalId, filter); } // Has page index been initialized? if (_nav.PageIndex == Null.NullInteger) { _nav.PageIndex = 0; } // Update the grid grdReviews.PageSize = 20; grdReviews.AllowPaging = true; grdReviews.DataSource = reviewList; grdReviews.CurrentPageIndex = _nav.PageIndex; grdReviews.DataBind(); }