Call QuickSearch from Customization

I am working with the following code after converting from E9 to E10 and I am struggling to make it work in E10.

image

I get the following error:
Warning: CS0618 - line 193 (4689) - ‘Ice.Adapters.QuickSearchAdapter.ShowQuickSearch(object, bool, System.Data.DataTable)’ is obsolete: ‘Obsoleted method, please use overload that accepts QuickSearchID as parameter’

I have been trying to make Jose’s code from http://trigemco.com/call-a-custom-quick-search-2/ work but I’m afraid it is a little over my head getting multiple criteria to work.

Is it possible to make the original code work or has it changed completely with E10?

Thanks,

Bill Short

The code I posted is very similar to the one above what are you struggling with? Specifically…

Are you referring to the second piece of code on your page of code examples (that starts with sender = oTrans.EpiBaseForm;)?

If I am working with that then I am unsure of where the txtFilter.Text comes from. Is that just a textbox on the form that contains the ABC Code? And also how would I put in the second criteria?

Thanks,

Bill

Corrent the txtFilter was just a texbox I used in the example. To add a second criteria simnply add a second IF in the loop

I (we) have got to be close. It compiles and when I enter the city and state then click the button the quick search pops up. The only issue is that it returns every tax region. It should only return one.

I’m thinking I need to have something in the bottom section of code about the second criteria. Thanks again.

[/uploads/default/original/2X/8/82e0e0da23f23e8ba71b9861c899e51c1d4faa97.png]
[/uploads/default/original/2X/a/a29eb595b87ced3a0883b7d4d74f50bb75f2e134.png]

private void cmdTaxOTS_Click(object sender, System.EventArgs args)
                {
                                sender = oTrans.EpiBaseForm;
                                QuickSearchAdapter _qdA = new QuickSearchAdapter(oTrans);
                                _qdA.BOConnect();
                                _qdA.GetByID("","TaxL");
                                QuickSearchDataSet qsds = _qdA.QuickSearchData;

                                EpiTextBox txbOTSState = (EpiTextBox) csm.GetNativeControlReference("6a3adf30-bd2e-447b-a427-b7c8ac36ff6a");
                                EpiTextBox tbxOTSCity = (EpiTextBox) csm.GetNativeControlReference("9ad6e6c9-067b-4a2d-9dad-441f6a527082");

                                foreach(QuickSearchDataSet.QuickSearchCriteriaRow r in qsds.QuickSearchCriteria)
                                {
                                    if(r.FieldName.Equals("TaxRgn.Character01") && r.CriteriaType.Equals(edvOrderHed.dataView[edvOrderHed.Row]["Constant"] as string))  //Also tried TaxRgn_Character01.
                                    {
                                        r.CriteriaValue = txbOTSState.Text;
                                        break;
                                    }
                                }

                                foreach(QuickSearchDataSet.QuickSearchCriteriaRow r in qsds.QuickSearchCriteria)
                                {
                                    if(r.FieldName.Equals("TaxRgn.Character03") && r.CriteriaType.Equals(edvOrderHed.dataView[edvOrderHed.Row]["Constant"] as string)) //Also tried TaxRgn_Character03.
                                    {
                                        r.CriteriaValue = tbxOTSCity.Text;
                                        break;
                                    }
                                }

                                try
                                {
                                    using(QuickSearchPanel panel = _qdA.GetQuickSearchPanel(oTrans.EpiBaseForm))
                                    {
                                        if(panel !=null)
                                        {
                                            using(QuickSearchForm form = new QuickSearchForm(_qdA))
                                            {
                                                form.LastQS = "TaxL";
                                                System.Reflection.MethodInfo mi = form.GetType().GetMethod("addQuickSearchPanel",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                                                mi.Invoke(form, new object[]{panel});

                                                SearchOptions options = SearchOptions.CreateSearchForm(DataSetMode.ListDataSet);
                                                options.Sender = sender;

                                                options.SelectMode = SelectMode.SingleSelect;
                                                form.ShowDialog(new Ice.Lib.Searches.EpiSearchEngine((EpiBaseAdapter)_qdA),options);
                                                System.Reflection.FieldInfo fi = form.GetType().GetField("selectObject", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                                                object o= fi.GetValue(form);
                                                if(o!=null)
                                                {

                                                    //o is a String containing your returned key
                                                    //if multi select o is an ArrayList containing all selected keys.
                                                    if (o == null)
                                                           return;
                                                    SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
                                                    opts.NamedSearch.WhereClauses.Add("TaxRgn.Character01", string.Format("SysRowID='{0}'",o.ToString()));
                                                    opts.DataSetMode = DataSetMode.RowsDataSet;
                                                    TaxRgnAdapter _adapter = (TaxRgnAdapter)csm.TransAdaptersHT["oTrans_adapter"];
                                                    _adapter.ClearData();
                                                    _adapter.InvokeSearch(opts);
                                                    oTrans.NotifyAll();
                                                    EpiDataView edvA = oTrans.Factory("TaxRgn.Character01");
                                                    edvA.Row=0;
                                                    edvA.Notify(new EpiNotifyArgs(oTrans, 0, EpiTransaction.NotifyType.Initialize));

                                                }
                                            }
                                        }
                                    }
                                }
                                catch(Exception ex)
                                {
                                }
                }