public List<BillInformation> GetAssociatedBills(CompanyInformation company, ClientInformation client) { List<BillInformation> bills = new List<BillInformation>(); DataTable results = database.Select("SELECT * FROM bill WHERE company=@company AND client=@client", new Dictionary<string, object>() { {"company", company.ID}, {"client", client.ID} }); foreach (DataRow result in results.Rows) { BillInformation bill = new BillInformation(); bill.Fill(result); bills.Add(bill); } return bills; }
public List<ProductInformation> GetProducts(BillInformation bill) { List<ProductInformation> products = new List<ProductInformation>(); DataTable results = database.Select("SELECT " + "p.product_id, p.name, p.quantity, p.unit_price, p.unit, p.vat FROM product AS p " + "INNER JOIN BillItems AS i ON p.product_id = i.product_id " + "WHERE i.bill_id = @bill", new Dictionary<string, object>() { {"bill", bill.ID} }); foreach (DataRow dataRow in results.Rows) { ProductInformation product = new ProductInformation(); product.Fill(dataRow); products.Add(product); } return products; }