Button Click event to update Bin number in Mass Issue to Mfg. Mtl Grid

Hello everyone,

I am trying to add a button to the Mass Issue to Mfg. module to update the “From Bin”(BinNum) column in the grid view. I am trying to update every field in the column to “0002”.
Any help is appreciated, Thanks!

The field name in grid:

Grid Properties:

I tried to modify the script from another thread however, it doesn’t even give me an error so I assume I did some thing fundamentally wrong that I need some help with.

Here is the function I modified trying to make it work for me

private void epiButtonPHX_Click(object sender, System.EventArgs args)
	{
		EpiDataView edvugdIssue = oTrans.Factory("ugdIssue");
		MessageBox.Show(oTrans.LastView.ViewName);	    	                
		foreach(DataRowView row in edvugdIssue.dataView)
		{
			row.BeginEdit();
			row["Mtl.BinNum"] = "0002";
			row.EndEdit();
		}
		oTrans.Update();
		
	}

Here is the full version:

// **************************************************
    // Custom code for MassIssueForm
    // Created: 9/20/2018 5:49:33 PM
    // **************************************************
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Windows.Forms;
    using Erp.Adapters;
    using Ice.BO;
    using Erp.UI;
    using Ice.Lib;
    using Ice.Adapters;
    using Ice.Lib.Customization;
    using Ice.Lib.ExtendedProps;
    using Ice.Lib.Framework;
    using Ice.Lib.Searches;
    using Ice.UI.FormFunctions;
    public class Script
    {
    	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
    	// Begin Wizard Added Module Level Variables **
    	// End Wizard Added Module Level Variables **

    	// Add Custom Module Level Variables Here **

    	public void InitializeCustomCode()
    	{
    		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
    		// Begin Wizard Added Variable Initialization

    		// End Wizard Added Variable Initialization

    		// Begin Wizard Added Custom Method Calls

    		// End Wizard Added Custom Method Calls
    	}

    	public void DestroyCustomCode()
    	{
    		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
    		// Begin Wizard Added Object Disposal

    		// End Wizard Added Object Disposal

    		// Begin Custom Code Disposal

    		// End Custom Code Disposal
    	}
    	
    	private void epiButtonPHX_Click(object sender, System.EventArgs args)
    	{
    		EpiDataView edvugdIssue = oTrans.Factory("ugdIssue");	    	                
    		foreach(DataRowView row in edvugdIssue.dataView)
    		{
    			row.BeginEdit();
    			row["BinNum"] = "0002";
    			row.EndEdit();
    		}
    		oTrans.Update();
    		
    	}

    }

While made the function for the button click, you never added it to the event handler.

You’re missing:

If you had used the Event wizard it would have added those lines and created an “empty” function, like:

image

But just so you know, your code will compile okay. But it will throw an error when that function is called.

Thank you for catching that. I was wondering whey I didn’t receive any errors even though I keep changing things.

If I see errors at least I can guess what is wrong with it.
Thanks again!

Try the following:

private void epiButtonPHX_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		//EpiDataView edvugdIssue = oTrans.Factory("ugdIssue");
		EpiDataView edvMtl = (EpiDataView)(oTrans.EpiDataViews["Mtl"]);

		DataView dvMtl = edvMtl.dataView;
		//MessageBox.Show(oTrans.LastView.ViewName);	    	                
		
		foreach(DataRowView row in dvMtl)
		{
			row.BeginEdit();
			row["BinNum"] = "1A";
			row.EndEdit();
		}
		//oTrans.Update();
	}

If you uncomment the //otrans.Update(); line then clicking the button will also issue the materials. If you want it to just update the grid, leave it commented out.

2 Likes

You are wonderful sir, thank you very much for the help and the explanation. I see you used the epiBinding name.

I probably wouldn’t be able to figure out what was wrong since many things were wrong. I will keep building up on this.

Thanks again!
Have a great day!