我有一个汉堡店的销售点系统,我想创建一个显示当天销售额的图表。代码是正确的,但是当我测试它时。交易后图表根本没有显示。
这两个代码如下:
(在交易和保存交易之后)
void paymentSuccess(object sender, PaymentMadeEventArgs e)
{
TblTransaction transaction = new TblTransaction();
transaction.TransactionDate = DateTime.Now;
if (e.PaymentSuccess == true)
{
//save the current transaction
foreach (TblProduct product in products)
{
transaction.TblTransactionItems.Add(new TblTransactionItem() { ProductID = product.ProductID });
}
rde.AddToTblTransactions(transaction);
rde.SaveChanges();
}
(我在图表上的代码):
private void generateGraph()
{
using (RanchoPOSDatabaseEntities rde = new RanchoPOSDatabaseEntities()) //inherits the database class of the main form into a private class
{
var query = from product in rde.TblTransactionItems //var ay isang datatype na iniindicate na hindi defined kung anong data ang ipapasok sa system
group product by product.TblProduct.Description into g //groups products by their description at ilalagay sa variable na 'g'
select new { ProductID = g.Key, TotalUnitSold = g.Count() }; //display data base on primary key and the number of items sold
chart1.DataSource = query; //binds the query to the chart1
chart1.Series["Series1"].XValueMember = "ProductID";
chart1.Series["Series1"].YValueMembers = "TotalUnitSold";
chart1.Series["Series1"].Name = "Products";
chart1.DataBind();
chart1.Show();
}
我使用c#
2010与SQL Server 2008
作为媒介,有些人可以查找此>