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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | <?xml version="1.0" encoding="utf-8"?> <?qbxml version="16.0"?> <QBXML> <QBXMLMsgsRq onError="stopOnError"> <ItemInventoryAddRq> <ItemInventoryAdd> <!-- required --> <Name >STRTYPE</Name> <!-- required --> <BarCode> <!-- optional --> <BarCodeValue >STRTYPE</BarCodeValue> <!-- optional --> <AssignEvenIfUsed >BOOLTYPE</AssignEvenIfUsed> <!-- optional --> <AllowOverride >BOOLTYPE</AllowOverride> <!-- optional --> </BarCode> <IsActive >BOOLTYPE</IsActive> <!-- optional --> <ClassRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </ClassRef> <ParentRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </ParentRef> <ManufacturerPartNumber >STRTYPE</ManufacturerPartNumber> <!-- optional --> <UnitOfMeasureSetRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </UnitOfMeasureSetRef> <IsTaxIncluded >BOOLTYPE</IsTaxIncluded> <!-- optional --> <SalesTaxCodeRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </SalesTaxCodeRef> <SalesDesc >STRTYPE</SalesDesc> <!-- optional --> <SalesPrice >PRICETYPE</SalesPrice> <!-- optional --> <IncomeAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </IncomeAccountRef> <PurchaseDesc >STRTYPE</PurchaseDesc> <!-- optional --> <PurchaseCost >PRICETYPE</PurchaseCost> <!-- optional --> <PurchaseTaxCodeRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </PurchaseTaxCodeRef> <COGSAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </COGSAccountRef> <PrefVendorRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </PrefVendorRef> <AssetAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </AssetAccountRef> <ReorderPoint >QUANTYPE</ReorderPoint> <!-- optional --> <Max >QUANTYPE</Max> <!-- optional --> <QuantityOnHand >QUANTYPE</QuantityOnHand> <!-- optional --> <TotalValue >AMTTYPE</TotalValue> <!-- optional --> <InventoryDate >DATETYPE</InventoryDate> <!-- optional --> <ExternalGUID >GUIDTYPE</ExternalGUID> <!-- optional --> </ItemInventoryAdd> <IncludeRetElement >STRTYPE</IncludeRetElement> <!-- optional, may repeat --> </ItemInventoryAddRq> <ItemInventoryAddRs statusCode="INTTYPE" statusSeverity="STRTYPE" statusMessage="STRTYPE"> <ItemInventoryRet> <!-- optional --> <ListID >IDTYPE</ListID> <!-- required --> <TimeCreated >DATETIMETYPE</TimeCreated> <!-- required --> <TimeModified >DATETIMETYPE</TimeModified> <!-- required --> <EditSequence >STRTYPE</EditSequence> <!-- required --> <Name >STRTYPE</Name> <!-- required --> <FullName >STRTYPE</FullName> <!-- required --> <BarCodeValue >STRTYPE</BarCodeValue> <!-- optional --> <IsActive >BOOLTYPE</IsActive> <!-- optional --> <ClassRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </ClassRef> <ParentRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </ParentRef> <Sublevel >INTTYPE</Sublevel> <!-- required --> <ManufacturerPartNumber >STRTYPE</ManufacturerPartNumber> <!-- optional --> <UnitOfMeasureSetRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </UnitOfMeasureSetRef> <IsTaxIncluded >BOOLTYPE</IsTaxIncluded> <!-- optional --> <SalesTaxCodeRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </SalesTaxCodeRef> <SalesDesc >STRTYPE</SalesDesc> <!-- optional --> <SalesPrice >PRICETYPE</SalesPrice> <!-- optional --> <IncomeAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </IncomeAccountRef> <PurchaseDesc >STRTYPE</PurchaseDesc> <!-- optional --> <PurchaseCost >PRICETYPE</PurchaseCost> <!-- optional --> <PurchaseTaxCodeRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </PurchaseTaxCodeRef> <COGSAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </COGSAccountRef> <PrefVendorRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </PrefVendorRef> <AssetAccountRef> <!-- optional --> <ListID >IDTYPE</ListID> <!-- optional --> <FullName >STRTYPE</FullName> <!-- optional --> </AssetAccountRef> <ReorderPoint >QUANTYPE</ReorderPoint> <!-- optional --> <Max >QUANTYPE</Max> <!-- optional --> <QuantityOnHand >QUANTYPE</QuantityOnHand> <!-- optional --> <AverageCost >PRICETYPE</AverageCost> <!-- optional --> <QuantityOnOrder >QUANTYPE</QuantityOnOrder> <!-- optional --> <QuantityOnSalesOrder >QUANTYPE</QuantityOnSalesOrder> <!-- optional --> <ExternalGUID >GUIDTYPE</ExternalGUID> <!-- optional --> <DataExtRet> <!-- optional, may repeat --> <OwnerID >GUIDTYPE</OwnerID> <!-- optional --> <DataExtName >STRTYPE</DataExtName> <!-- required --> <!-- DataExtType may have one of the following values: AMTTYPE, DATETIMETYPE, INTTYPE, PERCENTTYPE, PRICETYPE, QUANTYPE, STR1024TYPE, STR255TYPE --> <DataExtType >ENUMTYPE</DataExtType> <!-- required --> <DataExtValue >STRTYPE</DataExtValue> <!-- required --> </DataExtRet> </ItemInventoryRet> <ErrorRecovery> <!-- optional --> <!-- BEGIN OR --> <ListID >IDTYPE</ListID> <!-- optional --> <!-- OR --> <OwnerID >GUIDTYPE</OwnerID> <!-- optional --> <!-- OR --> <TxnID >IDTYPE</TxnID> <!-- optional --> <!-- END OR --> <TxnNumber >INTTYPE</TxnNumber> <!-- optional --> <EditSequence >STRTYPE</EditSequence> <!-- optional --> <ExternalGUID >GUIDTYPE</ExternalGUID> <!-- optional --> </ErrorRecovery> </ItemInventoryAddRs> </QBXMLMsgsRq> </QBXML> |
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 | '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.QBFC16 Module com.intuit.idn.samples Public Class Sample Public Sub DoItemInventoryAdd() Dim sessionBegun as Boolean sessionBegun = False Dim connectionOpen as Boolean connectionOpen = False Dim sessionManager as QBSessionManager sessionManager = nothing Try 'Create the session Manager object sessionManager = new QBSessionManager 'Create the message set request object to hold our request Dim requestMsgSet as IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US",16,0) requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue BuildItemInventoryAddRq(requestMsgSet) 'Connect to QuickBooks and begin a session sessionManager.OpenConnection("","Sample Code from OSR") connectionOpen = True sessionManager.BeginSession("", ENOpenMode.omDontCare) 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 WalkItemInventoryAddRs(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 BuildItemInventoryAddRq(requestMsgSet as IMsgSetRequest) Dim ItemInventoryAddRq as IItemInventoryAdd ItemInventoryAddRq= requestMsgSet.AppendItemInventoryAddRq() 'Set field value for Name ItemInventoryAddRq.Name.SetValue("ab") 'Set field value for BarCodeValue ItemInventoryAddRq.BarCode.BarCodeValue.SetValue("ab") 'Set field value for AssignEvenIfUsed ItemInventoryAddRq.BarCode.AssignEvenIfUsed.SetValue(True) 'Set field value for AllowOverride ItemInventoryAddRq.BarCode.AllowOverride.SetValue(True) 'Set field value for IsActive ItemInventoryAddRq.IsActive.SetValue(True) 'Set field value for ListID ItemInventoryAddRq.ClassRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.ClassRef.FullName.SetValue("ab") 'Set field value for ListID ItemInventoryAddRq.ParentRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.ParentRef.FullName.SetValue("ab") 'Set field value for ManufacturerPartNumber ItemInventoryAddRq.ManufacturerPartNumber.SetValue("ab") 'Set field value for ListID ItemInventoryAddRq.UnitOfMeasureSetRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.UnitOfMeasureSetRef.FullName.SetValue("ab") 'Set field value for IsTaxIncluded ItemInventoryAddRq.IsTaxIncluded.SetValue(True) 'Set field value for ListID ItemInventoryAddRq.SalesTaxCodeRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.SalesTaxCodeRef.FullName.SetValue("ab") 'Set field value for SalesDesc ItemInventoryAddRq.SalesDesc.SetValue("ab") 'Set field value for SalesPrice ItemInventoryAddRq.SalesPrice.SetValue(15.65) 'Set field value for ListID ItemInventoryAddRq.IncomeAccountRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.IncomeAccountRef.FullName.SetValue("ab") 'Set field value for PurchaseDesc ItemInventoryAddRq.PurchaseDesc.SetValue("ab") 'Set field value for PurchaseCost ItemInventoryAddRq.PurchaseCost.SetValue(15.65) 'Set field value for ListID ItemInventoryAddRq.PurchaseTaxCodeRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.PurchaseTaxCodeRef.FullName.SetValue("ab") 'Set field value for ListID ItemInventoryAddRq.COGSAccountRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.COGSAccountRef.FullName.SetValue("ab") 'Set field value for ListID ItemInventoryAddRq.PrefVendorRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.PrefVendorRef.FullName.SetValue("ab") 'Set field value for ListID ItemInventoryAddRq.AssetAccountRef.ListID.SetValue("200000-1011023419") 'Set field value for FullName ItemInventoryAddRq.AssetAccountRef.FullName.SetValue("ab") 'Set field value for ReorderPoint ItemInventoryAddRq.ReorderPoint.SetValue(2) 'Set field value for Max ItemInventoryAddRq.Max.SetValue(2) 'Set field value for QuantityOnHand ItemInventoryAddRq.QuantityOnHand.SetValue(2) 'Set field value for TotalValue ItemInventoryAddRq.TotalValue.SetValue(10.01) 'Set field value for InventoryDate ItemInventoryAddRq.InventoryDate.SetValue(DateTime.Parse("12/15/2007")) 'Set field value for ExternalGUID ItemInventoryAddRq.ExternalGUID.SetValue(System.Guid.NewGuid().ToString()) 'Set field value for IncludeRetElementList 'May create more than one of these if needed ItemInventoryAddRq.IncludeRetElementList.Add("ab") End Sub Public Sub WalkItemInventoryAddRs( 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.rtItemInventoryAddRs) then 'upcast to more specific type here, this is safe because we checked with response.Type check above Dim ItemInventoryRet as IItemInventoryRet ItemInventoryRet = CType(response.Detail,IItemInventoryRet) WalkItemInventoryRet(ItemInventoryRet) End If End If End If Next j End Sub Public Sub WalkItemInventoryRet(ItemInventoryRet as IItemInventoryRet) if (ItemInventoryRet is nothing) then Exit Sub End If 'Go through all the elements of IItemInventoryRet 'Get value of ListID Dim ListID12832 as String ListID12832 = ItemInventoryRet.ListID.GetValue() 'Get value of TimeCreated Dim TimeCreated12833 as DateTime TimeCreated12833 = ItemInventoryRet.TimeCreated.GetValue() 'Get value of TimeModified Dim TimeModified12834 as DateTime TimeModified12834 = ItemInventoryRet.TimeModified.GetValue() 'Get value of EditSequence Dim EditSequence12835 as String EditSequence12835 = ItemInventoryRet.EditSequence.GetValue() 'Get value of Name Dim Name12836 as String Name12836 = ItemInventoryRet.Name.GetValue() 'Get value of FullName Dim FullName12837 as String FullName12837 = ItemInventoryRet.FullName.GetValue() 'Get value of BarCodeValue if ( not ItemInventoryRet.BarCodeValue is nothing) then Dim BarCodeValue12838 as String BarCodeValue12838 = ItemInventoryRet.BarCodeValue.GetValue() End If 'Get value of IsActive if ( not ItemInventoryRet.IsActive is nothing) then Dim IsActive12839 as Boolean IsActive12839 = ItemInventoryRet.IsActive.GetValue() End If if (not ItemInventoryRet.ClassRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.ClassRef.ListID is nothing) then Dim ListID12840 as String ListID12840 = ItemInventoryRet.ClassRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.ClassRef.FullName is nothing) then Dim FullName12841 as String FullName12841 = ItemInventoryRet.ClassRef.FullName.GetValue() End If End If if (not ItemInventoryRet.ParentRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.ParentRef.ListID is nothing) then Dim ListID12842 as String ListID12842 = ItemInventoryRet.ParentRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.ParentRef.FullName is nothing) then Dim FullName12843 as String FullName12843 = ItemInventoryRet.ParentRef.FullName.GetValue() End If End If 'Get value of Sublevel Dim Sublevel12844 as Integer Sublevel12844 = ItemInventoryRet.Sublevel.GetValue() 'Get value of ManufacturerPartNumber if ( not ItemInventoryRet.ManufacturerPartNumber is nothing) then Dim ManufacturerPartNumber12845 as String ManufacturerPartNumber12845 = ItemInventoryRet.ManufacturerPartNumber.GetValue() End If if (not ItemInventoryRet.UnitOfMeasureSetRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.UnitOfMeasureSetRef.ListID is nothing) then Dim ListID12846 as String ListID12846 = ItemInventoryRet.UnitOfMeasureSetRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.UnitOfMeasureSetRef.FullName is nothing) then Dim FullName12847 as String FullName12847 = ItemInventoryRet.UnitOfMeasureSetRef.FullName.GetValue() End If End If 'Get value of IsTaxIncluded if ( not ItemInventoryRet.IsTaxIncluded is nothing) then Dim IsTaxIncluded12848 as Boolean IsTaxIncluded12848 = ItemInventoryRet.IsTaxIncluded.GetValue() End If if (not ItemInventoryRet.SalesTaxCodeRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.SalesTaxCodeRef.ListID is nothing) then Dim ListID12849 as String ListID12849 = ItemInventoryRet.SalesTaxCodeRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.SalesTaxCodeRef.FullName is nothing) then Dim FullName12850 as String FullName12850 = ItemInventoryRet.SalesTaxCodeRef.FullName.GetValue() End If End If 'Get value of SalesDesc if ( not ItemInventoryRet.SalesDesc is nothing) then Dim SalesDesc12851 as String SalesDesc12851 = ItemInventoryRet.SalesDesc.GetValue() End If 'Get value of SalesPrice if ( not ItemInventoryRet.SalesPrice is nothing) then Dim SalesPrice12852 as Double SalesPrice12852 = ItemInventoryRet.SalesPrice.GetValue() End If if (not ItemInventoryRet.IncomeAccountRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.IncomeAccountRef.ListID is nothing) then Dim ListID12853 as String ListID12853 = ItemInventoryRet.IncomeAccountRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.IncomeAccountRef.FullName is nothing) then Dim FullName12854 as String FullName12854 = ItemInventoryRet.IncomeAccountRef.FullName.GetValue() End If End If 'Get value of PurchaseDesc if ( not ItemInventoryRet.PurchaseDesc is nothing) then Dim PurchaseDesc12855 as String PurchaseDesc12855 = ItemInventoryRet.PurchaseDesc.GetValue() End If 'Get value of PurchaseCost if ( not ItemInventoryRet.PurchaseCost is nothing) then Dim PurchaseCost12856 as Double PurchaseCost12856 = ItemInventoryRet.PurchaseCost.GetValue() End If if (not ItemInventoryRet.PurchaseTaxCodeRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.PurchaseTaxCodeRef.ListID is nothing) then Dim ListID12857 as String ListID12857 = ItemInventoryRet.PurchaseTaxCodeRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.PurchaseTaxCodeRef.FullName is nothing) then Dim FullName12858 as String FullName12858 = ItemInventoryRet.PurchaseTaxCodeRef.FullName.GetValue() End If End If if (not ItemInventoryRet.COGSAccountRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.COGSAccountRef.ListID is nothing) then Dim ListID12859 as String ListID12859 = ItemInventoryRet.COGSAccountRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.COGSAccountRef.FullName is nothing) then Dim FullName12860 as String FullName12860 = ItemInventoryRet.COGSAccountRef.FullName.GetValue() End If End If if (not ItemInventoryRet.PrefVendorRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.PrefVendorRef.ListID is nothing) then Dim ListID12861 as String ListID12861 = ItemInventoryRet.PrefVendorRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.PrefVendorRef.FullName is nothing) then Dim FullName12862 as String FullName12862 = ItemInventoryRet.PrefVendorRef.FullName.GetValue() End If End If if (not ItemInventoryRet.AssetAccountRef. is nothing) then 'Get value of ListID if ( not ItemInventoryRet.AssetAccountRef.ListID is nothing) then Dim ListID12863 as String ListID12863 = ItemInventoryRet.AssetAccountRef.ListID.GetValue() End If 'Get value of FullName if ( not ItemInventoryRet.AssetAccountRef.FullName is nothing) then Dim FullName12864 as String FullName12864 = ItemInventoryRet.AssetAccountRef.FullName.GetValue() End If End If 'Get value of ReorderPoint if ( not ItemInventoryRet.ReorderPoint is nothing) then Dim ReorderPoint12865 as Integer ReorderPoint12865 = ItemInventoryRet.ReorderPoint.GetValue() End If 'Get value of Max if ( not ItemInventoryRet.Max is nothing) then Dim Max12866 as Integer Max12866 = ItemInventoryRet.Max.GetValue() End If 'Get value of QuantityOnHand if ( not ItemInventoryRet.QuantityOnHand is nothing) then Dim QuantityOnHand12867 as Integer QuantityOnHand12867 = ItemInventoryRet.QuantityOnHand.GetValue() End If 'Get value of AverageCost if ( not ItemInventoryRet.AverageCost is nothing) then Dim AverageCost12868 as Double AverageCost12868 = ItemInventoryRet.AverageCost.GetValue() End If 'Get value of QuantityOnOrder if ( not ItemInventoryRet.QuantityOnOrder is nothing) then Dim QuantityOnOrder12869 as Integer QuantityOnOrder12869 = ItemInventoryRet.QuantityOnOrder.GetValue() End If 'Get value of QuantityOnSalesOrder if ( not ItemInventoryRet.QuantityOnSalesOrder is nothing) then Dim QuantityOnSalesOrder12870 as Integer QuantityOnSalesOrder12870 = ItemInventoryRet.QuantityOnSalesOrder.GetValue() End If 'Get value of ExternalGUID if ( not ItemInventoryRet.ExternalGUID is nothing) then Dim ExternalGUID12871 as String ExternalGUID12871 = ItemInventoryRet.ExternalGUID.GetValue() End If if (not ItemInventoryRet.DataExtRetList is nothing) Dim i12872 as Integer for i12872 = 0 to ItemInventoryRet.DataExtRetList.Count - 1 Dim DataExtRet as IDataExtRet DataExtRet = ItemInventoryRet.DataExtRetList.GetAt(i12872) 'Get value of OwnerID if ( not DataExtRetOwnerID is nothing) then Dim OwnerID12873 as String OwnerID12873 = DataExtRetOwnerID.GetValue() End If 'Get value of DataExtName Dim DataExtName12874 as String DataExtName12874 = DataExtRetDataExtName.GetValue() 'Get value of DataExtType Dim DataExtType12875 as ENDataExtType DataExtType12875 = DataExtRetDataExtType.GetValue() 'Get value of DataExtValue Dim DataExtValue12876 as String DataExtValue12876 = DataExtRetDataExtValue.GetValue() Next i12872 End If End Sub End Class End Module |
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 | //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.QBFC16; namespace com.intuit.idn.samples { public class Sample { public void DoItemInventoryAdd() { bool sessionBegun = false; bool connectionOpen = false; QBSessionManager sessionManager = null; try { //Create the session Manager object sessionManager = new QBSessionManager(); //Create the message set request object to hold our request IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US",16,0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; BuildItemInventoryAddRq(requestMsgSet); //Connect to QuickBooks and begin a session sessionManager.OpenConnection("","Sample Code from OSR"); connectionOpen = true; sessionManager.BeginSession("", ENOpenMode.omDontCare); 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; WalkItemInventoryAddRs(responseMsgSet); } catch (Exception e) { MessageBox.Show(e.Message, "Error"); if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } } void BuildItemInventoryAddRq(IMsgSetRequest requestMsgSet) { IItemInventoryAdd ItemInventoryAddRq= requestMsgSet.AppendItemInventoryAddRq(); //Set field value for Name ItemInventoryAddRq.Name.SetValue("ab"); //Set field value for BarCodeValue ItemInventoryAddRq.BarCode.BarCodeValue.SetValue("ab"); //Set field value for AssignEvenIfUsed ItemInventoryAddRq.BarCode.AssignEvenIfUsed.SetValue(true); //Set field value for AllowOverride ItemInventoryAddRq.BarCode.AllowOverride.SetValue(true); //Set field value for IsActive ItemInventoryAddRq.IsActive.SetValue(true); //Set field value for ListID ItemInventoryAddRq.ClassRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.ClassRef.FullName.SetValue("ab"); //Set field value for ListID ItemInventoryAddRq.ParentRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.ParentRef.FullName.SetValue("ab"); //Set field value for ManufacturerPartNumber ItemInventoryAddRq.ManufacturerPartNumber.SetValue("ab"); //Set field value for ListID ItemInventoryAddRq.UnitOfMeasureSetRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.UnitOfMeasureSetRef.FullName.SetValue("ab"); //Set field value for IsTaxIncluded ItemInventoryAddRq.IsTaxIncluded.SetValue(true); //Set field value for ListID ItemInventoryAddRq.SalesTaxCodeRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.SalesTaxCodeRef.FullName.SetValue("ab"); //Set field value for SalesDesc ItemInventoryAddRq.SalesDesc.SetValue("ab"); //Set field value for SalesPrice ItemInventoryAddRq.SalesPrice.SetValue(15.65); //Set field value for ListID ItemInventoryAddRq.IncomeAccountRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.IncomeAccountRef.FullName.SetValue("ab"); //Set field value for PurchaseDesc ItemInventoryAddRq.PurchaseDesc.SetValue("ab"); //Set field value for PurchaseCost ItemInventoryAddRq.PurchaseCost.SetValue(15.65); //Set field value for ListID ItemInventoryAddRq.PurchaseTaxCodeRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.PurchaseTaxCodeRef.FullName.SetValue("ab"); //Set field value for ListID ItemInventoryAddRq.COGSAccountRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.COGSAccountRef.FullName.SetValue("ab"); //Set field value for ListID ItemInventoryAddRq.PrefVendorRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.PrefVendorRef.FullName.SetValue("ab"); //Set field value for ListID ItemInventoryAddRq.AssetAccountRef.ListID.SetValue("200000-1011023419"); //Set field value for FullName ItemInventoryAddRq.AssetAccountRef.FullName.SetValue("ab"); //Set field value for ReorderPoint ItemInventoryAddRq.ReorderPoint.SetValue(2); //Set field value for Max ItemInventoryAddRq.Max.SetValue(2); //Set field value for QuantityOnHand ItemInventoryAddRq.QuantityOnHand.SetValue(2); //Set field value for TotalValue ItemInventoryAddRq.TotalValue.SetValue(10.01); //Set field value for InventoryDate ItemInventoryAddRq.InventoryDate.SetValue(DateTime.Parse("12/15/2007")); //Set field value for ExternalGUID ItemInventoryAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString()); //Set field value for IncludeRetElementList //May create more than one of these if needed ItemInventoryAddRq.IncludeRetElementList.Add("ab"); } void WalkItemInventoryAddRs(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.rtItemInventoryAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IItemInventoryRet ItemInventoryRet = (IItemInventoryRet)response.Detail; WalkItemInventoryRet(ItemInventoryRet); } } } } } void WalkItemInventoryRet(IItemInventoryRet ItemInventoryRet) { if (ItemInventoryRet == null) return; //Go through all the elements of IItemInventoryRet //Get value of ListID string ListID12787 = (string)ItemInventoryRet.ListID.GetValue(); //Get value of TimeCreated DateTime TimeCreated12788 = (DateTime)ItemInventoryRet.TimeCreated.GetValue(); //Get value of TimeModified DateTime TimeModified12789 = (DateTime)ItemInventoryRet.TimeModified.GetValue(); //Get value of EditSequence string EditSequence12790 = (string)ItemInventoryRet.EditSequence.GetValue(); //Get value of Name string Name12791 = (string)ItemInventoryRet.Name.GetValue(); //Get value of FullName string FullName12792 = (string)ItemInventoryRet.FullName.GetValue(); //Get value of BarCodeValue if (ItemInventoryRet.BarCodeValue != null) { string BarCodeValue12793 = (string)ItemInventoryRet.BarCodeValue.GetValue(); } //Get value of IsActive if (ItemInventoryRet.IsActive != null) { bool IsActive12794 = (bool)ItemInventoryRet.IsActive.GetValue(); } if (ItemInventoryRet.ClassRef != null) { //Get value of ListID if (ItemInventoryRet.ClassRef.ListID != null) { string ListID12795 = (string)ItemInventoryRet.ClassRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.ClassRef.FullName != null) { string FullName12796 = (string)ItemInventoryRet.ClassRef.FullName.GetValue(); } } if (ItemInventoryRet.ParentRef != null) { //Get value of ListID if (ItemInventoryRet.ParentRef.ListID != null) { string ListID12797 = (string)ItemInventoryRet.ParentRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.ParentRef.FullName != null) { string FullName12798 = (string)ItemInventoryRet.ParentRef.FullName.GetValue(); } } //Get value of Sublevel int Sublevel12799 = (int)ItemInventoryRet.Sublevel.GetValue(); //Get value of ManufacturerPartNumber if (ItemInventoryRet.ManufacturerPartNumber != null) { string ManufacturerPartNumber12800 = (string)ItemInventoryRet.ManufacturerPartNumber.GetValue(); } if (ItemInventoryRet.UnitOfMeasureSetRef != null) { //Get value of ListID if (ItemInventoryRet.UnitOfMeasureSetRef.ListID != null) { string ListID12801 = (string)ItemInventoryRet.UnitOfMeasureSetRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.UnitOfMeasureSetRef.FullName != null) { string FullName12802 = (string)ItemInventoryRet.UnitOfMeasureSetRef.FullName.GetValue(); } } //Get value of IsTaxIncluded if (ItemInventoryRet.IsTaxIncluded != null) { bool IsTaxIncluded12803 = (bool)ItemInventoryRet.IsTaxIncluded.GetValue(); } if (ItemInventoryRet.SalesTaxCodeRef != null) { //Get value of ListID if (ItemInventoryRet.SalesTaxCodeRef.ListID != null) { string ListID12804 = (string)ItemInventoryRet.SalesTaxCodeRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.SalesTaxCodeRef.FullName != null) { string FullName12805 = (string)ItemInventoryRet.SalesTaxCodeRef.FullName.GetValue(); } } //Get value of SalesDesc if (ItemInventoryRet.SalesDesc != null) { string SalesDesc12806 = (string)ItemInventoryRet.SalesDesc.GetValue(); } //Get value of SalesPrice if (ItemInventoryRet.SalesPrice != null) { double SalesPrice12807 = (double)ItemInventoryRet.SalesPrice.GetValue(); } if (ItemInventoryRet.IncomeAccountRef != null) { //Get value of ListID if (ItemInventoryRet.IncomeAccountRef.ListID != null) { string ListID12808 = (string)ItemInventoryRet.IncomeAccountRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.IncomeAccountRef.FullName != null) { string FullName12809 = (string)ItemInventoryRet.IncomeAccountRef.FullName.GetValue(); } } //Get value of PurchaseDesc if (ItemInventoryRet.PurchaseDesc != null) { string PurchaseDesc12810 = (string)ItemInventoryRet.PurchaseDesc.GetValue(); } //Get value of PurchaseCost if (ItemInventoryRet.PurchaseCost != null) { double PurchaseCost12811 = (double)ItemInventoryRet.PurchaseCost.GetValue(); } if (ItemInventoryRet.PurchaseTaxCodeRef != null) { //Get value of ListID if (ItemInventoryRet.PurchaseTaxCodeRef.ListID != null) { string ListID12812 = (string)ItemInventoryRet.PurchaseTaxCodeRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.PurchaseTaxCodeRef.FullName != null) { string FullName12813 = (string)ItemInventoryRet.PurchaseTaxCodeRef.FullName.GetValue(); } } if (ItemInventoryRet.COGSAccountRef != null) { //Get value of ListID if (ItemInventoryRet.COGSAccountRef.ListID != null) { string ListID12814 = (string)ItemInventoryRet.COGSAccountRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.COGSAccountRef.FullName != null) { string FullName12815 = (string)ItemInventoryRet.COGSAccountRef.FullName.GetValue(); } } if (ItemInventoryRet.PrefVendorRef != null) { //Get value of ListID if (ItemInventoryRet.PrefVendorRef.ListID != null) { string ListID12816 = (string)ItemInventoryRet.PrefVendorRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.PrefVendorRef.FullName != null) { string FullName12817 = (string)ItemInventoryRet.PrefVendorRef.FullName.GetValue(); } } if (ItemInventoryRet.AssetAccountRef != null) { //Get value of ListID if (ItemInventoryRet.AssetAccountRef.ListID != null) { string ListID12818 = (string)ItemInventoryRet.AssetAccountRef.ListID.GetValue(); } //Get value of FullName if (ItemInventoryRet.AssetAccountRef.FullName != null) { string FullName12819 = (string)ItemInventoryRet.AssetAccountRef.FullName.GetValue(); } } //Get value of ReorderPoint if (ItemInventoryRet.ReorderPoint != null) { int ReorderPoint12820 = (int)ItemInventoryRet.ReorderPoint.GetValue(); } //Get value of Max if (ItemInventoryRet.Max != null) { int Max12821 = (int)ItemInventoryRet.Max.GetValue(); } //Get value of QuantityOnHand if (ItemInventoryRet.QuantityOnHand != null) { int QuantityOnHand12822 = (int)ItemInventoryRet.QuantityOnHand.GetValue(); } //Get value of AverageCost if (ItemInventoryRet.AverageCost != null) { double AverageCost12823 = (double)ItemInventoryRet.AverageCost.GetValue(); } //Get value of QuantityOnOrder if (ItemInventoryRet.QuantityOnOrder != null) { int QuantityOnOrder12824 = (int)ItemInventoryRet.QuantityOnOrder.GetValue(); } //Get value of QuantityOnSalesOrder if (ItemInventoryRet.QuantityOnSalesOrder != null) { int QuantityOnSalesOrder12825 = (int)ItemInventoryRet.QuantityOnSalesOrder.GetValue(); } //Get value of ExternalGUID if (ItemInventoryRet.ExternalGUID != null) { string ExternalGUID12826 = (string)ItemInventoryRet.ExternalGUID.GetValue(); } if (ItemInventoryRet.DataExtRetList != null) { for (int i12827 = 0; i12827 < ItemInventoryRet.DataExtRetList.Count; i12827++) { IDataExtRet DataExtRet = ItemInventoryRet.DataExtRetList.GetAt(i12827); //Get value of OwnerID if (DataExtRet.OwnerID != null) { string OwnerID12828 = (string)DataExtRet.OwnerID.GetValue(); } //Get value of DataExtName string DataExtName12829 = (string)DataExtRet.DataExtName.GetValue(); //Get value of DataExtType ENDataExtType DataExtType12830 = (ENDataExtType)DataExtRet.DataExtType.GetValue(); //Get value of DataExtValue string DataExtValue12831 = (string)DataExtRet.DataExtValue.GetValue(); } } } } } |