M
Mike
I'm creating a datatable (see below) that is going through each row of my
dataset and add new rows per each column created. Is there a way to store
the GrossSales figures so I can use
those numbers in for a calculation within the Expenses row?
My data for the dsSales dataset like this:
year totalGross SalesmanLastName
2005 45,000 Smith
2004 25,000 Jensen
2003 12,000 A. Smith
My data for dsExpenses is coming out like this:
year Expense SalesmanLastName
2005 4,000 Smith
2004 1500 Jensen
2003 12,000 A. Smith
is there a way to store the TotalGross and use that for a calculation within
the foreach {} loop for the dsExpense so I can have the net calculated? I
have to seperate dataset due to the data is coming from 2 seperate tables
within the database
public DataTable Results()
{
dtFigures = new DataTable();
dsSales = GetSalesValues();
foreach (DataTable dt in dsSales.Tables)
{
foreach (DataRow dr in dt.Rows)
{
dr = dtFigures.NewRow();
dr["SubHeader"] = "Sales Figures"
dr["Year"] = dr["Year"].ToString();
dtFigures.Rows.Add(dr);
dr = dtFigures.NewRow();
GrossSales = Convert.ToDecimal(dr["totalGross"]) / 1000;
dr["MetricType"] = "Gross Sales
dr["Year"] = dr["Year"].ToString();
dr["Year One"] =
Convert.ToInt32(GrossSales).ToString("c0");
dtFigures.Rows.Add(dr);
}
}
dsExpenses = AllExpenses();
foreach (DataTable dt in dsExpenses.Tables)
{
foreach (DataRow dr in dt.Rows)
{
dr = dtFigures.NewRow();
dr["SubHeader"] = "Expenses";
dr["Year"] = dr["Year"].ToString();
dtFigures.Rows.Add(dr);
dr = dtFigures.NewRow();
dr["MetricType"] = "Year to date expenses";
dr["Year"] = dr["Year"].ToString();
dr["Year One Expenses"] = Convert.ToDecimal(dr["Expense"])
/ 1000;
dtFigures.Rows.Add(dr);
}
}
}
dataset and add new rows per each column created. Is there a way to store
the GrossSales figures so I can use
those numbers in for a calculation within the Expenses row?
My data for the dsSales dataset like this:
year totalGross SalesmanLastName
2005 45,000 Smith
2004 25,000 Jensen
2003 12,000 A. Smith
My data for dsExpenses is coming out like this:
year Expense SalesmanLastName
2005 4,000 Smith
2004 1500 Jensen
2003 12,000 A. Smith
is there a way to store the TotalGross and use that for a calculation within
the foreach {} loop for the dsExpense so I can have the net calculated? I
have to seperate dataset due to the data is coming from 2 seperate tables
within the database
public DataTable Results()
{
dtFigures = new DataTable();
dsSales = GetSalesValues();
foreach (DataTable dt in dsSales.Tables)
{
foreach (DataRow dr in dt.Rows)
{
dr = dtFigures.NewRow();
dr["SubHeader"] = "Sales Figures"
dr["Year"] = dr["Year"].ToString();
dtFigures.Rows.Add(dr);
dr = dtFigures.NewRow();
GrossSales = Convert.ToDecimal(dr["totalGross"]) / 1000;
dr["MetricType"] = "Gross Sales
dr["Year"] = dr["Year"].ToString();
dr["Year One"] =
Convert.ToInt32(GrossSales).ToString("c0");
dtFigures.Rows.Add(dr);
}
}
dsExpenses = AllExpenses();
foreach (DataTable dt in dsExpenses.Tables)
{
foreach (DataRow dr in dt.Rows)
{
dr = dtFigures.NewRow();
dr["SubHeader"] = "Expenses";
dr["Year"] = dr["Year"].ToString();
dtFigures.Rows.Add(dr);
dr = dtFigures.NewRow();
dr["MetricType"] = "Year to date expenses";
dr["Year"] = dr["Year"].ToString();
dr["Year One Expenses"] = Convert.ToDecimal(dr["Expense"])
/ 1000;
dtFigures.Rows.Add(dr);
}
}
}