[英]Query with RefNumberList for invoice QuickBooks QBFC
I am developing a program which will query Quickbooks with a set of invoice numbers, and then against each invoice no. 我正在开发一个程序,该程序将使用一组发票号,然后针对每个发票号查询Quickbook。 will get invoice, the invoice numbers will come primarily from a file. 将获得发票,发票编号主要来自文件。 and the numbers which have problems that is they don't have a matching record in quick book will be saved in another file. 快速书中没有匹配记录的问题编号将保存在另一个文件中。
Now that I add all the invoice numbers in the RefNumberList as I have hard coded two numbers in the following example 现在,我将所有发票编号添加到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;
}
The main problem is that if even any one of the invoice number fails to have a record in the quick books, entire query fails. 主要问题在于,即使连发票编号中的任何一个都无法在速查簿中记录,整个查询也会失败。
I would suggest that you make each invoice a separate request. 我建议您单独提出每张发票。 That way you will still get the other queries returning a value. 这样,您仍将获得其他返回值的查询。
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); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.