I’m not sure how the GetData method is meant to work, to be honest. Brace yourself for a lot of experimenting when it comes to Epicor methods.
Someone else might pop in with additional info on performance, but I’d use the GetByID method, and tell the wizard you’re going to pass in the parameter. You’ll notice this method doesn’t give you a dataset at all. The data is loaded into the adapter itself. You can explore methods and properties of the adapter under Tools, Object Explorer.
So under the “City” case in your switch statement, you’re going to call the generated method and pass the city in, like CallUD18AdapterGetByIDMethod(args.Row["City"].ToString())
.
Now, what the wizard screws up in the GetByID method is that UD tables have 5 keys. It won’t find any results if you only pass in one. So update the line under // Call Adapter method
like this: bool result = adapterUD18.GetByID(stringId,string.Empty,string.Empty,string.Empty,string.Empty);
Add an if-statement to verify result
is true so you don’t throw an index error when you access the data, which is available like this: adapterUD18.UD18Data.Tables[0].Rows[0]["Character01"].ToString()
Does Java have out parameters? That might be the simplest way to bring back three values. So here’s some rough code:
private void Customer_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
switch (args.Column.ColumnName){
case "City":
string country;
string state;
string zip;
if (GetUD18Data(args.Row["City"].ToString(), out country, out state, out zip)){
args.Row["Country"] = country;
args.Row["State"] = state;
args.Row["Zip"] = zip;
oTrans.Update(); // optional, depending on your workflow. it will attempt to save the row with the new values
}
break;
}
}
private bool GetUD18Data(string city, out string country, out string state, out string zip)
{
UD18Adapter adapterUD18 = new UD18Adapter(this.oTrans);
adapterUD18.BOConnect();
bool result = adapterUD01.GetByID(stringId,string.Empty,string.Empty,string.Empty,string.Empty);
if(result){
country = adapterUD18.UD18Data.Tables[0].Rows[0]["ShortChar01"].ToString();
state = adapterUD18.UD18Data.Tables[0].Rows[0]["ShortChar02"].ToString();
zip = adapterUD18.UD18Data.Tables[0].Rows[0]["ShortChar03"].ToString();
}
adapterUD18.Dispose();
return result;
}