Omer Butt
Active member
- Joined
- Sep 6, 2021
- Messages
- 29
- Programming Experience
- Beginner
I have a Chart on Dashboard where I want when the dashboard load the Chart displays the data according to database.
Below is a Table I created named
In this Already have saved one record successfully through Add Medic Form
Where the Manufacture Date and Expiry Date are BunifuDatePicker
BunifuDatePicker Name is Dash_ValidExpire_Chart
Now want that record to be displayed on Dashboard in a chart to show Valid and expiry Medicine.
Below is a code that I did on dashboard load event
Below is the Image of a Chart in Which I want the data to be displayed shown in the image is a default chart image
Below is a Table I created named
Medic
Databese Table:
Create table Medic(
Med_ID int Primary Key Identity (1,1),
Med_Name varchar(250) not null,
M_Date varchar(250) not null,
E_Date varchar(250) not null,
);
Where the Manufacture Date and Expiry Date are BunifuDatePicker
BunifuDatePicker Name is Dash_ValidExpire_Chart
Now want that record to be displayed on Dashboard in a chart to show Valid and expiry Medicine.
Below is a code that I did on dashboard load event
Code for Chart to Display Data on Dashboard Load:
DbConnect Conn = new DbConnect();
Int64 Count;
private void P_DashboardUC_Load(object sender, EventArgs e)
{
LoadChart();
}
public void LoadChart()
{
try
{
string ChartQuery = "select count(Med_Name) from Pharmacist_Medicine where E_Date >= getdate()";
SqlDataAdapter da = new SqlDataAdapter(ChartQuery, Conn.Connect);
DataSet ds = new DataSet();
da.Fill(ds);
Count = Int64.Parse(ds.Tables[0].Rows[0][0].ToString());
this.Dash_ValidExpire_Chart.Series["Valid Medicines"].Points.AddXY("Medicine Validity Chart", Count);
Dash_ValidExpire_Chart.DataSource = ds;
}
catch(Exception msg)
{
MessageBox.Show(msg.Message);
}
}
Below is the Image of a Chart in Which I want the data to be displayed shown in the image is a default chart image