示例#1
0
        public void loadTop()
        {
            try
            {
                MySqlDataAdapter sda  = pos.loadChartTopSell(dateTimePicker1.Value.ToString("yyyy-MM-dd"), dateTimePicker2.Value.ToString("yyyy-MM-dd"), topSalesSorting.Text);
                DataSet          data = new DataSet();
                sda.Fill(data, "TOPSALES");
                chart1.DataSource = data.Tables["TOPSALES"];
                Series series = chart1.Series[0];
                series.LabelForeColor = Color.White;
                series.ChartType      = SeriesChartType.Doughnut;

                series.Name = "TOP SELLING";
                var chart = chart1;
                chart1.Series[0].XValueMember = "description";
                if (topSalesSorting.Text == "SORT BY QTY")
                {
                    chart1.Series[0].YValueMembers = "quantity";
                }
                else
                {
                    chart1.Series[0].YValueMembers = "total";
                }

                chart.Series[0].IsValueShownAsLabel = true;
                if (topSalesSorting.Text == "SORT BY QTY")
                {
                    chart.Series[0].LabelFormat = "{#,##0}";
                }
                else
                {
                    chart.Series[0].LabelFormat = "{#,##0.00}";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }