我有我从通过一个DataGridView创建水晶报表数据集/表
MakePayment makePayment = new MakePayment();
var Result = GridSellProducts.Rows.OfType<DataGridViewRow>().Select(
r => r.Cells.OfType<DataGridViewCell>().Select(c => c.Value).ToArray());
makePayment.gridElements = Result.ToList();
MakePayment的值来读取创建以下列表是另一种形式,我将有一个按钮,用于制作上的项目,并显示支付销售收据。我没有在Visual Studio中使用Crystal Reports,只有SAP从SQL表中读取数据。
如何创建一个水晶报表,显示List-ItemSalesList的itemname,quantity,unit price,tax,total等列表元素?
到目前为止,我已经试过这样:
foreach (var x in ItemSalesElements)
{
ItemSalesList.Add(new ItemSales <--from makePayment.gridElements
{
ItemName = x[0].ToString(),
Quantity = decimal.Parse(x[1].ToString()),
UnitPrice = decimal.Parse(x[2].ToString()),
Total = decimal.Parse(x[6].ToString()),
});
}
ItemSalesData itemSalesData = new ItemSalesData();
ItemSalesData.ItemSalesTableRow row = itemSalesData.ItemSalesTable.NewItemSalesTableRow();
foreach (var x in ItemSalesList)
{
row.ItemName = x.ItemName;
row.Quantity = x.Quantity;
row.UnitPrice = x.UnitPrice;
row.Total = x.Total;
itemSalesData.ItemSalesTable.Rows.Add(row);
}
ItemSalesReport cr = new ItemSalesReport();
cr.SetDataSource(itemSalesData);
我应该编辑还是在下面写一个答案? –
当你需要改进它时,编辑你的问题总是一个好主意。 –