C# sample browse invoice

118 views
Skip to first unread message

Dan Palley

unread,
Dec 17, 2019, 8:10:33 PM12/17/19
to TramsAPI Beta
So far, a lot of the work in the C# sample code has made loading and saving data easier.  

Now we are adding functionality to make it easier to browse data once it's been loaded, especially for complicated records that are made up of multiple tables.

For example, after you load an invoice, you may want to iterate through each booking and segment.

There's a new method called GetRows().   The method takes a single parameter, which is the table you want rows for.  As we iterate through the rows, child tables are automatically filtered so you only see child records that correspond to the current parent row.

Here's an example.  After loading invoice #25, we iterate through the invoice, booking and segment tables and display the record numbers.  Typically the load only returns a single invoice, but there could be more than one booking and each booking could have multiple segments.

            await invoice.Load(25);
           
foreach (System.Data.DataRow invoiceDataRow in invoice.GetRows(invoice.InvoiceTable))
           
{
               
Console.WriteLine("InvoiceNo = "+(long)invoiceDataRow[Invoice.Field_Invoice_InvoiceNo]);
               
foreach (System.Data.DataRow bookingDataRow in invoice.GetRows(invoice.BookingTable))
               
{
                   
Console.WriteLine("  BookingNo =  "+(long)bookingDataRow[Invoice.Field_Booking_BookingNo]);
                   
foreach (System.Data.DataRow segmentDataRow in invoice.GetRows(invoice.SegmentTable))
                   
{
                       
Console.WriteLine("    SegmentNo =  "+(long)segmentDataRow[Invoice.Field_Segment_SegmentNo]);
                   
}
               
}
           
}

Here's the output:

InvoiceNo = 25
 
BookingNo = 60
   
SegmentNo = 80
    SegmentNo = 81
  BookingNo = 61
    
SegmentNo = 82
    SegmentNo = 83

Dan

Alexander Kobelev

unread,
Jun 23, 2020, 11:41:45 AM6/23/20
to Trams API
        Hi Dan,
How should I do multiple Record Locator Search?
I've tried to create multiple JObjects, but it didn't work. Multiple " InvoiceSearch.Param_RecordLocator" also not working. Below example of a single Record Locator search, can you direct me on how to do a multiple search?


await invoiceSearch.Search(
            new JObject
                {
                    { InvoiceSearch.Param_IssueDateFrom, new JValue(new DateTime(2020, 5, 1)) },
                    { InvoiceSearch.Param_IssueDateTo, new JValue(new DateTime(2020, 6, 30)) },
                    { InvoiceSearch.Param_InvoiceType, new JArray(Invoice.InvoiceType_Sale)},
                    { InvoiceSearch.Param_RecordLocator, "KGJF3U"},
                    {
                        InvoiceSearch.Param_IncludeCols,
                        new JArray(InvoiceSearch.Col_Invoice_InvoiceNo)
                    }
                }
        ).ConfigureAwait(false);

Alex K.

antonie van der baan

unread,
Jun 23, 2020, 3:28:00 PM6/23/20
to Trams API
Hi Alexander,

The InvoiceQuery call returns a result for a given Record Locator. The call would then be repeated for each additional Record Locator.

-Antonie 

seasid...@gmail.com

unread,
Jun 23, 2020, 6:03:37 PM6/23/20
to Trams API
Hi Alexander,

Are you wanting multiple records returned?? 
As an example, you want 1 query that would return the record locators KGJF3U, ABC123, ZZXXYY

Thanks
Orlando

Alexander Kobelev

unread,
Jun 23, 2020, 6:06:04 PM6/23/20
to Trams API
Exactly! 
I have multiple RecordLocators that I want to conduct Invoice search based on given list of Record Locators.

Alexander Kobelev

unread,
Jun 24, 2020, 8:34:59 AM6/24/20
to Trams API
Thanks, Antonie.
So, there is no way to conduct a search with multiple searching parameters in one shot? Ok. 

antonie van der baan

unread,
Jun 24, 2020, 1:24:25 PM6/24/20
to Trams API
Hi Alexander,

At the present time, no.

Regards,
-Antonie
Reply all
Reply to author
Forward
0 new messages