วันพุธที่ 22 เมษายน พ.ศ. 2563
chart
using DevExpress.XtraCharts;
-----------------------------------------------------------------
private void Form1_Load(object sender, EventArgs e)
{
MySqlConnection cnn = new MySqlConnection(ConString);
string sql = "SELECT hserv,COUNT(*) c " +
"FROM epe0 " +
"GROUP BY HSERV " +
"ORDER BY count(*) DESC";
try
{
cnn.Open();
StatusLabel1.Text = "Connected !!";
StatusLabel1.ForeColor = Color.Green;
cnn.Close();
}
catch (Exception ex)
{
// MessageBox.Show("Can not open connection ! " + ex.Message);
StatusLabel1.Text = "UnConnected !!";
StatusLabel1.ForeColor = Color.Red;
}
finally
{
}
try
{
cnn.Open();
DataTable dt = new DataTable() ;
DataSet ds = new DataSet();
MySqlCommand cmd = new MySqlCommand(sql, cnn);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
//MySqlDataReader rdr = cmd.ExecuteReader();
da.Fill(dt);
da.Fill(ds, "Table");
gridControl1.DataSource = ds.Tables[0].DefaultView;
DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series("A Pie Series", ViewType.Bar);
chartControl1.DataSource = ds.Tables[0].DefaultView;
// chartControl1.SeriesDataMember = "Table";
chartControl1.Series.Add(series1);
series1.ArgumentDataMember = "hserv";
series1.ValueDataMembers[0] = "c";
// this.Controls.Add(chartControl1);
//chartControl1.da
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error ! " + ex.Message);
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น