Beispiel #1
0
        protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
        {
            rating = e.Value.ToString();
            if (rating == null)
            {
                rating = "1";
            }
            AjaxControlToolkit.Rating _rating = (AjaxControlToolkit.Rating)sender;
            DataListItem item = (DataListItem)_rating.NamingContainer;

            if (item != null)
            {
                idd = (string)DataList1.DataKeys[item.ItemIndex];
            }
            SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

            scon.Open();
            String     chkpas = "******" + idd + "'";
            SqlCommand com2   = new SqlCommand(chkpas, scon);

            pname = com2.ExecuteScalar().ToString();
            String     query = "insert into [Table3](Id,Product_name,Rating) values('" + idd + "','" + pname + "'," + Convert.ToInt16(rating.ToString()) + ")";
            SqlCommand cmd   = new SqlCommand();

            cmd.CommandText = query;
            cmd.Connection  = scon;
            cmd.ExecuteNonQuery();
            System.Diagnostics.Debug.WriteLine(idd);
            scon.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Handles the ItemDataBound event of the dlCatalog control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs"/> instance containing the event data.</param>
        void dlCatalog_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Product product = e.Item.DataItem as Product;
                if (product == null)
                {
                    return;
                }
                HyperLink imageLink  = e.Item.FindControl("hlImageLink") as HyperLink;
                site      masterPage = this.Page.Master as site;
                if (imageLink != null && !string.IsNullOrEmpty(product.DefaultImagePath))
                {
                    imageLink.ImageUrl = ImageProcess.GetProductThumbnailUrl(product.DefaultImagePath);
                }

                Label retailPrice = e.Item.FindControl("lblRetailPrice") as Label;
                if (masterPage != null)
                {
                    if (masterPage.SiteSettings.DisplayRetailPrice && product.RetailPrice != 0)
                    {
                        if (retailPrice != null)
                        {
                            retailPrice.Text = StoreUtility.GetFormattedAmount(product.RetailPrice, true);
                        }
                    }
                    else
                    {
                        retailPrice.Visible = false;
                    }
                }
                Label ourPrice = e.Item.FindControl("lblOurPrice") as Label;
                if (ourPrice != null)
                {
                    ourPrice.Text = StoreUtility.GetFormattedAmount(product.DisplayPrice, true);
                }
                if (masterPage.SiteSettings.AddTaxToPrice && TaxService.GetDefaultTaxProvider().IsProductLevelTaxProvider)
                {
                    Label taxApplied = e.Item.FindControl("lblTaxApplied") as Label;
                    if (taxApplied != null)
                    {
                        taxApplied.Visible = true;
                    }
                }
                AjaxControlToolkit.Rating ajaxRating = e.Item.FindControl("ajaxRating") as AjaxControlToolkit.Rating;
                if (ajaxRating != null && masterPage.SiteSettings.DisplayRatings)
                {
                    ajaxRating.GroupingText  = LocalizationUtility.GetText("lblAverageRating");
                    ajaxRating.CurrentRating = product.Rating;
                }
                else
                {
                    ajaxRating.Visible = false;
                }
            }
        }
        protected void DropDownListRateValues_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.MessageAuthenticatedToVote();

            if (!this.User.Identity.IsAuthenticated)
            {
                return;
            }

            bool userHasVoutedAllready = this.CurrentUserHasVouted();

            if (userHasVoutedAllready)
            {
                // Update
                var    uR = this.GetUserRating(this.User.Identity.Name, this.Id);
                Rating userRatingToUpdate = uR.ToList <Rating>().FirstOrDefault(r => r.SupplementId == this.Id);
                userRatingToUpdate.Value = int.Parse(this.DropDownListRateValues.SelectedValue);

                this.RatingsServices.Update(userRatingToUpdate);
            }
            else
            {
                // Insert
                Rating newRating = new Rating();

                newRating.AuthorId     = this.User.Identity.GetUserId();
                newRating.SupplementId = this.Id;
                newRating.Value        = int.Parse(this.DropDownListRateValues.SelectedValue);

                this.RatingsServices.Add(newRating);
            }

            this.Ratings = this.GetSupplementRatings(this.Id).ToList();

            //if (nameTextBox != null)
            //{
            //    /* Do your stuff */
            //}
            // Source:
            // http://stackoverflow.com/questions/1126517/why-cant-i-reference-a-textbox-by-id-when-its-in-a-createuserwizard-control
            // https://msdn.microsoft.com/en-us/library/ms178342.aspx
            //ContentPlaceHolder cph = (ContentPlaceHolder)this.Master.FindControl("MainContent");
            //var label = (Label)cph.FindControl("Label1");


            Label labelTotalVotes = (Label)this.ListViewSupplementDetails.Items[0].FindControl("LabelTotalVotes") as Label;
            Label labelYourVote   = (Label)this.ListViewSupplementDetails.Items[0].FindControl("LabelYourVote") as Label;

            AjaxControlToolkit.Rating supplementRating = (AjaxControlToolkit.Rating) this.ListViewSupplementDetails.Items[0].FindControl("SupplementRating");

            // Update controls
            string avg      = this.GetAverageRatingValue().ToString();
            string userVote = this.GetCurrentUserVoteValue().ToString();

            this.DropDownListRateValues.SelectedValue = userVote;
            if (labelTotalVotes != null)
            {
                labelTotalVotes.Text = this.Ratings.Count.ToString();
            }
            if (labelYourVote != null)
            {
                labelYourVote.Text    = userVote;
                labelYourVote.Visible = (labelYourVote.Text != null);
            }
            if (supplementRating != null)
            {
                supplementRating.CurrentRating = int.Parse(avg);
            }
        }
