9.05.700b VB Conversion Help

To everyone that replied...Thank you. I greatly appreciate it. Got it figured out. Pasting the final code below.


 private static void OrderDtl_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
 {
  switch (args.Column.ColumnName)
  {
   case "PartNum":
    Epicor.Mfg.Core.Session objSession = oTrans.Session as Epicor.Mfg.Core.Session;
    Epicor.Mfg.BO.Part adpPart = new Epicor.Mfg.BO.Part(objSession.ConnectionPool);
    Epicor.Mfg.BO.PartDataSet dsPart = new Epicor.Mfg.BO.PartDataSet();

    dsPart = adpPart.GetByID(args.ProposedValue.ToString());
    if (dsPart.Tables[0].Rows.Count > 0) {
     if (dsPart.Tables[0].Rows[0]["Inactive"].ToString() == "True") {
      args.ProposedValue = "";
     }
    }
    break;
  }
 }

I am new to
Epicor (6 months), and need some help converting VB code to C#. I have
used the online converters to get the format done, but the issue now is the
Epicor objects.

 

Here is the
VB code:

 

                Private Sub
OrderDtl_BeforeFieldChange(ByVal sender As Object, ByVal args As
DataColumnChangeEventArgs)

                Select Case
args.Column.ColumnName

                 Case “PartNum”

                 Dim adpPart As New
Epicor.mfg.bo.part(SalesOrderForm.session.connectionpool)

 Dim dsPart as New
Epicor.mfg.bo.partdataset

                 dsPart = adpPart.GetByID(args.ProposedValue)

if dsPart.tables(0).rows.count>0 then

 if
dspart.tables(0).rows(0).item(“Inactive”) = True then

 args.ProposedValue = “”

 end if

 end If

                 End Select

                End Sub

 

 

The
converted C code from a converter:

 

 private
static void OrderDtl_BeforeFieldChange(object sender, DataColumnChangeEventArgs
args)

 {

  // ** Argument Properties and Uses **

  // args.Row[“FieldName”]

  // args.Column, args.ProposedValue, args.Row

  // Add Event Handler Code

  switch (args.Column.ColumnName)

  {

   case “PartNum”:

    Epicor.Mfg.BO.Part adpPart = new
Epicor.Mfg.BO.Part(SalesOrderForm.Session.ConnectionPool);

    Epicor.Mfg.BO.PartDataset dsPart = new
Epicor.Mfg.BO.PartDataset();

 

    dsPart = adpPart.GetByID(args.ProposedValue);

    if (dsPart.tables(0).rows.count > 0) {

     if
(dsPart.tables(0).rows(0).item(“Inactive”) == true) {

      args.ProposedValue = “”;

     }

    }

    break;

  }

 }

 

Below are the
errors that I am getting:

Error:
CS0117 - line 262 (3137) - ‘object’ does not contain a definition for
‘ConnectionPool’

 Error: CS0234 - line 263 (3138) - The type or namespace name
‘PartDataset’ does not exist in the namespace ‘Epicor.Mfg.BO’ (are you missing
an assembly reference?)

 Error: CS0234 - line 263 (3138) - The type or namespace name
‘PartDataset’ does not exist in the namespace ‘Epicor.Mfg.BO’ (are you missing
an assembly reference?)

 Error: CS1502 - line 265 (3140) - The best overloaded method match for
‘Epicor.Mfg.Proxy.PartImpl.GetByID(string)’ has some invalid arguments

 Error: CS1503 - line 265 (3140) - Argument ‘1’: cannot convert from
‘object’ to ‘string’

 

I
would just like the proper way to call these objects in C# so that I can fix
this issue and move on.

 

Thank you in advance.

In developer mode with customization window open go to actions/assembly references/add  Include

Epicor.Mfg.BO.Part, Epicor.Mfg.AD.Part and Epicor.Mfg.IF.Part...dlls

For
dsPart = adpPart.GetByID(args.ProposedValue); change to
dsPart = adpPart.GetByID(args.ProposedValue.ToString());


SalesOrderForm.Session.ConnectionPool needs to be cast to Session


Epicor.Mfg.Core.Session session = oTrans.Session as Epicor.Mfg.Core.Session;


Then you can do 


Epicor.Mfg.BO.Part adpPart = new Epicor.Mfg.BO.Part(session.ConnectionPool);


Jim Kinneman

Encompass Solutions, Inc.

Thanks for the quick reply. Getting closer. Now I get these errors.


Error: CS0118 - line 267 (3143) - 'Epicor.Mfg.BO.PartDataSet.Tables' is a 'property' but is used like a 'method'
 Error: CS0118 - line 268 (3144) - 'Epicor.Mfg.BO.PartDataSet.Tables' is a 'property' but is used like a 'method'


Monte

change parenthesis to brackets.  () to []


Jim Kinneman

Encompass Solutions, Inc.

Thanks again. Almost there. If there is a better way to get the data from the table, I am all ears!


Now I get:

Error: CS0117 - line 268 (3144) - 'System.Data.DataRow' does not contain a definition for 'Item'


on:

if (dsPart.Tables[0].Rows[0].Item["Inactive"] == true) {

Have you thought about using a BAQ Zone?  You can embed it just to the customization, instead of embedding it to the field in a table, if you only want it in that customization.

EpicorUserExpCust_UserGuide_905700_Part3of3 is the document that helps with placing it in a customization.