protected void Page_Load(object sender, EventArgs e)
{
double totalUsage = 0;
int rowCount = getRowCount();
int columnCount = getColumnCount();
string[] xValues = getColumnName();
double[] yValues = new double[columnCount];
SqlConnection conBudget = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
SqlCommand cmdBudget = new SqlCommand("SELECT Foods, Clothes, Drinks, Entertaiment FROM DailyBudget WHERE (Username=@username)", conBudget);
conBudget.Open();
cmdBudget.Parameters.AddWithValue("@username", "gahhon");
SqlDataReader dtrBudget = cmdBudget.ExecuteReader();
if (dtrBudget.Read())
for (int i = 0; i < columnCount; i++)
{
yValues[i] = Convert.ToDouble(dtrBudget[i]);
totalUsage += Convert.ToDouble(dtrBudget[i]);
}
dtrBudget.Close();
conBudget.Close();
double RemainBudget = getRemainBudget(totalUsage);
lblBudget.Text = "RM " + getDailyBudget().ToString("n2");
lblCurrent.Text = "RM " + getCurrentBudget().ToString("n2");
lblRemaining.Text = "RM " + RemainBudget.ToString("n2");
insertChart(xValues, yValues);
}
protected void insertChart(string[] xValues, double[] yValues)
{
pcBudget.Series["Series1"]["PieLabelStyle"] = "Outside";
pcBudget.Series["Series1"].Points.DataBindXY(xValues, yValues);
pcBudget.Series["Series1"].EmptyPointStyle.IsValueShownAsLabel = false;
pcBudget.Series["Series1"].EmptyPointStyle.IsVisibleInLegend = false;
pcBudget.Series["Series1"].LegendText = "#VALX #PERCENT{P2}";
pcBudget.DataManipulator.Sort(PointSortOrder.Descending, pcBudget.Series["Series1"])
DataBindXY(xValues, yValues)
Occured the problem of Enumeration already finish. thanks for in advance