How to access UDCodes table in C#


(system) #1

From memory I believe CodeID is not a field that you can query by via the search function.  CodeID is in the child table of the parent/child set that makes up user codes, many adapters don't expose all fields especially child records to the search Function.  Not in system right now but you might check to see what other methods are available and you may need to make a connect to the adapter or BO.  Otherwise you can just search on CodeTypeID which will return all codes for that set.  You then could filter out the row you are interested in from the dataset returned.  If the number of codes is a lot it may be worth going the connect to adapter route and using a method that can get the CodeID record directly.


Jim Kinneman

Encompass Solutions, Inc.



---In vantage@yahoogroups.com, <vantage@yahoogroups.com> wrote:

I'm pretty new to C# but I've been getting along OK - I'm a Progress programmer.

However I'm having trouble getting data from the UDCodes table from the code below you can see I’ve tried to use the “UserCodesAdapter” however I get the message “Invalid query: where Company = 'IP01' and (CodeTypeID = 'PRODSTYLE' and CodeID = 'SHT PR') BY CodeTypeID”
Can anyone point out where I’m going wrong?

private void CallUserCodesAdapterGetDataMethod()
    {
        try
        {
            // Declare and Initialize EpiDataView Variables
            // Declare and create an instance of the Adapter.
            UserCodesAdapter adapterUserCodes = new UserCodesAdapter(this.oTrans);
            adapterUserCodes.BOConnect();

            // Declare and Initialize Variables
            string codeTypeID;
            codeTypeID = "PRODSTYLE";

            // Get part *************************************************************
            // Declare and Initialize EpiDataView Variables
            EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));

            // Check if valid EpiDataView Row(s) are selected
            if ((edvPart.Row < 0))
            {
                return;
            }

            // Declare and Initialize Variables
            string codeID = ((string)(edvPart.dataView[edvPart.Row]["ShortChar06"]));

            MessageBox.Show(codeID);
            
            // End get part *********************************************************

            bool recSelected = false;
            string whereClause = string.Empty;
            
            whereClause = "CodeTypeID = 'PRODSTYLE' and CodeID = '" + codeID + "'";


            // Call Adapter method
            // System.Data.DataSet dsUserCodes = adapterUserCodes.GetData(codeTypeID);
            System.Data.DataSet dsUserCodes =
                Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup
                    (this.oTrans, "UserCodesAdapter", out recSelected, false, whereClause);

            if ((recSelected))
            {
                System.Data.DataRow adapterRow = dsUserCodes.Tables[0].Rows[0];
                MessageBox.Show((string)adapterRow["LongDesc"]);
            }
            // Cleanup Adapter Reference
            adapterUserCodes.Dispose();

        } catch (System.Exception ex)
        {
            ExceptionBox.Show(ex);
        }
    }

(system) #2
I'm pretty new to C# but I've been getting along OK - I'm a Progress programmer.

However I'm having trouble getting data from the UDCodes table from the code below you can see I’ve tried to use the “UserCodesAdapter” however I get the message “Invalid query: where Company = 'IP01' and (CodeTypeID = 'PRODSTYLE' and CodeID = 'SHT PR') BY CodeTypeID”
Can anyone point out where I’m going wrong?

private void CallUserCodesAdapterGetDataMethod()
    {
        try
        {
            // Declare and Initialize EpiDataView Variables
            // Declare and create an instance of the Adapter.
            UserCodesAdapter adapterUserCodes = new UserCodesAdapter(this.oTrans);
            adapterUserCodes.BOConnect();

            // Declare and Initialize Variables
            string codeTypeID;
            codeTypeID = "PRODSTYLE";

            // Get part *************************************************************
            // Declare and Initialize EpiDataView Variables
            EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));

            // Check if valid EpiDataView Row(s) are selected
            if ((edvPart.Row < 0))
            {
                return;
            }

            // Declare and Initialize Variables
            string codeID = ((string)(edvPart.dataView[edvPart.Row]["ShortChar06"]));

            MessageBox.Show(codeID);
            
            // End get part *********************************************************

            bool recSelected = false;
            string whereClause = string.Empty;
            
            whereClause = "CodeTypeID = 'PRODSTYLE' and CodeID = '" + codeID + "'";


            // Call Adapter method
            // System.Data.DataSet dsUserCodes = adapterUserCodes.GetData(codeTypeID);
            System.Data.DataSet dsUserCodes =
                Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup
                    (this.oTrans, "UserCodesAdapter", out recSelected, false, whereClause);

            if ((recSelected))
            {
                System.Data.DataRow adapterRow = dsUserCodes.Tables[0].Rows[0];
                MessageBox.Show((string)adapterRow["LongDesc"]);
            }
            // Cleanup Adapter Reference
            adapterUserCodes.Dispose();

        } catch (System.Exception ex)
        {
            ExceptionBox.Show(ex);
        }
    }