本文整理汇总了C#中Customer.OpenQBConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.OpenQBConnection方法的具体用法?C# Customer.OpenQBConnection怎么用?C# Customer.OpenQBConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.OpenQBConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Task_ImportPayments
private void Task_ImportPayments(Objsearch oQuery, Invoice oInvoice, Customer oCustomer, Receivepayment oReceivePayment, Quickbooks oQuickbooks)
{
try
{
oQuery.OpenQBConnection();
oInvoice.OpenQBConnection();
oCustomer.OpenQBConnection();
oReceivePayment.OpenQBConnection();
PaymentResult oPaymentResult = oQuickbooks.GetPayments();
if (oPaymentResult.IsSuccessfull)
{
m_iTotal = oPaymentResult.Payments.Count();
m_iCurrent = 0;
var errorCount = 0;
var successCount = 0;
foreach (SpeedySpots.API.Interfaces.Payment oPayment in oPaymentResult.Payments)
{
decimal fTotal = 0;
string sInvoices = string.Empty;
oReceivePayment.Reset();
foreach (SpeedySpots.API.Interfaces.PaymentLineItem oPaymentLineItem in oPayment.LineItems)
{
oQuery.Reset();
oQuery.QBXMLVersion = "5.0";
oQuery.QueryType = ObjsearchQueryTypes.qtInvoiceSearch;
oQuery.SearchCriteria = new SearchCriteria();
oQuery.SearchCriteria.RefNumber = oPaymentLineItem.InvoiceID;
oQuery.IterateResults = true;
oQuery.MaxResults = 0;
oQuery.Search();
if (oQuery.Results.Count > 0)
{
oInvoice.Get(oQuery.Results[0].ResultId);
AppliedTo oAppliedTo = new AppliedTo();
oAppliedTo.RefId = oQuery.Results[0].ResultId;
oAppliedTo.PaymentAmount = oPaymentLineItem.Amount.ToString("0.00");
oReceivePayment.AppliedTo.Add(oAppliedTo);
fTotal += oPaymentLineItem.Amount;
sInvoices += string.Format("{0}, ", oPaymentLineItem.InvoiceID);
}
}
try
{
oReceivePayment.AutoApply = ReceivepaymentAutoApplies.aaCustom;
oReceivePayment.CustomerName = oInvoice.CustomerName;
oReceivePayment.Amount = fTotal.ToString();
oReceivePayment.TransactionDate = oPayment.CreatedDateTime.ToString("d");
if (oPayment.CreditCardFirstName != string.Empty)
{
oReceivePayment.RefNumber = string.Format("{0} {1}", oPayment.CreditCardFirstName, oPayment.CreditCardLastName);
}
if (oPayment.CreditCardType == "Visa")
{
oReceivePayment.PaymentMethodName = "Visa";
}
else if (oPayment.CreditCardType == "MasterCard")
{
oReceivePayment.PaymentMethodName = "Mastercard";
}
else if (oPayment.CreditCardType == "American Express")
{
oReceivePayment.PaymentMethodName = "American Express";
}
else if (oPayment.CreditCardType == "Discover")
{
oReceivePayment.PaymentMethodName = "Discover";
}
// Remove last ', '
if (sInvoices.Length > 2)
{
sInvoices = sInvoices.Substring(0, sInvoices.Length - 2);
}
oReceivePayment.Memo = string.Format("Payment for invoice {0} - AuthID: {1}", sInvoices, oPayment.AuthorizeNetID);
oReceivePayment.Add();
successCount++;
}
catch (Exception e)
{
errorCount++;
MessageBox.Show(e.Message + System.Environment.NewLine + System.Environment.NewLine + e.StackTrace);
}
this.UpdateProgress();
if (m_oWorkerProcess.CancellationPending)
{
break;
}
//.........这里部分代码省略.........
示例2: Task_ImportCustomers
private void Task_ImportCustomers(Objsearch oQuery, Quickbooks oQuickbooks)
{
try
{
oQuery.OpenQBConnection();
oQuery.QBXMLVersion = "5.0";
oQuery.QueryType = ObjsearchQueryTypes.qtCustomerSearch;
CustomerResult oCustomerResult = oQuickbooks.GetCustomers();
List<int> oSMSIDImported = new List<int>();
if (oCustomerResult.IsSuccessfull)
{
m_iTotal = oCustomerResult.Customers.Count();
m_iCurrent = 0;
int customerCount = 0;
int importedCount = 0;
int duplicateNameCount = 0;
int errorCount = 0;
customerCount = oCustomerResult.Customers.Count;
foreach (var oCustomer in oCustomerResult.Customers)
{
oQuery.SearchCriteria = new SearchCriteria();
oQuery.SearchCriteria.NameStartsWith = oCustomer.Name;
oQuery.Search();
CompanyUniqueness companyUnique = this.IsUniqueCustomerName(oCustomer.Name, oQuery.Results);
if (companyUnique == CompanyUniqueness.Unique)
{
// Add new customer into Quickbooks
Customer oQuickbooksCustomer = new Customer();
oQuickbooksCustomer.OpenQBConnection();
oQuickbooksCustomer.CustomerName = oCustomer.Name;
oQuickbooksCustomer.CompanyName = oCustomer.Name;
oQuickbooksCustomer.AltContactName = oCustomer.BillingName;
oQuickbooksCustomer.AltPhone = oCustomer.BillingPhone;
oQuickbooksCustomer.ContactName = oCustomer.Contact;
oQuickbooksCustomer.Phone = oCustomer.Phone;
oQuickbooksCustomer.Fax = oCustomer.Fax;
if (oCustomer.ShippingCountry == "United States")
{
oQuickbooksCustomer.ShippingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><State>{4}</State><PostalCode>{5}</PostalCode><Country>{6}</Country>", oCustomer.Name, oCustomer.ShippingAddressLine1, oCustomer.ShippingAddressLine2, oCustomer.ShippingCity, oCustomer.ShippingState, oCustomer.ShippingZip, oCustomer.ShippingCountry);
}
else
{
// Not the United States, ignore the state value completely
oQuickbooksCustomer.ShippingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><PostalCode>{4}</PostalCode><Country>{5}</Country>", oCustomer.Name, oCustomer.ShippingAddressLine1, oCustomer.ShippingAddressLine2, oCustomer.ShippingCity, oCustomer.ShippingZip, oCustomer.ShippingCountry);
}
if (oCustomer.BillingCountry == "United States")
{
oQuickbooksCustomer.BillingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><State>{4}</State><PostalCode>{5}</PostalCode><Country>{6}</Country>", oCustomer.Name, oCustomer.BillingAddressLine1, oCustomer.BillingAddressLine2, oCustomer.BillingCity, oCustomer.BillingState, oCustomer.BillingZip, oCustomer.BillingCountry);
}
else
{
// Not the United States, ignore the state value completely
oQuickbooksCustomer.BillingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><PostalCode>{4}</PostalCode><Country>{5}</Country>", oCustomer.Name, oCustomer.BillingAddressLine1, oCustomer.BillingAddressLine2, oCustomer.BillingCity, oCustomer.BillingZip, oCustomer.BillingCountry);
}
oQuickbooksCustomer.Email = oCustomer.InvoiceEmails.Replace(",", ";");
oQuickbooksCustomer.TermsName = "NET 30 DAYS";
oQuickbooksCustomer.Config(string.Format("FirstName={0}", oCustomer.Name));
oQuickbooksCustomer.Config("LastName=");
try
{
oQuickbooksCustomer.Add();
oQuickbooksCustomer.SetCustomField("SMSID", oCustomer.SMSID.ToString());
oSMSIDImported.Add(oCustomer.SMSID);
importedCount += 1;
}
catch (Exception oException)
{
errorCount += 1;
MessageBox.Show(oException.Message + System.Environment.NewLine + System.Environment.NewLine + oException.StackTrace);
}
finally
{
oQuickbooksCustomer.CloseQBConnection();
}
}
else if (companyUnique == CompanyUniqueness.DuplicateMarkImported)
{
oSMSIDImported.Add(oCustomer.SMSID);
duplicateNameCount += 1;
}
else
{
duplicateNameCount += 1;
}
//.........这里部分代码省略.........