public void savedSearchMaxCredible(NetSuiteService service)
        {
            TransactionSearchAdvanced TSA = new TransactionSearchAdvanced();
            TSA.savedSearchScriptId = TxtSavedSearch1.Text;
            TransactionSearch TS = new TransactionSearch();
            TransactionSearchBasic TSB = new TransactionSearchBasic();

            if (Settings.Default.APP_DatesEnabled)
            {
                DateTime theSearchStartDate = DTPickerFrom.Value;
                DateTime theSearchFinishDate = DTPickerTo.Value;
                SearchDateField theDTSearch = new SearchDateField();
                theDTSearch.operatorSpecified = true;
                theDTSearch.@operator = SearchDateFieldOperator.within;
                theDTSearch.searchValue2Specified = true;
                theDTSearch.searchValueSpecified = true;
                theDTSearch.searchValue = theSearchStartDate;
                theDTSearch.searchValue2 = theSearchFinishDate;

                TSB.tranDate = theDTSearch;
            }

            TS.basic = TSB;
            TSA.criteria = TS;

            AppendTextBoxLine(txtSearchResults, "Performing search ...", true);
            SearchResult SR = service.search(TSA);

            if (SR.totalRecords == 0)
            {
                AppendTextBoxLine(txtSearchResults, "No records / consignments were returned in the Saved Search : " + TxtSavedSearch1.Text, true);
            }
            else
            {
                AppendTextBoxLine(txtSearchResults, SR.totalRecords + " records / consignments were returned in the Saved Search : " + TxtSavedSearch1.Text, true);

                SearchRow[] SSR;
                SSR = SR.searchRowList;
                SearchRow[] SSRM;

                // Build Intermediate List to allow pagination 
                System.Collections.ArrayList theInvoiceList = new System.Collections.ArrayList();
                for (int ssr = 0; ssr < SSR.Length; ssr++) theInvoiceList.Add(SSR[ssr]);
                AppendTextBoxLine(txtSearchResults, "Records downloaded : " + theInvoiceList.Count + " of " + SR.totalRecords.ToString(), true);

                if (SR.totalRecords > SR.pageSize)
                {
                    int batchNo = 2;
                    // Keep getting pages until there are no more pages to get
                    while (SR.totalRecords > ((batchNo - 1) * SR.pageSize))
                    {
                        AppendTextBoxLine(txtSearchResults, "Fetching next batch no. " + batchNo, true);
                        // Invoke searchMore() operation - ensure logged in ...
                        setupNetSuiteObjects(service); // To ensure logged in before next batch
                        SearchResult SRM = service.searchMore(batchNo);
                        if (SRM != null)
                        {
                            // Process response
                            if (SRM.status.isSuccess)
                            {
                                SSRM = SRM.searchRowList;
                                for (int ssrm = 0; ssrm < SSRM.Length; ssrm++) theInvoiceList.Add(SSRM[ssrm]);
                                AppendTextBoxLine(txtSearchResults, "Records downloaded : " + theInvoiceList.Count + " of " + SR.totalRecords.ToString(), true);
                                batchNo++;
                            }
                            else
                            {
                                AppendTextBoxLine(txtSearchResults, getStatusDetails(SRM.status), true);
                            }
                        }
                    }
                }

                _SSRECORDS = new SearchRow[theInvoiceList.Count];
                IEnumerator iienum = theInvoiceList.GetEnumerator();
                for (int iicr = 0; iienum.MoveNext(); iicr++)
                {
                    _SSRECORDS[iicr] = (SearchRow)iienum.Current;
                }

                //Record list assembly complete - create list for MaxCredible upload
                ProgressNSSearch.Maximum = _SSRECORDS.Length;
                for (int i = 0; i < _SSRECORDS.Length; i++)
                {
                    TransactionSearchRow TSR = (TransactionSearchRow)_SSRECORDS[i];

                    // Declare all the variables for use when writing the file...
                    //DOCNUM
                    string theInternalid = "";
                    if (TSR.basic.internalId != null)
                    {
                        theInternalid = TSR.basic.internalId[0].searchValue.internalId;
                    }

                    string sDocNum = "";
                    if (TSR.basic.tranId != null)
                    {
                        sDocNum = TSR.basic.tranId[0].searchValue.ToString();
                    }

                    //DATE
                    string sDate = "";
                    if (TSR.basic.tranDate != null)
                    {
                        sDate = TSR.basic.tranDate[0].searchValue.ToString("dd/MM/yyyy");
                    }

                    AppendTextBoxLine(txtSearchResults, (i+1) + "\t" + theInternalid + "\t" + sDocNum + "\t" + sDate, false);
                    ProgressNSSearch.Value++;
                }

                // Set up MaxCredible Data defaults based on records returned
                _MaxCredibleData.NR_RECORDS = _SSRECORDS.Length.ToString();
                _MaxCredibleData.CHUNK_SIZE = TxtChunkSize.Text;
                GrpMaxCredible.Text = "Step 2 - Upload " + _MaxCredibleData.NR_RECORDS + " Records to MaxCredible";
                updateChunkSizes();
                
            }
            return;
        }
        public void itemFulfillmentSearch(string orderNumber)
        {
            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            TransactionSearchAdvanced tranSearchAdvanced = new TransactionSearchAdvanced();
            TransactionSearch tranSearch = new TransactionSearch();
            SearchStringField orderID = new SearchStringField();
            orderID.@operator = SearchStringFieldOperator.@is;
            orderID.operatorSpecified = true;
            orderID.searchValue = orderNumber;

            TransactionSearchBasic tranSearchBasic = new TransactionSearchBasic();
            tranSearchBasic.tranId = orderID;
            tranSearch.basic = tranSearchBasic;
            tranSearchAdvanced.criteria = tranSearch;

            SearchPreferences searchPreferences = new SearchPreferences();
            searchPreferences.bodyFieldsOnly = false;
            service.searchPreferences = searchPreferences;

            SearchResult transactionResult = service.search(tranSearchAdvanced);

            if (transactionResult.status.isSuccess != true) throw new Exception("Cannot find Order " + orderNumber + " " + transactionResult.status.statusDetail[0].message);
            if (transactionResult.recordList.Count() != 1) throw new Exception("More than one order found for item " + orderNumber);

            this.itemFulfillment = new com.netsuite.webservices.ItemFulfillment();
            this.itemFulfillment = ((com.netsuite.webservices.ItemFulfillment)transactionResult.recordList[0]);
        }