Ejemplo n.º 1
0
        public PageAdmin()
        {
            InitializeComponent();
            //ngay thang nam
            fromDatePicker.Date = new DateTime(2021, 1, 1).Date;
            toDatePicker.Date   = new DateTime(2021, 12, 31).Date;

            data = new List <Tuple <int, decimal> >();
            data = QueryForSQLServer.GetTotalByMonth(2021);

            var dataSeller = QueryForSQLServer.GetListBestSellerPurchases();

            //string []Labels = new []{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul","Aug","Sep","Oct","Nov","Dec" };
            ////LineChartViewX.DataContext = Labels;
            //PieChartView.Series = new SeriesCollection();

            //foreach (var item in data)
            //{
            //    if (item.Item2 != 0)
            //        PieChartView.Series.Add(
            //        new PieSeries()
            //        {
            //            Values = new ChartValues<decimal> { item.Item2 },
            //            Title = item.Item1.ToString(),
            //            DataLabels = true,

            //        }
            //    ) ;
            //}
            //PieChartView.LegendLocation = LegendLocation.Bottom;
            //PieChartView.DataContext = this;

            var productdt = QueryForSQLServer.GetProductFromDBTwo();

            DataGridProduct.ItemsSource = productdt;

            //PieChartView.Series = new SeriesCollection();

            foreach (var item in dataSeller)
            {
                ColumChartView.Series.Add(
                    new ColumnSeries()
                {
                    Values = new ChartValues <decimal> {
                        item.Item2
                    },
                    Title      = item.Item1.ToString(),
                    DataLabels = true,
                }
                    );
            }

            ColumChartView.LegendLocation = LegendLocation.Bottom;
            ColumChartView.DataContext    = this;

            //var linedata = new List<decimal>();
            //foreach(var item in data)
            //{
            //    linedata.Add(item.Item2);
            //}
            //LineChartView.Series.Add(
            //    new LineSeries()

            //    {
            //        Values = new ChartValues<decimal> { linedata[0] },
            //        Title = "Doanh thu theo năm",
            //        LineSmoothness = 0, //0: straight lines, 1: really smooth lines
            //        DataLabels = true,


            //    }
            //);
            //for (int i = 1; i < linedata.Count(); i++)
            //{
            //    LineChartView.Series[0].Values.Add(linedata[i]);
            //}
            //LineChartView.LegendLocation = LegendLocation.Bottom;
            //LineChartView.AxisX.Add(
            //    new Axis
            //    {
            //        MinValue = 0,
            //        Labels = Labels
            //    }
            //    );
            //LineChartView.AxisY.Add(
            //    new Axis
            //    {
            //        MinValue = 0,
            //    }
            //    );
            //LineChartView.DataContext = this;
        }