通过c#代码从quickbooks桌面访问贷项通知单

时间:2016-06-14 11:04:32

标签: c# quickbooks intuit-partner-platform intuit

我有一个要求,我需要以编程方式/通过c#代码从quickbooks desktop(企业版)中检索贷项通知单。

任何人都可以帮我使用此代码/方法。

由于

2 个答案:

答案 0 :(得分:0)

您需要使用CreditMemoQuery。

请参阅“屏幕参考指南” - http://developer-static.intuit.com/qbsdk-current/common/newosr/index.html或查看其他请求的示例并进行修改。

https://developer.intuit.com/docs/0250_qb/0050_documentation/sample_code

答案 1 :(得分:0)

使用ICreditMemoQuery对象从QuickBooks中检索贷记凭证列表。这是使用QuickBooks SDK 13.0检索Credit凭证列表的示例C#代码:

using QBXMLRP2Lib;
using Interop.QBFC13;

public class SDKApp
{
    private QBSessionManager sessionMgr;

    public SDKApp()
    {
        // in the class constructor - sessionMgr is a member variable
        sessionMgr = new QBSessionManager(); 
    }

    public void GetCreditMemoData()
    {
        // open connection and begin session before data fetch - intentionally skipped this code
        IMsgSetRequest msgset = null;
        ICreditMemoQuery creditMemoQuery = null;
        try
        {
            // during data fetch
            msgset = sessionMgr.CreateMsgSetRequest("US", 13, 0);
            creditMemoQuery = msgset.AppendCreditMemoQueryRq();

            creditMemoQuery.ORTxnQuery.TxnFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetValue(new DateTime(2012, 3, 31), false); // you can apply filters too

            IMsgSetResponse msgRes = sessionMgr.DoRequests(msgset);
            IResponseList responseList = msgRes.ResponseList;
            if (responseList.Count > 0)
            {
                IResponse response = responseList.GetAt(0);
                ICreditMemoRetList creditMemoList = response.Detail as ICreditMemoRetList;
                if (creditMemoList == null)
                {
                    return;
                }

                for (int i = 0; i <= creditMemoList.Count - 1; i++)
                {
                    ICreditMemoRet qbCreditMemo = creditMemoList.GetAt(i);
                    Console.WriteLine("Credit no.:" + qbCreditMemo.TxnNumber.GetValue() + " Customer:" + qbCreditMemo.CustomerRef.FullName.GetValue() + " Total:" + qbCreditMemo.TotalAmount.GetValue());
                }
            }
        }
        catch (Exception ex)
        {
            //handle exception here
        }
        finally
        {
            if (msgset != null)
            {
                Marshal.FinalReleaseComObject(msgset);
            }
            if (creditMemoQuery != null)
            {
                Marshal.FinalReleaseComObject(creditMemoQuery);
            }
        }

        // end session and close connection after data fetch - intentionally skipped this code
    }
}

希望这有帮助。