Beispiel #4
0
        public void diplayStylists()
        {
            //Edits and reviews+ratings feature to be added
            try
            {
                sList = handler.aboutStylist();

                tblStylists.CssClass = "table table-light table-hover";

                int count = 0;
                foreach (SP_AboutStylist u in sList)
                {
                    TableRow row = new TableRow();
                    tblStylists.Rows.Add(row);
                    TableCell   uImage = new TableCell();
                    PlaceHolder img    = new PlaceHolder();
                    img.Controls.Add(new LiteralControl(
                                         "<img src=" + u.UserImage +
                                         " alt='Stylist Picture' class='img-fluid' " +
                                         "width='200' height='160' /><br/>"));
                    uImage.Width = 250;
                    PlaceHolder ph = new PlaceHolder();
                    try
                    {
                        AjaxControlToolkit.Rating theStars = new AjaxControlToolkit.Rating();

                        stylistRating = handler.getStylistRating(u.EmployeeID.ToString());

                        theStars.CurrentRating       = stylistRating.Rating;
                        theStars.ID                  = "rt" + u.StylistName.ToString();
                        theStars.StarCssClass        = "starRating";
                        theStars.WaitingStarCssClass = "waitingStar";
                        theStars.FilledStarCssClass  = "filledStar";
                        theStars.EmptyStarCssClass   = "emptyStar";
                        theStars.CssClass            = "img-fluid";
                        theStars.ReadOnly            = true;
                        ph.Controls.Add(theStars);
                    }
                    catch (Exception Err)
                    {
                        function.logAnError("Couldn't get star rating stylist.aspx err:" + Err.ToString());
                    }
                    uImage.Controls.Add(img);
                    uImage.Controls.Add(ph);
                    tblStylists.Rows[count].Cells.Add(uImage);

                    TableCell newCell = new TableCell();
                    newCell.CssClass = "img-fluid";
                    newCell.Text     = "<h4>"
                                       + u.StylistName.ToString() + "</h4>"
                                       + "<br/>"
                                       + "<h5>Specialisation: "
                                       + "<a href='ViewProduct.aspx?ProductID="
                                       + u.ServiceID.Replace(" ", string.Empty) + "' target='_blank'>"
                                       + u.Specialisation.ToString() + "</a></h5>"
                                       + "<br/>"
                                       + "<h5>Bio:</h5>"
                                       + "<p>" + u.Bio + "</p>";
                    newCell.Width = 600;
                    tblStylists.Rows[count].Cells.Add(newCell);
                    count++;
                }
            }
            catch (Exception E)
            {
                phStylistsErr.Visible = true;
                errorHeader.Text      = "Error displaying stylists.";
                errorMessage.Text     = "It seems there is a problem communicating with the database."
                                        + "Please report problem to admin or try again later.";
                function.logAnError(E.ToString());
            }
        }