gpt4 book ai didi

C# QuickBooks 无法添加检查

转载 作者:太空宇宙 更新时间:2023-11-03 13:01:52 25 4
gpt4 key购买 nike

我正在尝试使用 C# 添加将佣金支付从我的系统转移到 QuickBooks 的功能,除了添加检查请求外,我已经得到了一大堆工作。目前,我得到这个输出

CheckAdd

ExpenseLineAddList:

element(2) - Required object is empty

End of ExpenseLineAddList

End of CheckAdd

这是代码。不幸的是,它有点长,但这正是围绕必要位的内容。

            MySql.Data.MySqlClient.MySqlConnection CheckConn = new MySql.Data.MySqlClient.MySqlConnection();
MySqlCommand CheckCmd = new MySqlCommand();
CheckConn.ConnectionString = myConnectionString;
CheckConn.Open();
CheckCmd.Connection = CheckConn;
CheckCmd.CommandText = "select `companies`.`ParentCompanyName`, `DateTimeStart`, `DateTimeEnd` from `commissiontransfers` join `orders` using (`InvoiceID`) join `companies` using (`CompanyID`) where `Transfered`=0 group by `ParentCompanyName`;";

MySqlDataReader CheckReader = CheckCmd.ExecuteReader();
DataTable Checks;
using (CheckReader)
{
Checks = new System.Data.DataTable();
Checks.Load(CheckReader);
}
CheckReader.Close();
CheckReader.Dispose();
CheckConn.Close();
CheckConn.Dispose();

foreach (DataRow Check in Checks.Rows)
{

IMsgSetRequest AddCheckMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
AddCheckMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
ICheckAdd CheckAddRq = AddCheckMsgSet.AppendCheckAddRq();

CheckAddRq.AccountRef.FullName.SetValue("Bank Account");
CheckAddRq.PayeeEntityRef.FullName.SetValue(Convert.ToString(Check["ParentCompanyName"]));
CheckAddRq.Memo.SetValue("Date Range: From " + Convert.ToDateTime(Check["DateTimeStart"]).ToString("MM/dd/yyyy") + " to " + Convert.ToDateTime(Check["DateTimeEnd"]).ToString("MM/dd/yyyy"));
CheckAddRq.IsToBePrinted.SetValue(true);


MySql.Data.MySqlClient.MySqlConnection CommissionTransferConn = new MySql.Data.MySqlClient.MySqlConnection();
MySqlCommand CommissionTransferCmd = new MySqlCommand();
CommissionTransferConn.ConnectionString = myConnectionString;
CommissionTransferConn.Open();
CommissionTransferCmd.Connection = CommissionTransferConn;
CommissionTransferCmd.CommandText = "select `CommissionTransferID`, round(`OrderCommission`-`FactoryCommission`-`ShippingCommission`, 2) `Total`, `orders`.`DateTimePaid`, `companies`.`OldQBName`, `orders`.`Customer` from `commissiontransfers` join `orders` using (`InvoiceID`) join `companies` using (`CompanyID`) where `Transfered`=0;";

MySqlDataReader CommissionTransferReader = CommissionTransferCmd.ExecuteReader();
DataTable CommissionTransfers;
using (CommissionTransferReader)
{
CommissionTransfers = new System.Data.DataTable();
CommissionTransfers.Load(CommissionTransferReader);
}
CommissionTransferReader.Close();
CommissionTransferReader.Dispose();
CommissionTransferConn.Close();
CommissionTransferConn.Dispose();

foreach (DataRow CommissionTransfer in CommissionTransfers.Rows)
{

IExpenseLineAdd ExpenseLineAdd = CheckAddRq.ExpenseLineAddList.Append();
ExpenseLineAdd = CheckAddRq.ExpenseLineAddList.Append();
ExpenseLineAdd.AccountRef.FullName.SetValue("Contract Labor:1099's");
ExpenseLineAdd.Amount.SetValue(Convert.ToDouble(CommissionTransfer["Total"]));
ExpenseLineAdd.Memo.SetValue(Convert.ToString(CommissionTransfer["Customer"]) + " - " + Convert.ToDateTime(CommissionTransfer["DateTimePaid"]).ToString("MM/dd/yyyy"));
ExpenseLineAdd.ClassRef.FullName.SetValue(Convert.ToString(CommissionTransfer["OldQBName"]));

GetFirstRow("update `commissiontransfers` set `Transfered`=1 where `CommissionTransferID`='" + CommissionTransfer["CommissionTransferID"] + "';");
}
CheckAddRq.IncludeRetElementList.Add("TxnID");

try {
IMsgSetResponse CheckResponseMsgSet = sessionManager.DoRequests(AddCheckMsgSet);
IResponse CheckResponse = CheckResponseMsgSet.ResponseList.GetAt(0);
MessageBox.Show(CheckResponse.StatusCode + ": " + CheckResponse.StatusMessage);
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}

我的 AddCheckMsgSet 变量似乎是空的,但我终究无法弄清楚为什么会这样。非常感谢任何帮助!

最佳答案

当然,我在这个问题上卡了三个小时,发到这里就自己解决了。好吧,问题与这些行有关

IExpenseLineAdd ExpenseLineAdd = CheckAddRq.ExpenseLineAddList.Append();
ExpenseLineAdd = CheckAddRq.ExpenseLineAddList.Append();

我需要做的就是删除第二行,因为我已经附加了一个新的费用行,而第二个附加导致第一个请求为空。希望这对将来的人有所帮助,因为我在尝试连接到 QuickBooks 时遇到了唯一的问题。

关于C# QuickBooks 无法添加检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32057585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com