public UserControlStatisticsTabCommodityRates()
 {
     InitializeComponent();
     this._commodityToCheck        = 0;
     this.CommodityRatesCollection = new SeriesCollection();
     PopulateChart(DatabaseSocket.getPriceOfCommByLastHour(_commodityToCheck));
 }
        private void comboBoxRange_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (this.comboBoxRange.SelectedIndex != -1)
                {
                    switch (((ComboBoxItem)this.comboBoxRange.SelectedItem).Content.ToString())
                    {
                    case "Between...":
                        this.buttonSearch.Visibility        = Visibility.Visible;
                        this.comboBoxInputNumber.Visibility = Visibility.Hidden;
                        this.DatePickerFrom.Visibility      = Visibility.Visible;
                        this.DatePickerTo.Visibility        = Visibility.Visible;
                        break;

                    case "Last ... trades":
                        this.buttonSearch.Visibility        = Visibility.Hidden;
                        this.comboBoxInputNumber.Visibility = Visibility.Visible;
                        this.DatePickerFrom.Visibility      = Visibility.Hidden;
                        this.DatePickerTo.Visibility        = Visibility.Hidden;
                        PopulateChart(DatabaseSocket.getMarketShare(5000));
                        break;

                    case "Last week":
                        this.buttonSearch.Visibility        = Visibility.Hidden;
                        this.comboBoxInputNumber.Visibility = Visibility.Hidden;
                        this.DatePickerFrom.Visibility      = Visibility.Hidden;
                        this.DatePickerTo.Visibility        = Visibility.Hidden;
                        PopulateChart(DatabaseSocket.GetMarketShareOfLastWeek());
                        break;

                    case "Last day":
                        this.buttonSearch.Visibility        = Visibility.Hidden;
                        this.comboBoxInputNumber.Visibility = Visibility.Hidden;
                        this.DatePickerFrom.Visibility      = Visibility.Hidden;
                        this.DatePickerTo.Visibility        = Visibility.Hidden;
                        PopulateChart(DatabaseSocket.GetMarketShareOfLastDay());
                        break;

                    case "Last hour":
                    default:
                        this.buttonSearch.Visibility        = Visibility.Hidden;
                        this.comboBoxInputNumber.Visibility = Visibility.Hidden;
                        this.DatePickerFrom.Visibility      = Visibility.Hidden;
                        this.DatePickerTo.Visibility        = Visibility.Hidden;
                        PopulateChart(DatabaseSocket.GetMarketShareOfLastHour());
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
 private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (this.comboBoxInputNumber.SelectedIndex != -1)
         {
             int n = Convert.ToInt32(((ComboBoxItem)this.comboBoxInputNumber.SelectedItem).Content.ToString());
             PopulateChart(DatabaseSocket.getMarketShare(n));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
        private void PopulateData(string TIME_WINDOW)
        {
            try
            {
                List <String> biggestPrice  = DatabaseSocket.GetHighlightsBiggestPrice(TIME_WINDOW);
                List <String> mostSoldComm  = DatabaseSocket.GetHighlightsMostSoldComm(TIME_WINDOW);
                List <String> leastSoldComm = DatabaseSocket.GetHighlightsLeastSoldComm(TIME_WINDOW);
                List <String> bestSale      = DatabaseSocket.GetHighlightsBestSale(TIME_WINDOW);
                List <String> worstSale     = DatabaseSocket.GetHighlightsWorstSale(TIME_WINDOW);

                this.labelBiggestPrice.Content  = "Biggest price: " + biggestPrice[0] + " of commodity " + biggestPrice[1] + " at " + biggestPrice[2];
                this.labelMostSoldComm.Content  = "Most sold commodity: " + mostSoldComm[0] + " with " + mostSoldComm[1] + " sold";
                this.labelLeastSoldComm.Content = "Least sold commodity: " + leastSoldComm[0] + " with " + leastSoldComm[1] + " sold";
                this.labelBestSale.Content      = "Best sale: " + bestSale[0] + "$ (Amount: " + bestSale[1] + ", Price: " + bestSale[2] + "), of commodity " + bestSale[3];
                this.labelWorstSale.Content     = "Worst sale: " + worstSale[0] + "$ (Amount: " + worstSale[1] + ", Price: " + worstSale[2] + "), of commodity " + worstSale[3];
            }
            catch
            {
            }
        }
 private void buttonSearch_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DateTime?from = this.DatePickerFrom.SelectedDate;
         DateTime?to   = this.DatePickerTo.SelectedDate;
         if (!from.HasValue || !to.HasValue)
         {
             throw new ArgumentException();
         }
         if (from.Value.CompareTo(to.Value) < 0)
         {
             PopulateChart(DatabaseSocket.getMarketShareBetweenDates(from.Value, to.Value));
         }
         else
         {
             throw new ArgumentException();
         }
     }
     catch
     {
         MessageBox.Show("Please pick dates where the left one is earlier than the right one.", "Illegal Input!");
     }
 }
 public UserControlStatisticsTabMarketShare()
 {
     InitializeComponent();
     this.MarketShareCollection = new SeriesCollection();
     PopulateChart(DatabaseSocket.GetMarketShareOfLastHour());
 }