0

我看到了这个链接,我注意到我们有同样的问题,他的问题仍然没有回答。

这是问题。

public class ServiceSel
    {
        public void GetCheqe()
        {
            bool sessionBegun = false;
            bool connectionOpen = false;
            QBSessionManager rp = null;

        try
        {
            rp = new QBSessionManager();
            IMsgSetRequest requestMsgSet = rp.CreateMsgSetRequest("US", 8, 0);
            requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
            rp.OpenConnection("Database Path File QuickBooks", "QuickBooks Integration Demo");
            connectionOpen = true;
            rp.BeginSession("", ENOpenMode.omDontCare);
            sessionBegun = true;

            ICheckQuery checkQuery = requestMsgSet.AppendCheckQueryRq();
            IMsgSetResponse msgSetRs = rp.DoRequests(requestMsgSet);
            IResponse response = msgSetRs.ResponseList.GetAt(0);
            ICheckRetList checkRetList = (ICheckRetList)response.Detail;

            if (checkRetList != null)
            {
                for (int i = 0; i < checkRetList.Count; i++)
                {
                        ICheckRet checkRet = checkRetList.GetAt(i);
                        //Bank Account On top 
                        string TxnID = checkRet.TxnID.GetValue().ToString();       //Data correct
                        string TxnNumber = checkRet.TxnNumber.GetValue().ToString();   //Data correct
                        string Account = checkRet.AccountRef.FullName.GetValue();   //Data correct
                        string Amount = checkRet.Amount.GetValue().ToString();   //Data correct

                         if (checkRet.ExpenseLineRetList != null)
                         {
                                 Error checkRet.Expense Show null Data But in quickbooks have many data expense in calendar 

                         }      
                }
            }
        }
        catch (Exception ex)
        {
            //MessageBox.Show(ex.Message, "Error");
        }
        finally
        {
            if (sessionBegun)
            {
                rp.EndSession();
            }
            if (connectionOpen)
            {
                rp.CloseConnection();
            }
        }

    }

为什么 ExpenseLineRetList 为空?

4

1 回答 1

2

除非您将其包含在查询中,否则支票请求将不包括支票的详细信息行。通过添加IncludeLineItems设置,您将可以访问支票的费用或项目列表(支票可能有费用行、项目行或两者兼有)。您需要进行更改以包括以下内容:

ICheckQuery checkQuery = requestMsgSet.AppendCheckQueryRq();
checkQuery.IncludeLineItems.SetValue(true);
IMsgSetResponse msgSetRs = rp.DoRequests(requestMsgSet);

我还建议您在尝试获取响应详细信息之前检查响应代码,以便更好地处理错误:

IResponse response = msgSetRs.ResponseList.GetAt(0);
if(response.StatusCode != 0)
{
    // There was an error. response.StatusCode has the error number
    // response.StatusMessage has the error description.
}
else
{        
    ICheckRetList checkRetList = (ICheckRetList)response.Detail;
    .
    .
    .
}
于 2014-04-01T13:20:21.660 回答