Adds a customer to QBPOS.
Request
Response
XMLOPS
VB.NET
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | <?xml version="1.0" encoding="utf-8"?> <?qbposxml version="4.0"?> <QBPOSXML> <QBPOSXMLMsgsRq onError="stopOnError"> <CustomerAddRq> <CustomerAdd defMacro="MACROTYPE"> <!-- required --> <CompanyName >STRTYPE</CompanyName> <!-- optional --> <CustomerID >STRTYPE</CustomerID> <!-- optional --> <CustomerDiscPercent >FLOATTYPE</CustomerDiscPercent> <!-- optional --> <!-- CustomerDiscType may have one of the following values: None, PriceLevel, Percentage --> <CustomerDiscType >ENUMTYPE</CustomerDiscType> <!-- optional --> <CustomerType >STRTYPE</CustomerType> <!-- optional --> <EMail >STRTYPE</EMail> <!-- optional --> <IsOkToEMail >BOOLTYPE</IsOkToEMail> <!-- optional --> <FirstName >STRTYPE</FirstName> <!-- optional --> <IsAcceptingChecks >BOOLTYPE</IsAcceptingChecks> <!-- optional --> <IsUsingChargeAccount >BOOLTYPE</IsUsingChargeAccount> <!-- optional --> <IsUsingWithQB >BOOLTYPE</IsUsingWithQB> <!-- optional --> <IsRewardsMember >BOOLTYPE</IsRewardsMember> <!-- optional --> <IsNoShipToBilling >BOOLTYPE</IsNoShipToBilling> <!-- optional --> <LastName >STRTYPE</LastName> <!-- required --> <Notes >STRTYPE</Notes> <!-- optional --> <Phone >STRTYPE</Phone> <!-- optional --> <Phone2 >STRTYPE</Phone2> <!-- optional --> <Phone3 >STRTYPE</Phone3> <!-- optional --> <Phone4 >STRTYPE</Phone4> <!-- optional --> <!-- PriceLevelNumber may have one of the following values: 1, 2, 3, 4, 5 --> <PriceLevelNumber >ENUMTYPE</PriceLevelNumber> <!-- optional --> <Salutation >STRTYPE</Salutation> <!-- optional --> <TaxCategory >STRTYPE</TaxCategory> <!-- optional --> <BillAddress> <!-- optional --> <City >STRTYPE</City> <!-- optional --> <Country >STRTYPE</Country> <!-- optional --> <PostalCode >STRTYPE</PostalCode> <!-- optional --> <State >STRTYPE</State> <!-- optional --> <Street >STRTYPE</Street> <!-- optional --> <Street2 >STRTYPE</Street2> <!-- optional --> </BillAddress> <DefaultShipAddress >STRTYPE</DefaultShipAddress> <!-- optional --> <ShipAddress> <!-- optional, may repeat --> <AddressName >STRTYPE</AddressName> <!-- optional --> <CompanyName >STRTYPE</CompanyName> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> <City >STRTYPE</City> <!-- optional --> <Country >STRTYPE</Country> <!-- optional --> <PostalCode >STRTYPE</PostalCode> <!-- optional --> <State >STRTYPE</State> <!-- optional --> <Street >STRTYPE</Street> <!-- optional --> <Street2 >STRTYPE</Street2> <!-- optional --> </ShipAddress> </CustomerAdd> <IncludeRetElement >STRTYPE</IncludeRetElement> <!-- optional, may repeat --> </CustomerAddRq> <CustomerAddRs statusCode="INTTYPE" statusSeverity="STRTYPE" statusMessage="STRTYPE"> <CustomerRet> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <TimeCreated >DATETIMETYPE</TimeCreated> <!-- optional --> <TimeModified >DATETIMETYPE</TimeModified> <!-- optional --> <AccountBalance >AMTTYPE</AccountBalance> <!-- optional --> <AccountLimit >AMTTYPE</AccountLimit> <!-- optional --> <AmountPastDue >AMTTYPE</AmountPastDue> <!-- optional --> <CompanyName >STRTYPE</CompanyName> <!-- optional --> <CustomerID >STRTYPE</CustomerID> <!-- optional --> <CustomerDiscPercent >FLOATTYPE</CustomerDiscPercent> <!-- optional --> <!-- CustomerDiscType may have one of the following values: None, PriceLevel, Percentage --> <CustomerDiscType >ENUMTYPE</CustomerDiscType> <!-- optional --> <CustomerType >STRTYPE</CustomerType> <!-- optional --> <EMail >STRTYPE</EMail> <!-- optional --> <IsOkToEMail >BOOLTYPE</IsOkToEMail> <!-- optional --> <FirstName >STRTYPE</FirstName> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> <IsAcceptingChecks >BOOLTYPE</IsAcceptingChecks> <!-- optional --> <IsUsingChargeAccount >BOOLTYPE</IsUsingChargeAccount> <!-- optional --> <IsUsingWithQB >BOOLTYPE</IsUsingWithQB> <!-- optional --> <IsRewardsMember >BOOLTYPE</IsRewardsMember> <!-- optional --> <IsNoShipToBilling >BOOLTYPE</IsNoShipToBilling> <!-- optional --> <LastName >STRTYPE</LastName> <!-- optional --> <LastSale >DATETYPE</LastSale> <!-- optional --> <Notes >STRTYPE</Notes> <!-- optional --> <Phone >STRTYPE</Phone> <!-- optional --> <Phone2 >STRTYPE</Phone2> <!-- optional --> <Phone3 >STRTYPE</Phone3> <!-- optional --> <Phone4 >STRTYPE</Phone4> <!-- optional --> <!-- PriceLevelNumber may have one of the following values: 1, 2, 3, 4, 5 --> <PriceLevelNumber >ENUMTYPE</PriceLevelNumber> <!-- optional --> <Salutation >STRTYPE</Salutation> <!-- optional --> <!-- StoreExchangeStatus may have one of the following values: Modified, Sent, Acknowledged --> <StoreExchangeStatus >ENUMTYPE</StoreExchangeStatus> <!-- optional --> <TaxCategory >STRTYPE</TaxCategory> <!-- optional --> <WebNumber >STRTYPE</WebNumber> <!-- optional --> <BillAddress> <!-- optional --> <City >STRTYPE</City> <!-- optional --> <Country >STRTYPE</Country> <!-- optional --> <PostalCode >STRTYPE</PostalCode> <!-- optional --> <State >STRTYPE</State> <!-- optional --> <Street >STRTYPE</Street> <!-- optional --> <Street2 >STRTYPE</Street2> <!-- optional --> </BillAddress> <DefaultShipAddress >STRTYPE</DefaultShipAddress> <!-- optional --> <ShipAddress> <!-- optional, may repeat --> <AddressName >STRTYPE</AddressName> <!-- optional --> <CompanyName >STRTYPE</CompanyName> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> <City >STRTYPE</City> <!-- optional --> <Country >STRTYPE</Country> <!-- optional --> <PostalCode >STRTYPE</PostalCode> <!-- optional --> <State >STRTYPE</State> <!-- optional --> <Street >STRTYPE</Street> <!-- optional --> <Street2 >STRTYPE</Street2> <!-- optional --> </ShipAddress> <Reward> <!-- optional, may repeat --> <RewardAmount >AMTTYPE</RewardAmount> <!-- optional --> <RewardPercent >FLOATTYPE</RewardPercent> <!-- optional --> <EarnedDate >DATETYPE</EarnedDate> <!-- optional --> <MatureDate >DATETYPE</MatureDate> <!-- optional --> <ExpirationDate >DATETYPE</ExpirationDate> <!-- optional --> </Reward> <DataExtRet> <!-- optional, may repeat --> <OwnerID >GUIDTYPE</OwnerID> <!-- required --> <DataExtName >STRTYPE</DataExtName> <!-- required --> <!-- DataExtType may have one of the following values: INTTYPE, AMTTYPE, PRICETYPE, QUANTYPE, PERCENTTYPE, DATETIMETYPE, STR255TYPE, STR1024TYPE --> <DataExtType >ENUMTYPE</DataExtType> <!-- required --> <DataExtValue >STRTYPE</DataExtValue> <!-- required --> </DataExtRet> </CustomerRet> </CustomerAddRs> </QBPOSXMLMsgsRq> </QBPOSXML> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | 'The following sample code is generated as an illustration of
'Creating requests and parsing responses ONLY
'This code is NOT intended to show best practices or ideal code
'Use at your most careful discretion
imports System
imports System.Net
imports System.Drawing
imports System.Collections
imports System.ComponentModel
imports System.Windows.Forms
imports System.Data
imports System.IO
imports Interop.qbposfc4
Public Class SampleCustomerAdd
Public Sub DoCustomerAdd()
Dim sessionBegun as Boolean
sessionBegun = False
Dim connectionOpen as Boolean
connectionOpen = False
Dim sessionManager as QBPOSSessionManager
sessionManager = nothing
Try
'Create the session Manager object
sessionManager = new QBPOSSessionManager
'Create the message set request object to hold our request
Dim requestMsgSet as IMsgSetRequest
requestMsgSet = sessionManager.CreateMsgSetRequest(4,0)
requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue
BuildCustomerAddRq(requestMsgSet)
'Connect to QuickBooks and begin a session
sessionManager.OpenConnection("","Sample Code from OSR")
connectionOpen = True
sessionManager.BeginSession("")
sessionBegun = True
'Send the request and get the response from QuickBooks
Dim responseMsgSet as IMsgSetResponse
responseMsgSet = sessionManager.DoRequests(requestMsgSet)
'End the session and close the connection to QuickBooks
sessionManager.EndSession()
sessionBegun = False
sessionManager.CloseConnection()
connectionOpen = False
WalkCustomerAddRs(responseMsgSet)
Catch e as Exception
MessageBox.Show(e.Message, "Error")
if (sessionBegun) then
sessionManager.EndSession()
End If
if (connectionOpen) then
sessionManager.CloseConnection()
End If
End Try
End Sub
Public Sub BuildCustomerAddRq(requestMsgSet as IMsgSetRequest)
Dim CustomerAddRq as ICustomerAdd
CustomerAddRq= requestMsgSet.AppendCustomerAddRq()
'Set field value for CompanyName
CustomerAddRq.CompanyName.SetValue("ab")
'Set field value for CustomerID
CustomerAddRq.CustomerID.SetValue("ab")
'Set field value for CustomerDiscPercent
CustomerAddRq.CustomerDiscPercent.SetValue(12.34)
'Set field value for CustomerDiscType
CustomerAddRq.CustomerDiscType.SetValue(ENCustomerDiscType.cdtNone)
'Set field value for CustomerType
CustomerAddRq.CustomerType.SetValue("ab")
'Set field value for EMail
CustomerAddRq.EMail.SetValue("ab")
'Set field value for IsOkToEMail
CustomerAddRq.IsOkToEMail.SetValue(True)
'Set field value for FirstName
CustomerAddRq.FirstName.SetValue("ab")
'Set field value for IsAcceptingChecks
CustomerAddRq.IsAcceptingChecks.SetValue(True)
'Set field value for IsUsingChargeAccount
CustomerAddRq.IsUsingChargeAccount.SetValue(True)
'Set field value for IsUsingWithQB
CustomerAddRq.IsUsingWithQB.SetValue(True)
'Set field value for IsRewardsMember
CustomerAddRq.IsRewardsMember.SetValue(True)
'Set field value for IsNoShipToBilling
CustomerAddRq.IsNoShipToBilling.SetValue(True)
'Set field value for LastName
CustomerAddRq.LastName.SetValue("ab")
'Set field value for Notes
CustomerAddRq.Notes.SetValue("ab")
'Set field value for Phone
CustomerAddRq.Phone.SetValue("ab")
'Set field value for Phone2
CustomerAddRq.Phone2.SetValue("ab")
'Set field value for Phone3
CustomerAddRq.Phone3.SetValue("ab")
'Set field value for Phone4
CustomerAddRq.Phone4.SetValue("ab")
'Set field value for PriceLevelNumber
CustomerAddRq.PriceLevelNumber.SetValue(ENPriceLevelNumber.pln1)
'Set field value for Salutation
CustomerAddRq.Salutation.SetValue("ab")
'Set field value for TaxCategory
CustomerAddRq.TaxCategory.SetValue("ab")
'Set field value for City
CustomerAddRq.BillAddress.City.SetValue("ab")
'Set field value for Country
CustomerAddRq.BillAddress.Country.SetValue("ab")
'Set field value for PostalCode
CustomerAddRq.BillAddress.PostalCode.SetValue("ab")
'Set field value for State
CustomerAddRq.BillAddress.State.SetValue("ab")
'Set field value for Street
CustomerAddRq.BillAddress.Street.SetValue("ab")
'Set field value for Street2
CustomerAddRq.BillAddress.Street2.SetValue("ab")
'Set field value for DefaultShipAddress
CustomerAddRq.DefaultShipAddress.SetValue("ab")
Dim ShipAddress131 as IShipAddress
ShipAddress131=CustomerAddRq.ShipAddressList.Append()
'Set field value for AddressName
ShipAddress131.AddressName.SetValue("ab")
'Set field value for CompanyName
ShipAddress131.CompanyName.SetValue("ab")
'Set field value for FullName
ShipAddress131.FullName.SetValue("ab")
'Set field value for City
ShipAddress131.City.SetValue("ab")
'Set field value for Country
ShipAddress131.Country.SetValue("ab")
'Set field value for PostalCode
ShipAddress131.PostalCode.SetValue("ab")
'Set field value for State
ShipAddress131.State.SetValue("ab")
'Set field value for Street
ShipAddress131.Street.SetValue("ab")
'Set field value for Street2
ShipAddress131.Street2.SetValue("ab")
'Set field value for IncludeRetElementList
'May create more than one of these if needed
CustomerAddRq.IncludeRetElementList.Add("ab")
End Sub
Public Sub WalkCustomerAddRs( responseMsgSet as IMsgSetResponse)
if (responseMsgSet is nothing) then
Exit Sub
End If
Dim responseList as IResponseList
responseList = responseMsgSet.ResponseList
if (responseList is nothing) then
Exit Sub
End If
'if we sent only one request, there is only one response, we'll walk the list for this sample
for j=0 to responseList.Count-1
Dim response as IResponse
response = responseList.GetAt(j)
'check the status code of the response, 0=ok, >0 is warning
if (response.StatusCode >= 0) then
'the request-specific response is in the details, make sure we have some
if (not response.Detail is nothing) then
'make sure the response is the type we're expecting
Dim responseType as ENResponseType
responseType = CType(response.Type.GetValue(),ENResponseType)
if (responseType = ENResponseType.rtCustomerAddRs) then
'upcast to more specific type here, this is safe because we checked with response.Type check above
Dim CustomerRet as ICustomerRet
CustomerRet = CType(response.Detail,ICustomerRet)
WalkCustomerRet(CustomerRet)
End If
End If
End If
Next j
End Sub
Public Sub WalkCustomerRet(CustomerRet as ICustomerRet)
if (CustomerRet is nothing) then
Exit Sub
End If
'Go through all the elements of ICustomerRet
'Get value of ListID
if ( not CustomerRet.ListID is nothing) then
Dim ListID132 as String
ListID132 = CustomerRet.ListID.GetValue()
End If
'Get value of TimeCreated
if ( not CustomerRet.TimeCreated is nothing) then
Dim TimeCreated133 as DateTime
TimeCreated133 = CustomerRet.TimeCreated.GetValue()
End If
'Get value of TimeModified
if ( not CustomerRet.TimeModified is nothing) then
Dim TimeModified134 as DateTime
TimeModified134 = CustomerRet.TimeModified.GetValue()
End If
'Get value of AccountBalance
if ( not CustomerRet.AccountBalance is nothing) then
Dim AccountBalance135 as Double
AccountBalance135 = CustomerRet.AccountBalance.GetValue()
End If
'Get value of AccountLimit
if ( not CustomerRet.AccountLimit is nothing) then
Dim AccountLimit136 as Double
AccountLimit136 = CustomerRet.AccountLimit.GetValue()
End If
'Get value of AmountPastDue
if ( not CustomerRet.AmountPastDue is nothing) then
Dim AmountPastDue137 as Double
AmountPastDue137 = CustomerRet.AmountPastDue.GetValue()
End If
'Get value of CompanyName
if ( not CustomerRet.CompanyName is nothing) then
Dim CompanyName138 as String
CompanyName138 = CustomerRet.CompanyName.GetValue()
End If
'Get value of CustomerID
if ( not CustomerRet.CustomerID is nothing) then
Dim CustomerID139 as String
CustomerID139 = CustomerRet.CustomerID.GetValue()
End If
'Get value of CustomerDiscPercent
if ( not CustomerRet.CustomerDiscPercent is nothing) then
Dim CustomerDiscPercent140 as Single
CustomerDiscPercent140 = CustomerRet.CustomerDiscPercent.GetValue()
End If
'Get value of CustomerDiscType
if ( not CustomerRet.CustomerDiscType is nothing) then
Dim CustomerDiscType141 as ENCustomerDiscType
CustomerDiscType141 = CustomerRet.CustomerDiscType.GetValue()
End If
'Get value of CustomerType
if ( not CustomerRet.CustomerType is nothing) then
Dim CustomerType142 as String
CustomerType142 = CustomerRet.CustomerType.GetValue()
End If
'Get value of EMail
if ( not CustomerRet.EMail is nothing) then
Dim EMail143 as String
EMail143 = CustomerRet.EMail.GetValue()
End If
'Get value of IsOkToEMail
if ( not CustomerRet.IsOkToEMail is nothing) then
Dim IsOkToEMail144 as Boolean
IsOkToEMail144 = CustomerRet.IsOkToEMail.GetValue()
End If
'Get value of FirstName
if ( not CustomerRet.FirstName is nothing) then
Dim FirstName145 as String
FirstName145 = CustomerRet.FirstName.GetValue()
End If
'Get value of FullName
if ( not CustomerRet.FullName is nothing) then
Dim FullName146 as String
FullName146 = CustomerRet.FullName.GetValue()
End If
'Get value of IsAcceptingChecks
if ( not CustomerRet.IsAcceptingChecks is nothing) then
Dim IsAcceptingChecks147 as Boolean
IsAcceptingChecks147 = CustomerRet.IsAcceptingChecks.GetValue()
End If
'Get value of IsUsingChargeAccount
if ( not CustomerRet.IsUsingChargeAccount is nothing) then
Dim IsUsingChargeAccount148 as Boolean
IsUsingChargeAccount148 = CustomerRet.IsUsingChargeAccount.GetValue()
End If
'Get value of IsUsingWithQB
if ( not CustomerRet.IsUsingWithQB is nothing) then
Dim IsUsingWithQB149 as Boolean
IsUsingWithQB149 = CustomerRet.IsUsingWithQB.GetValue()
End If
'Get value of IsRewardsMember
if ( not CustomerRet.IsRewardsMember is nothing) then
Dim IsRewardsMember150 as Boolean
IsRewardsMember150 = CustomerRet.IsRewardsMember.GetValue()
End If
'Get value of IsNoShipToBilling
if ( not CustomerRet.IsNoShipToBilling is nothing) then
Dim IsNoShipToBilling151 as Boolean
IsNoShipToBilling151 = CustomerRet.IsNoShipToBilling.GetValue()
End If
'Get value of LastName
if ( not CustomerRet.LastName is nothing) then
Dim LastName152 as String
LastName152 = CustomerRet.LastName.GetValue()
End If
'Get value of LastSale
if ( not CustomerRet.LastSale is nothing) then
Dim LastSale153 as DateTime
LastSale153 = CustomerRet.LastSale.GetValue()
End If
'Get value of Notes
if ( not CustomerRet.Notes is nothing) then
Dim Notes154 as String
Notes154 = CustomerRet.Notes.GetValue()
End If
'Get value of Phone
if ( not CustomerRet.Phone is nothing) then
Dim Phone155 as String
Phone155 = CustomerRet.Phone.GetValue()
End If
'Get value of Phone2
if ( not CustomerRet.Phone2 is nothing) then
Dim Phone2156 as String
Phone2156 = CustomerRet.Phone2.GetValue()
End If
'Get value of Phone3
if ( not CustomerRet.Phone3 is nothing) then
Dim Phone3157 as String
Phone3157 = CustomerRet.Phone3.GetValue()
End If
'Get value of Phone4
if ( not CustomerRet.Phone4 is nothing) then
Dim Phone4158 as String
Phone4158 = CustomerRet.Phone4.GetValue()
End If
'Get value of PriceLevelNumber
if ( not CustomerRet.PriceLevelNumber is nothing) then
Dim PriceLevelNumber159 as ENPriceLevelNumber
PriceLevelNumber159 = CustomerRet.PriceLevelNumber.GetValue()
End If
'Get value of Salutation
if ( not CustomerRet.Salutation is nothing) then
Dim Salutation160 as String
Salutation160 = CustomerRet.Salutation.GetValue()
End If
'Get value of StoreExchangeStatus
if ( not CustomerRet.StoreExchangeStatus is nothing) then
Dim StoreExchangeStatus161 as ENStoreExchangeStatus
StoreExchangeStatus161 = CustomerRet.StoreExchangeStatus.GetValue()
End If
'Get value of TaxCategory
if ( not CustomerRet.TaxCategory is nothing) then
Dim TaxCategory162 as String
TaxCategory162 = CustomerRet.TaxCategory.GetValue()
End If
'Get value of WebNumber
if ( not CustomerRet.WebNumber is nothing) then
Dim WebNumber163 as String
WebNumber163 = CustomerRet.WebNumber.GetValue()
End If
if (not CustomerRet.BillAddress is nothing) then
'Get value of City
if ( not CustomerRet.BillAddress.City is nothing) then
Dim City164 as String
City164 = CustomerRet.BillAddress.City.GetValue()
End If
'Get value of Country
if ( not CustomerRet.BillAddress.Country is nothing) then
Dim Country165 as String
Country165 = CustomerRet.BillAddress.Country.GetValue()
End If
'Get value of PostalCode
if ( not CustomerRet.BillAddress.PostalCode is nothing) then
Dim PostalCode166 as String
PostalCode166 = CustomerRet.BillAddress.PostalCode.GetValue()
End If
'Get value of State
if ( not CustomerRet.BillAddress.State is nothing) then
Dim State167 as String
State167 = CustomerRet.BillAddress.State.GetValue()
End If
'Get value of Street
if ( not CustomerRet.BillAddress.Street is nothing) then
Dim Street168 as String
Street168 = CustomerRet.BillAddress.Street.GetValue()
End If
'Get value of Street2
if ( not CustomerRet.BillAddress.Street2 is nothing) then
Dim Street2169 as String
Street2169 = CustomerRet.BillAddress.Street2.GetValue()
End If
End If
'Get value of DefaultShipAddress
if ( not CustomerRet.DefaultShipAddress is nothing) then
Dim DefaultShipAddress170 as String
DefaultShipAddress170 = CustomerRet.DefaultShipAddress.GetValue()
End If
if (not CustomerRet.ShipAddressList is nothing)
Dim i171 as Integer
for i171 = 0 to CustomerRet.ShipAddressList.Count - 1
Dim ShipAddress as IShipAddress
ShipAddress = CustomerRet.ShipAddressList.GetAt(i171)
'Get value of AddressName
if ( not ShipAddress.AddressName is nothing) then
Dim AddressName172 as String
AddressName172 = ShipAddress.AddressName.GetValue()
End If
'Get value of CompanyName
if ( not ShipAddress.CompanyName is nothing) then
Dim CompanyName173 as String
CompanyName173 = ShipAddress.CompanyName.GetValue()
End If
'Get value of FullName
if ( not ShipAddress.FullName is nothing) then
Dim FullName174 as String
FullName174 = ShipAddress.FullName.GetValue()
End If
'Get value of City
if ( not ShipAddress.City is nothing) then
Dim City175 as String
City175 = ShipAddress.City.GetValue()
End If
'Get value of Country
if ( not ShipAddress.Country is nothing) then
Dim Country176 as String
Country176 = ShipAddress.Country.GetValue()
End If
'Get value of PostalCode
if ( not ShipAddress.PostalCode is nothing) then
Dim PostalCode177 as String
PostalCode177 = ShipAddress.PostalCode.GetValue()
End If
'Get value of State
if ( not ShipAddress.State is nothing) then
Dim State178 as String
State178 = ShipAddress.State.GetValue()
End If
'Get value of Street
if ( not ShipAddress.Street is nothing) then
Dim Street179 as String
Street179 = ShipAddress.Street.GetValue()
End If
'Get value of Street2
if ( not ShipAddress.Street2 is nothing) then
Dim Street2180 as String
Street2180 = ShipAddress.Street2.GetValue()
End If
Next i171
End If
if (not CustomerRet.RewardList is nothing)
Dim i181 as Integer
for i181 = 0 to CustomerRet.RewardList.Count - 1
Dim Reward as IReward
Reward = CustomerRet.RewardList.GetAt(i181)
'Get value of RewardAmount
if ( not Reward.RewardAmount is nothing) then
Dim RewardAmount182 as Double
RewardAmount182 = Reward.RewardAmount.GetValue()
End If
'Get value of RewardPercent
if ( not Reward.RewardPercent is nothing) then
Dim RewardPercent183 as Single
RewardPercent183 = Reward.RewardPercent.GetValue()
End If
'Get value of EarnedDate
if ( not Reward.EarnedDate is nothing) then
Dim EarnedDate184 as DateTime
EarnedDate184 = Reward.EarnedDate.GetValue()
End If
'Get value of MatureDate
if ( not Reward.MatureDate is nothing) then
Dim MatureDate185 as DateTime
MatureDate185 = Reward.MatureDate.GetValue()
End If
'Get value of ExpirationDate
if ( not Reward.ExpirationDate is nothing) then
Dim ExpirationDate186 as DateTime
ExpirationDate186 = Reward.ExpirationDate.GetValue()
End If
Next i181
End If
if (not CustomerRet.DataExtRetList is nothing)
Dim i187 as Integer
for i187 = 0 to CustomerRet.DataExtRetList.Count - 1
Dim DataExtRet as IDataExtRet
DataExtRet = CustomerRet.DataExtRetList.GetAt(i187)
'Get value of OwnerID
Dim OwnerID188 as String
OwnerID188 = DataExtRet.OwnerID.GetValue()
'Get value of DataExtName
Dim DataExtName189 as String
DataExtName189 = DataExtRet.DataExtName.GetValue()
'Get value of DataExtType
Dim DataExtType190 as ENDataExtType
DataExtType190 = DataExtRet.DataExtType.GetValue()
'Get value of DataExtValue
Dim DataExtValue191 as String
DataExtValue191 = DataExtRet.DataExtValue.GetValue()
Next i187
End If
End Sub
End Class
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | //The following sample code is generated as an illustration of //Creating requests and parsing responses ONLY //This code is NOT intended to show best practices or ideal code //Use at your most careful discretion using System; using System.Net; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using Interop.qbposfc4; namespace com.intuit.idn.samples { public class SampleCustomerAdd { public void DoCustomerAdd() { bool sessionBegun = false; bool connectionOpen = false; QBPOSSessionManager sessionManager = null; try { //Create the session Manager object sessionManager = new QBPOSSessionManager(); //Create the message set request object to hold our request IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest(4,0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; BuildCustomerAddRq(requestMsgSet); //Connect to QuickBooks and begin a session sessionManager.OpenConnection("","Sample Code from OSR"); connectionOpen = true; sessionManager.BeginSession(""); sessionBegun = true; //Send the request and get the response from QuickBooks IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); //End the session and close the connection to QuickBooks sessionManager.EndSession(); sessionBegun = false; sessionManager.CloseConnection(); connectionOpen = false; WalkCustomerAddRs(responseMsgSet); } catch (Exception e) { MessageBox.Show(e.Message, "Error"); if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } } void BuildCustomerAddRq(IMsgSetRequest requestMsgSet) { ICustomerAdd CustomerAddRq= requestMsgSet.AppendCustomerAddRq(); //Set attributes //Set field value for defMacro CustomerAddRq.defMacro.SetValue("IQBStringType"); //Set field value for CompanyName CustomerAddRq.CompanyName.SetValue("ab"); //Set field value for CustomerID CustomerAddRq.CustomerID.SetValue("ab"); //Set field value for CustomerDiscPercent CustomerAddRq.CustomerDiscPercent.SetValue(12.34F); //Set field value for CustomerDiscType CustomerAddRq.CustomerDiscType.SetValue(ENCustomerDiscType.cdtNone); //Set field value for CustomerType CustomerAddRq.CustomerType.SetValue("ab"); //Set field value for EMail CustomerAddRq.EMail.SetValue("ab"); //Set field value for IsOkToEMail CustomerAddRq.IsOkToEMail.SetValue(true); //Set field value for FirstName CustomerAddRq.FirstName.SetValue("ab"); //Set field value for IsAcceptingChecks CustomerAddRq.IsAcceptingChecks.SetValue(true); //Set field value for IsUsingChargeAccount CustomerAddRq.IsUsingChargeAccount.SetValue(true); //Set field value for IsUsingWithQB CustomerAddRq.IsUsingWithQB.SetValue(true); //Set field value for IsRewardsMember CustomerAddRq.IsRewardsMember.SetValue(true); //Set field value for IsNoShipToBilling CustomerAddRq.IsNoShipToBilling.SetValue(true); //Set field value for LastName CustomerAddRq.LastName.SetValue("ab"); //Set field value for Notes CustomerAddRq.Notes.SetValue("ab"); //Set field value for Phone CustomerAddRq.Phone.SetValue("ab"); //Set field value for Phone2 CustomerAddRq.Phone2.SetValue("ab"); //Set field value for Phone3 CustomerAddRq.Phone3.SetValue("ab"); //Set field value for Phone4 CustomerAddRq.Phone4.SetValue("ab"); //Set field value for PriceLevelNumber CustomerAddRq.PriceLevelNumber.SetValue(ENPriceLevelNumber.pln1); //Set field value for Salutation CustomerAddRq.Salutation.SetValue("ab"); //Set field value for TaxCategory CustomerAddRq.TaxCategory.SetValue("ab"); //Set field value for City CustomerAddRq.BillAddress.City.SetValue("ab"); //Set field value for Country CustomerAddRq.BillAddress.Country.SetValue("ab"); //Set field value for PostalCode CustomerAddRq.BillAddress.PostalCode.SetValue("ab"); //Set field value for State CustomerAddRq.BillAddress.State.SetValue("ab"); //Set field value for Street CustomerAddRq.BillAddress.Street.SetValue("ab"); //Set field value for Street2 CustomerAddRq.BillAddress.Street2.SetValue("ab"); //Set field value for DefaultShipAddress CustomerAddRq.DefaultShipAddress.SetValue("ab"); IShipAddress ShipAddress192=CustomerAddRq.ShipAddressList.Append(); //Set field value for AddressName ShipAddress192.AddressName.SetValue("ab"); //Set field value for CompanyName ShipAddress192.CompanyName.SetValue("ab"); //Set field value for FullName ShipAddress192.FullName.SetValue("ab"); //Set field value for City ShipAddress192.City.SetValue("ab"); //Set field value for Country ShipAddress192.Country.SetValue("ab"); //Set field value for PostalCode ShipAddress192.PostalCode.SetValue("ab"); //Set field value for State ShipAddress192.State.SetValue("ab"); //Set field value for Street ShipAddress192.Street.SetValue("ab"); //Set field value for Street2 ShipAddress192.Street2.SetValue("ab"); //Set field value for IncludeRetElementList //May create more than one of these if needed CustomerAddRq.IncludeRetElementList.Add("ab"); } void WalkCustomerAddRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) return; IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) return; //if we sent only one request, there is only one response, we'll walk the list for this sample for(int i=0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); //check the status code of the response, 0=ok, >0 is warning if (response.StatusCode >= 0) { //the request-specific response is in the details, make sure we have some if (response.Detail != null) { //make sure the response is the type we're expecting ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtCustomerAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above ICustomerRet CustomerRet = (ICustomerRet)response.Detail; WalkCustomerRet(CustomerRet); } } } } } void WalkCustomerRet(ICustomerRet CustomerRet) { if (CustomerRet == null) return; //Go through all the elements of ICustomerRet //Get value of ListID if (CustomerRet.ListID != null) { string ListID193 = (string)CustomerRet.ListID.GetValue(); } //Get value of TimeCreated if (CustomerRet.TimeCreated != null) { DateTime TimeCreated194 = (DateTime)CustomerRet.TimeCreated.GetValue(); } //Get value of TimeModified if (CustomerRet.TimeModified != null) { DateTime TimeModified195 = (DateTime)CustomerRet.TimeModified.GetValue(); } //Get value of AccountBalance if (CustomerRet.AccountBalance != null) { double AccountBalance196 = (double)CustomerRet.AccountBalance.GetValue(); } //Get value of AccountLimit if (CustomerRet.AccountLimit != null) { double AccountLimit197 = (double)CustomerRet.AccountLimit.GetValue(); } //Get value of AmountPastDue if (CustomerRet.AmountPastDue != null) { double AmountPastDue198 = (double)CustomerRet.AmountPastDue.GetValue(); } //Get value of CompanyName if (CustomerRet.CompanyName != null) { string CompanyName199 = (string)CustomerRet.CompanyName.GetValue(); } //Get value of CustomerID if (CustomerRet.CustomerID != null) { string CustomerID200 = (string)CustomerRet.CustomerID.GetValue(); } //Get value of CustomerDiscPercent if (CustomerRet.CustomerDiscPercent != null) { float CustomerDiscPercent201 = (float)CustomerRet.CustomerDiscPercent.GetValue(); } //Get value of CustomerDiscType if (CustomerRet.CustomerDiscType != null) { ENCustomerDiscType CustomerDiscType202 = (ENCustomerDiscType)CustomerRet.CustomerDiscType.GetValue(); } //Get value of CustomerType if (CustomerRet.CustomerType != null) { string CustomerType203 = (string)CustomerRet.CustomerType.GetValue(); } //Get value of EMail if (CustomerRet.EMail != null) { string EMail204 = (string)CustomerRet.EMail.GetValue(); } //Get value of IsOkToEMail if (CustomerRet.IsOkToEMail != null) { bool IsOkToEMail205 = (bool)CustomerRet.IsOkToEMail.GetValue(); } //Get value of FirstName if (CustomerRet.FirstName != null) { string FirstName206 = (string)CustomerRet.FirstName.GetValue(); } //Get value of FullName if (CustomerRet.FullName != null) { string FullName207 = (string)CustomerRet.FullName.GetValue(); } //Get value of IsAcceptingChecks if (CustomerRet.IsAcceptingChecks != null) { bool IsAcceptingChecks208 = (bool)CustomerRet.IsAcceptingChecks.GetValue(); } //Get value of IsUsingChargeAccount if (CustomerRet.IsUsingChargeAccount != null) { bool IsUsingChargeAccount209 = (bool)CustomerRet.IsUsingChargeAccount.GetValue(); } //Get value of IsUsingWithQB if (CustomerRet.IsUsingWithQB != null) { bool IsUsingWithQB210 = (bool)CustomerRet.IsUsingWithQB.GetValue(); } //Get value of IsRewardsMember if (CustomerRet.IsRewardsMember != null) { bool IsRewardsMember211 = (bool)CustomerRet.IsRewardsMember.GetValue(); } //Get value of IsNoShipToBilling if (CustomerRet.IsNoShipToBilling != null) { bool IsNoShipToBilling212 = (bool)CustomerRet.IsNoShipToBilling.GetValue(); } //Get value of LastName if (CustomerRet.LastName != null) { string LastName213 = (string)CustomerRet.LastName.GetValue(); } //Get value of LastSale if (CustomerRet.LastSale != null) { DateTime LastSale214 = (DateTime)CustomerRet.LastSale.GetValue(); } //Get value of Notes if (CustomerRet.Notes != null) { string Notes215 = (string)CustomerRet.Notes.GetValue(); } //Get value of Phone if (CustomerRet.Phone != null) { string Phone216 = (string)CustomerRet.Phone.GetValue(); } //Get value of Phone2 if (CustomerRet.Phone2 != null) { string Phone2217 = (string)CustomerRet.Phone2.GetValue(); } //Get value of Phone3 if (CustomerRet.Phone3 != null) { string Phone3218 = (string)CustomerRet.Phone3.GetValue(); } //Get value of Phone4 if (CustomerRet.Phone4 != null) { string Phone4219 = (string)CustomerRet.Phone4.GetValue(); } //Get value of PriceLevelNumber if (CustomerRet.PriceLevelNumber != null) { ENPriceLevelNumber PriceLevelNumber220 = (ENPriceLevelNumber)CustomerRet.PriceLevelNumber.GetValue(); } //Get value of Salutation if (CustomerRet.Salutation != null) { string Salutation221 = (string)CustomerRet.Salutation.GetValue(); } //Get value of StoreExchangeStatus if (CustomerRet.StoreExchangeStatus != null) { ENStoreExchangeStatus StoreExchangeStatus222 = (ENStoreExchangeStatus)CustomerRet.StoreExchangeStatus.GetValue(); } //Get value of TaxCategory if (CustomerRet.TaxCategory != null) { string TaxCategory223 = (string)CustomerRet.TaxCategory.GetValue(); } //Get value of WebNumber if (CustomerRet.WebNumber != null) { string WebNumber224 = (string)CustomerRet.WebNumber.GetValue(); } if (CustomerRet.BillAddress != null) { //Get value of City if (CustomerRet.BillAddress.City != null) { string City225 = (string)CustomerRet.BillAddress.City.GetValue(); } //Get value of Country if (CustomerRet.BillAddress.Country != null) { string Country226 = (string)CustomerRet.BillAddress.Country.GetValue(); } //Get value of PostalCode if (CustomerRet.BillAddress.PostalCode != null) { string PostalCode227 = (string)CustomerRet.BillAddress.PostalCode.GetValue(); } //Get value of State if (CustomerRet.BillAddress.State != null) { string State228 = (string)CustomerRet.BillAddress.State.GetValue(); } //Get value of Street if (CustomerRet.BillAddress.Street != null) { string Street229 = (string)CustomerRet.BillAddress.Street.GetValue(); } //Get value of Street2 if (CustomerRet.BillAddress.Street2 != null) { string Street2230 = (string)CustomerRet.BillAddress.Street2.GetValue(); } } //Get value of DefaultShipAddress if (CustomerRet.DefaultShipAddress != null) { string DefaultShipAddress231 = (string)CustomerRet.DefaultShipAddress.GetValue(); } if (CustomerRet.ShipAddressList != null) { for (int i232 = 0; i232 < CustomerRet.ShipAddressList.Count; i232++) { IShipAddress ShipAddress = CustomerRet.ShipAddressList.GetAt(i232); //Get value of AddressName if (ShipAddress.AddressName != null) { string AddressName233 = (string)ShipAddress.AddressName.GetValue(); } //Get value of CompanyName if (ShipAddress.CompanyName != null) { string CompanyName234 = (string)ShipAddress.CompanyName.GetValue(); } //Get value of FullName if (ShipAddress.FullName != null) { string FullName235 = (string)ShipAddress.FullName.GetValue(); } //Get value of City if (ShipAddress.City != null) { string City236 = (string)ShipAddress.City.GetValue(); } //Get value of Country if (ShipAddress.Country != null) { string Country237 = (string)ShipAddress.Country.GetValue(); } //Get value of PostalCode if (ShipAddress.PostalCode != null) { string PostalCode238 = (string)ShipAddress.PostalCode.GetValue(); } //Get value of State if (ShipAddress.State != null) { string State239 = (string)ShipAddress.State.GetValue(); } //Get value of Street if (ShipAddress.Street != null) { string Street240 = (string)ShipAddress.Street.GetValue(); } //Get value of Street2 if (ShipAddress.Street2 != null) { string Street2241 = (string)ShipAddress.Street2.GetValue(); } } } if (CustomerRet.RewardList != null) { for (int i242 = 0; i242 < CustomerRet.RewardList.Count; i242++) { IReward Reward = CustomerRet.RewardList.GetAt(i242); //Get value of RewardAmount if (Reward.RewardAmount != null) { double RewardAmount243 = (double)Reward.RewardAmount.GetValue(); } //Get value of RewardPercent if (Reward.RewardPercent != null) { float RewardPercent244 = (float)Reward.RewardPercent.GetValue(); } //Get value of EarnedDate if (Reward.EarnedDate != null) { DateTime EarnedDate245 = (DateTime)Reward.EarnedDate.GetValue(); } //Get value of MatureDate if (Reward.MatureDate != null) { DateTime MatureDate246 = (DateTime)Reward.MatureDate.GetValue(); } //Get value of ExpirationDate if (Reward.ExpirationDate != null) { DateTime ExpirationDate247 = (DateTime)Reward.ExpirationDate.GetValue(); } } } if (CustomerRet.DataExtRetList != null) { for (int i248 = 0; i248 < CustomerRet.DataExtRetList.Count; i248++) { IDataExtRet DataExtRet = CustomerRet.DataExtRetList.GetAt(i248); //Get value of OwnerID string OwnerID249 = (string)DataExtRet.OwnerID.GetValue(); //Get value of DataExtName string DataExtName250 = (string)DataExtRet.DataExtName.GetValue(); //Get value of DataExtType ENDataExtType DataExtType251 = (ENDataExtType)DataExtRet.DataExtType.GetValue(); //Get value of DataExtValue string DataExtValue252 = (string)DataExtRet.DataExtValue.GetValue(); } } } } } |