Jim Tat

Jim Tat

  • NA
  • 52
  • 47.2k

How to generate invoice by fetching from database c#

Feb 5 2018 3:26 PM
Helllo experts, I am doing an app which will generate invoices by fetching from database SQL.
 
Here see What I did :
  1. DataTable dt = new DataTable();  
  2. dt.Columns.AddRange(new DataColumn[5] {  
  3.                         new DataColumn("ProductId"typeof(string)),  
  4.                         new DataColumn("Product"typeof(string)),  
  5.                         new DataColumn("Price"typeof(int)),  
  6.                         new DataColumn("Quantity"typeof(int)),  
  7.                         new DataColumn("Total"typeof(int))});  
  8. dt.Rows.Add(101, "Sun Glasses", 200, 5, 1000);  
  9. dt.Rows.Add(102, "Jeans", 400, 2, 800);  
  10. dt.Rows.Add(103, "Trousers", 300, 3, 900);  
  11. dt.Rows.Add(104, "Shirts", 550, 2, 1100);  
So here As you can see we have Product, Price of the product , the quantity and the total (Price * Quantity)

So my aim is for example

Invoice 1 I want inside it the total price of 1 500

so here my need is that how can we fetch from database so that it will automatically fill the right amount that i need.

INVOICE 1 : TOTAL 1 500 USD

Product1 : Shirts - 550 -2 - 1100
Product2: Jeans - 400 - 1- 400
Total = 1500 (1100+400)
And it automatically removes the quantity of products taken in the database.

Is it possible ?

Thank you.

Answers (1)