示例#1
0
        private ChartJumlahObat GetChartJumlahObat(string sp)
        {
            ChartJumlahObat chartJumlahObat = new ChartJumlahObat();

            SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

            connection.Open();
            SqlCommand cmd = new SqlCommand(sp, connection);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader RDR = cmd.ExecuteReader();

            while (RDR.Read())
            {
                chartJumlahObat.jumlah.Add(Convert.ToInt32(RDR["jumlah"]));
                chartJumlahObat.bulan.Add(RDR["bulan"].ToString());
            }
            connection.Close();

            return(chartJumlahObat);
        }
示例#2
0
        private void refreshGrafikJumlahObat()
        {
            ChartJumlahObat chartPenjualan = GetChartJumlahObat("sp_chartPenjualan");
            ChartJumlahObat chartPembelian = GetChartJumlahObat("sp_chartPembelian");

            CartesianChart ch = new CartesianChart();

            ch.Foreground = new SolidColorBrush(Colors.Black);
            ch.Series     = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Penjualan",
                    Values = new ChartValues <int>(chartPenjualan.jumlah)
                },
                new ColumnSeries
                {
                    Title  = "Pembelian",
                    Values = new ChartValues <int>(chartPembelian.jumlah)
                }
            };

            ch.AxisX.Add(new Axis
            {
                Title     = "Bulan",
                Labels    = chartPenjualan.bulan,
                Separator = new Separator
                {
                    Step = 1
                }
            });

            ch.AxisY.Add(new Axis
            {
                Title = "Jumlah Obat",
            });


            jumlahObatChart.Children.Add(ch);
        }