Dec 12, 2013

Epicor Customize Show Quick Search

using System.Collections;
private void btnSearch_Click(object sender, System.EventArgs args)
    {
        // ** Place Event Handling Code Here **
        try
        {   
           
            SearchOptions opts = new SearchOptions(SearchMode.ShowDialog);
            string GroupID=processQuickNamedSearch("TestSearch",opts,APInvoiceForm);
            if(!string.IsNullOrEmpty(GroupID))
            {
                txtGroupID.Focus();
                txtGroupID.Text=GroupID;
                btnSearch.Focus();
            }
          
        }
        catch (Exception err)
        {
            EpiMessageBox.Show("Error At: \n"+err.ToString());
        }
    }
    private string processQuickNamedSearch(string quickSearchId, SearchOptions searchOptions,object formName)
    {
        searchOptions.CurrentAdapter = oTrans.PrimaryAdapter;
        ISearch currentAdapter = searchOptions.CurrentAdapter as ISearch;
        if (currentAdapter == null)
        {
            return string.Empty;
        }
        searchOptions.PrimaryTableName = currentAdapter.PrimaryTableName;
        searchOptions.Like = oTrans.PrimaryAdapter.Like;
        searchOptions.DSDefined = oTrans.PrimaryAdapter.GetCurrentDataSet(DataSetMode.RowsDataSet);
        DataTable table = new DataTable();      
        ArrayList al = null;

       
        if (searchOptions.SearchMode == SearchMode.ShowDialog)
        {
           
            object cancel = ProcessCaller.InvokeAdapterMethod(formName, "QuickSearchAdapter", "ShowQuickSearchForm", new object[] { formName, quickSearchId, searchOptions.SelectMode == SelectMode.SingleSelect, table });
            if (cancel == null)
            {
                cancel = DialogResult.Cancel;
            }
            if (cancel is DialogResult)
            {
                return string.Empty;
            }
            al = cancel as ArrayList;
            if (al == null)
            {
                al = new ArrayList();
                al.Add(cancel.ToString());
            }

        }
        return al[0].ToString();
       
    }
   

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib