[英]Retrive credit memo from quickbooks desktop through c# code
I have a requirement wherein i need to retrieve the credit memos from quickbooks desktop (enterprise edition) programatically/ through c# code. 我有一个要求,我需要以编程方式/通过c#代码从quickbooks桌面(企业版)中检索贷项通知单。
Can anyone help me with this code/method to use. 谁能帮助我使用此代码/方法。
Thanks 谢谢
You will need to use CreditMemoQuery. 您将需要使用CreditMemoQuery。
See the Onscreen Reference Guide - http://developer-static.intuit.com/qbsdk-current/common/newosr/index.html or look at the samples for the other requests and modify them. 请参阅《屏幕参考指南》-http: //developer-static.intuit.com/qbsdk-current/common/newosr/index.html或查看其他请求的示例并进行修改。
https://developer.intuit.com/docs/0250_qb/0050_documentation/sample_code https://developer.intuit.com/docs/0250_qb/0050_documentation/sample_code
Use ICreditMemoQuery
object to retrieve credit memo list from QuickBooks. 使用ICreditMemoQuery
对象从QuickBooks中检索贷项通知单列表。 Here's a sample C# code to retrieve Credit memo list using QuickBooks SDK 13.0: 以下是使用QuickBooks SDK 13.0检索贷项通知单列表的示例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
}
}
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.