1

我正在开发一个程序,它将使用一组发票编号查询 Quickbooks,然后针对每个发票编号。将获得发票,发票号码将主要来自文件。并且存在问题的号码,即他们在快速簿中没有匹配记录的号码将保存在另一个文件中。

现在我在 RefNumberList 中添加了所有发票编号,因为我在以下示例中硬编码了两个数字

IInvoiceQuery Invoices = msgset.AppendInvoiceQueryRq();
Invoices.ORInvoiceQuery.RefNumberList.Add("144");
Invoices.ORInvoiceQuery.RefNumberList.Add("9999");

msgset.Attributes.OnError = ENRqOnError.roeContinue;

if (sessionMgr.doRequests(ref msgset))
{
     MessageBox.Show("An error was detected while processing the request. Please check the log files");
     return;
}

主要问题是,即使任何一个发票号码在快速簿中都没有记录,整个查询也会失败。

4

1 回答 1

2

我建议您将每张发票单独申请。这样,您仍然可以让其他查询返回一个值。

msgset.Attributes.OnError = ENRqOnError.roeContinue;
string[] InvoiceList = { "144", "9999" };
foreach (string invNum in InvoiceList)
{
    IInvoiceQuery invQuery = msgset.AppendInvoiceQueryRq();
    invQuery.ORInvoiceQuery.RefNumberList.Add(invNum);
}

// Process the requests and get the response IMsgSetResponse MsgResponse = SessionManager.DoRequests(msgset);

// Check each response for (int index = 0; index < MsgResponse.ResponseList.Count; index++) { IResponse response = MsgResponse.ResponseList.GetAt(index); if (response.StatusCode != 0) { // Save the invoice number in the "not found" file // and display the error MessageBox.Show("Error finding invoice " + InvoiceList[index] + ". Error: " + response.StatusMessage); } }

于 2014-01-22T14:35:55.170 回答