Exemple #1
0
        private async void UserLoaiTruyen_Load(object sender, EventArgs e)
        {
            var tong = ExecSQL.ExecQuerySacalar("SELECT COUNT(DISTINCT matruyen) AS tong FROM dbo.tbl_ct_phieunhapxuat WHERE slnhap>0");

            Text = @"Loại truyện: " + tong + @" cuốn";
            var chartControl1 = new ChartControl();

            chartControl1.Dock = DockStyle.Fill;
            panelControl.Controls.Add(chartControl1);
            var dataTable = await ExecSQL.ExecProcedureDataAsyncAsDataTable("pro_get_tongso_loaitruyen");

            await Task.Factory.StartNew(new Action(() =>
            {
                chartControl1.DataSource = dataTable;
                chartControl1.BeginInvoke(new Action(() =>
                {
                    Series seriesloaitruyen = new Series("Loại truyện", ViewType.Bar);
                    seriesloaitruyen.LabelsVisibility = DefaultBoolean.True;
                    // Add points to them, with their arguments different.
                    foreach (DataRow dr in dataTable.Rows)
                    {
                        seriesloaitruyen.Points.Add(new SeriesPoint(dr["loaitruyen"], dr["soluong"]));
                    }
                    chartControl1.Series.AddRange(new Series[] { seriesloaitruyen });
                    chartControl1.Legend.Visibility = DefaultBoolean.True;

                    Legend legend = chartControl1.Legend;
                    legend.Margins.All = 8;
                    legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
                    legend.AlignmentVertical = LegendAlignmentVertical.Top;
                    legend.Direction = LegendDirection.LeftToRight;
                }));
            }));
        }
Exemple #2
0
        private void UserGiaTri_Load(object sender, EventArgs e)
        {
            var tong = ExecSQL.ExecQuerySacalar("SELECT SUM(slnhap*dongia) AS tong FROM dbo.tbl_ct_phieunhapxuat");

            Text = @"Giá trị: " + string.Format("{0:#,##}", tong) + @" VND";
            var chartControl1 = new ChartControl();

            chartControl1.Dock = DockStyle.Fill;
            panelControl.Controls.Add(chartControl1);
            Task.Factory.StartNew(() =>
            {
                var dataTable            = ExecSQL.ExecProcedureDataAsDataTable("pro_get_thongke_theothang");
                chartControl1.DataSource = dataTable;
                chartControl1.BeginInvoke(new Action(() =>
                {
                    Series seriesGiatri           = new Series("Giá trị", ViewType.Line);
                    seriesGiatri.LabelsVisibility = DefaultBoolean.True;

                    foreach (DataRow dr in dataTable.Rows)
                    {
                        seriesGiatri.Points.Add(new SeriesPoint(dr["thangnam"], dr["thanhtien"]));
                    }

                    seriesGiatri.Label.TextPattern = "{V:#,##0}";

                    chartControl1.Series.AddRange(new[] { seriesGiatri });
                    chartControl1.Legend.Visibility = DefaultBoolean.True;

                    Legend legend = chartControl1.Legend;
                    // chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Center
                    legend.Margins.All         = 8;
                    legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
                    legend.AlignmentVertical   = LegendAlignmentVertical.Top;
                    legend.Direction           = LegendDirection.LeftToRight;
                }));
            });
        }