Ejemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     currentset = Convert.ToInt32((sender as Button).Uid);
     for (int i = 1; i <= currentset; i++)
     {
         PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
         if (currentset == 1)
         {
             z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFF4500"));
         }
         else if (currentset == 2)
         {
             z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFA500"));
         }
         else if (currentset == 3)
         {
             z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9ACD32"));
         }
         else if (currentset == 4)
         {
             z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF228B22"));
         }
         else if (currentset == 5)
         {
             z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF32CD32"));
         }
     }
 }
Ejemplo n.º 2
0
        private void Button_MouseLeave(object sender, MouseEventArgs e)
        {
            for (int i = 1; i <= currentset; i++)
            {
                PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
                if (currentset == 1)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFF4500"));
                }
                else if (currentset == 2)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFA500"));
                }
                else if (currentset == 3)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9ACD32"));
                }
                else if (currentset == 4)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF228B22"));
                }
                else if (currentset == 5)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF32CD32"));
                }
            }

            for (int i = currentset + 1; i <= 5; i++)
            {
                PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
                z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF44404D"));
            }
        }
Ejemplo n.º 3
0
        private void Button_MouseEnter(object sender, MouseEventArgs e)
        {
            var x = Convert.ToInt32((sender as Button).Uid);

            for (int i = 1; i <= x; i++)
            {
                PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
                if (x == 1)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFF4500"));
                }
                else if (x == 2)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFA500"));
                }
                else if (x == 3)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9ACD32"));
                }
                else if (x == 4)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF228B22"));
                }
                else if (x == 5)
                {
                    z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF32CD32"));
                }
            }

            for (int i = x + 1; i <= 5; i++)
            {
                PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
                z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF44404D"));
            }
        }
Ejemplo n.º 4
0
        private void SendRateBtn_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                using (SqlConnection con2 = new SqlConnection(ConnectionString))
                {
                    con2.Open();
                    string     CmdString = "insert into Rating(username, book_id, value, comment)values('" + username + "'," + book.Id + "," + currentset + ",'" + Comment.Text + "')";
                    SqlCommand cmd2      = new SqlCommand(CmdString, con2);
                    cmd2.ExecuteNonQuery();
                    AddComOk.IsOpen = true;
                    CommentPanel.Children.Add(new CommentItem(username, Comment.Text, currentset));
                    Comment.Text = "";
                    for (int i = 1; i <= 5; i++)
                    {
                        PackIcon z = Dev.FindChild <PackIcon>(THIS, "Icon_" + Convert.ToString(i));
                        z.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF44404D"));
                    }
                }
            }
            catch (Exception)
            {
                AddComFail.IsOpen = true;
            }
            try
            {
                using (SqlConnection con = new SqlConnection(ConnectionString))
                {
                    con.Open();
                    string     CmdString = "select AVG(value) from Rating where book_id =" + book.Id;
                    SqlCommand cmd       = new SqlCommand(CmdString, con);
                    string     value     = cmd.ExecuteScalar().ToString();
                    if (value.Length > 3)
                    {
                        value = value.Substring(0, 3);
                    }
                    RateBlock.Text = value;
                }

                using (SqlConnection con = new SqlConnection(ConnectionString))
                {
                    con.Open();
                    string Cmd = "SELECT (select COUNT(*) from Rating where book_id = " + book.Id + " and value = 1)[1],"
                                 + "(select COUNT(*) from Rating where book_id = " + book.Id + " and value = 2)[2],"
                                 + "(select COUNT(*) from Rating where book_id = " + book.Id + " and value = 3)[3],"
                                 + "(select COUNT(*) from Rating where book_id = " + book.Id + " and value = 4)[4],"
                                 + "(select COUNT(*) from Rating where book_id = " + book.Id + " and value = 5)[5],"
                                 + "(select COUNT(*) from Rating where book_id = " + book.Id + ")[count]";
                    SqlCommand    command = new SqlCommand(Cmd, con);
                    SqlDataReader reader  = command.ExecuteReader();
                    if (reader.HasRows) // если есть данные
                    {
                        reader.Read();
                        Rating rating = new Rating(Convert.ToInt32(reader.GetValue(0)), Convert.ToInt32(reader.GetValue(1)), Convert.ToInt32(reader.GetValue(2)), Convert.ToInt32(reader.GetValue(3)), Convert.ToInt32(reader.GetValue(4)), Convert.ToInt32(reader.GetValue(5)));
                        if (rating.total == 0)
                        {
                            Five.Width = Four.Width = Three.Width = Two.Width = One.Width = 0;
                        }
                        else
                        {
                            int[]  array  = new int[] { rating.five, rating.four, rating.three, rating.two, rating.one };
                            int[]  sorted = (from element in array orderby element ascending select element).ToArray();
                            double part   = 175 / (double)sorted[4];
                            Five.Width  = (double)rating.five * part;
                            Four.Width  = (double)rating.four * part;
                            Three.Width = (double)rating.three * part;
                            Two.Width   = (double)rating.two * part;
                            One.Width   = (double)rating.one * part;
                        }
                    }
                    reader.Close();
                    if (NoRatesPanel.Visibility == Visibility.Visible)
                    {
                        NoRatesPanel.Visibility = Visibility.Collapsed;
                        RatesPanel.Visibility   = Visibility.Visible;
                    }
                }
            }
            catch (Exception err)
            {
                NoRatesPanel.Visibility = Visibility.Visible;
                RatesPanel.Visibility   = Visibility.Collapsed;
            }
        }