Sarah Reynolds

Sarah Reynolds

  • NA
  • 32
  • 11.4k

Best Approach?

Feb 3 2012 11:08 AM
Hi Guys, I'm hoping you can offer some advice on an issue i'm having with a datagrid populated from a database with a bindingsource.

DBConnect DBCon = new DBConnect();
string strSqlAO = "SELECT order_id AS 'Order', store_name AS 'Store Name', customer_id AS 'Customer ID', firstname AS 'First Name', lastname AS 'Last Name', email, telephone AS 'Tel', shipping_postcode AS 'Shipping Postcode', shipping_method AS 'Shipping Method', payment_method AS 'Payment Method', total AS 'Total', currency_code AS 'Currency', date_added AS 'Date Added', order_status_id FROM order ORDER BY date_added DESC";
//set the BindingSource DataSource
bSourceAO.DataSource = DBCon.GetData(strSqlAO);
//set the DataGridView DataSource
dgAllOrders.DataSource = bSourceAO;

The datagrid contains customers details and their order numbers from a table called 'order'. I can filter this datagrid to remove customers so my 'end result/view' is different to the actual data originally pulled from the database. (50 orders pulled into datagrid view but may only end up with 10 orders)

The 'order' table contains an 'order_id' field and the products purchased are in another table called 'order_products' and linked via the 'order_id'.

Once my datagrid is filtered I need to be able to produce a 'batch packing list' of the products ordered by the customers left in the datagrid only. I need the packing list to only show the product once but with the actual times that product was purchased.

ie: 3 of the customers left in the datagrid purchase 'Product A' so I need my packing list to show 'Product A = 3'.

I cant get my head around the best approach and don't want to start with this problem until I have at least a clear idea of the best approach.

Any ideas how to achieve this?

Thanks.
Sarah





Answers (4)