Need to help with adapter methods and working with data sets

(Brandon Anderson) #1

So I’m trying to work through creating a warehouse bin from from the order entry screen. It’s for a contract bin creation for jobs

I made a button, and have the code to go and check if there is a bin or not. If there isn’t one I want to create one with variables that I have from the order line.

I think I have a new dataset with the GetNewWhseBin code. Now I am trying to figure out how to manipulate the data set before the update and I’m stuck. I need to set the bin number (I have variables for that already) and the description (ditto on the variables). I will be hard coding the bin type as a contract bin. That should be all that I need to set.

When I’m looking in the object explorer for the adapter, I can’t find anything for those columns in the dataset. Should I just be opening the warehouse bin entry screen and looking at the dataview there to get what I need?

Any tips on how to look up the use of the adapters? I have the BL tester pulled up too so I can see the columns on the dataset, but I get stuck on the bridge to connect the dataset to the columns.

I will be doing the same basic thing with the Planning contract adapter as well, but if I can learn how to look up some of this stuff a little better, it should be similar.

			WhseBinAdapter BinAdapter  = new WhseBinAdapter(oTrans);
					BinAdapter.GetByID("GEN",BinNum); //check if the bin exists
					MessageBox.Show("There is a bin " +  BinNum);
					MessageBox.Show("This bin does not exist");
					//get a new bin

(Brandon Anderson) #2

I figured out the warehouse bin adapter.

What I am figuring out is, it’s your adapter name that’s been instantiated, then the name of the adapter with “data” instead of adapter, then the names of the adapter and the row number, then the column name (not in quotes). Then you can set what you want.

This is the code that I ended up with. It made the bin for me! A win for the little guy.

Next up, doing the same thing with the contract bin.

					//get a new bin
					BinAdapter.WhseBinData.WhseBin[0].BinNum = BinNum;
					BinAdapter.WhseBinData.WhseBin[0].Description = "Contract Bin For " +BinNum;
					BinAdapter.WhseBinData.WhseBin[0].BinType = "Cont";

(Joseph Moeller) #3

Yes, this is often how I access the data when I know I’m adding one single row to the dataset. However, you may want to grab a selected record into a variable based on RowMod if you end up interacting with a dataset that could contain more than one row.

As a reminder, unless you have a finally { BinAdapter.Dispose(); } in there, I recommend you wrap your adapter instantiation in a using so the disposal will occur at the end of this code block.

using(WhseBinAdapter BinAdapter  = new WhseBinAdapter(oTrans))
   // your code here
// BinAdapter is no longer used here