// gets customer/invoice from an anonymous type private void getValuesFromVar(out CustomerAS2 _customer, out InvoiceLineItemAS2 _invoice, dynamic _v) { // get customer try { _customer = _v.Customer; } catch (RuntimeBinderException) { _customer = null; } // get invoice line item try { _invoice = _v.Invoice; } catch (RuntimeBinderException) { _invoice = null; } }
// fill row with cells for given customer/invoice // if either null, empty cells private void fillRow(TableRow _row, CustomerAS2 _customer, InvoiceLineItemAS2 _invoice) { // grab info string _custID = (_customer != null) ? (_customer.CustomerID.ToString()) : ((_invoice != null) ? (_invoice.CustomerID.ToString()) : ("")); string _name = (_customer != null) ? (_customer.Name) : (""); string _street = (_customer != null) ? (_customer.Street) : (""); string _city = (_customer != null) ? (_customer.City) : (""); string _state = (_customer != null) ? (_customer.State) : (""); string _zip = (_customer != null) ? (_customer.Zip) : (""); string _ordNum = (_invoice != null) ? (_invoice.OrderNumber.ToString()) : (""); string _seqNum = (_invoice != null) ? (_invoice.SequenceNumber.ToString()) : (""); string _itemsku = (_invoice != null) ? (_invoice.ItemSKU.ToString()) : (""); string _quantity = (_invoice != null) ? (_invoice.Quantity.ToString()) : (""); string _price = (_invoice != null) ? (_invoice.Price.ToString()) : (""); string _weight = (_invoice != null) ? (_invoice.Weight.ToString()) : (""); string _shipping = (_invoice != null) ? (_invoice.Shipping.ToString()) : (""); // Customer ID, Name, Street, City, State, Zip // Order Number, Sequence Number, Item SKU, Quantity, Price, Weight, Shipping cost // build cells _row.Cells.Add(createCell(_custID)); _row.Cells.Add(createCell(_name)); _row.Cells.Add(createCell(_street)); _row.Cells.Add(createCell(_city)); _row.Cells.Add(createCell(_state)); _row.Cells.Add(createCell(_zip)); _row.Cells.Add(createCell(_ordNum)); _row.Cells.Add(createCell(_seqNum)); _row.Cells.Add(createCell(_itemsku)); _row.Cells.Add(createCell(_quantity)); _row.Cells.Add(createCell(_price)); _row.Cells.Add(createCell(_weight)); _row.Cells.Add(createCell(_shipping)); }