I could really use your help ,I've been struggling with this for a while.
So, I'm working on a WPF application and I want to print an invoice like PDF. The printing is working perfectly, I've created a FlowDocument which has three tables, header, second with the details like price etc. and the third is the footer. The data is on an SQL Server and I have a Closed_Orders table which has the data I'd like to print. These are displayed in a datagrid (NOT datagridVIEW!). The printer works like you select a row in the datagrid and it gets the data (DataRowView row = (DataRowView)Closed_Orders.SelectedItem;
) and puts it in one row in the second table of the flowdocuwment. Each closed order has an ID, but I have more rows with the same ID, sometimes just one , but can be five r six or more. I made another Print table where if you select an order, it puts in all orders with the same ID and they are displayed in another datagrid.
My goal is to put the orders with the same ID (All row from the print table) in the second table of my flowdocument if I select an order and click on the Print button. Maybe I could loop through the grid, but I don't know how, or how can I get the data from each row of the datagrid or the Print table and put it in the document and also how to create just as many rows to the table as the SQL table has ?
I did it ,it was easier than I thought. I stored the numbers of rows in an int variable, then I made a while loop where it went from 1 to the number of rows, inside the while I got the values I needed from the database with ROW_NUMBER() OVER(ORDER BY amount) AS num
,then I added the rows:
int row = i + 2;
table2.RowGroups.Add(new TableRowGroup());
table2.RowGroups[0].Rows.Add(new TableRow());
currentRow = table2.RowGroups[0].Rows[row];
currentRow.Cells.Add(new TableCell(new Paragraph(new Run((amount+....