private void UpdateCustomer(Quickbooks qb, ICustomerRet customer, CheckToWrite r) { List <String> account = new List <string>(); IMsgSetRequest msgRequest = qb.newRequest(); msgRequest.Attributes.OnError = ENRqOnError.roeStop; ICustomerMod customerMod = msgRequest.AppendCustomerModRq(); customerMod.ListID.SetValue(customer.ListID.GetValue()); customerMod.AccountNumber.SetValue(r.RecipientId); customerMod.Name.SetValue(r.FullName); customerMod.BillAddress.Addr1.SetValue(customerMod.Name.GetValue()); customerMod.BillAddress.Addr2.SetValue(r.Address1); customerMod.BillAddress.Addr3.SetValue(r.Address2); customerMod.Contact.SetValue(customerMod.Name.GetValue()); customerMod.BillAddress.City.SetValue(r.City); customerMod.BillAddress.State.SetValue(r.State); customerMod.BillAddress.PostalCode.SetValue(r.Zip); customerMod.EditSequence.SetValue(customer.EditSequence.GetValue()); IMsgSetResponse response = qb.performRequest(msgRequest); if (response.ResponseList.GetAt(0).StatusCode != 0) { throw new Exception("Unable to update customer " + response.ResponseList.GetAt(0).StatusMessage); } }
private void modifyCustomer(ICustomerRet QBCustomer) { Console.WriteLine(QBCustomer.Name.GetValue() + ": " + QBCustomer.Email.GetValue()); IMsgSetRequest requestMsgSet = _MySessionManager.CreateMsgSetRequest("US", 13, 0); ICustomerMod Query = requestMsgSet.AppendCustomerModRq(); Query.ListID.SetValue(QBCustomer.ListID.GetValue()); Query.EditSequence.SetValue(QBCustomer.EditSequence.GetValue()); Query.Email.SetValue(""); IMsgSetResponse responseMsgSet = _MySessionManager.DoRequests(requestMsgSet); //IResponseList rsList = responseMsgSet.ResponseList; //IResponse response = rsList.GetAt(0); //ICustomerRet QBCustomer = (ICustomerRet)response.Detail; //if (QBCustomer == null) //{ // throw new Exception("Sorry, sales order not found."); //} //string CustomerName = QBCustomer.Name.GetValue().ToString(); ////string email = QBCustomer.Email.GetValue(); //Console.WriteLine(CustomerName); }
public Dictionary <string, string> Modify(string id, CustomerEntity entity) { Dictionary <string, string> data = null; try { IMsgSetRequest requestMsgSet = QuickBooksConection(); //edit items ICustomerMod customerMod = requestMsgSet.AppendCustomerModRq(); customerMod.ListID.SetValue(id); customerMod.EditSequence.SetValue(entity.EditSequence); if (!string.IsNullOrEmpty(entity.Name)) { customerMod.Name.SetValue(entity.Name); } if (!string.IsNullOrEmpty(entity.CompanyName)) { customerMod.CompanyName.SetValue(entity.CompanyName); } if (!string.IsNullOrEmpty(entity.Email)) { customerMod.Email.SetValue(entity.Email); } if (!string.IsNullOrEmpty(entity.Phone)) { customerMod.Phone.SetValue(entity.Phone); } if (entity.IsActive.HasValue) { customerMod.IsActive.SetValue(entity.IsActive.Value); } // end edit items data = QuickBooksExcuet(requestMsgSet); } catch (Exception ex) { data = new Dictionary <string, string>(); } return(data); }