Customization Button not Functioning - Help Needed

I’m in the process of finalizing a customization and wanted to have a button that the user could use to search sales orders with. Unfortunately, the button does not seem to be functioning at all. Below is the code where I enable the button based on criteria and the adapter for it:


	private void edvJobHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		
		if ((args.Row > -1))
		{
			if((bool)view.dataView[args.Row]["JobEngineered"])
			{
				this.bt_SalesOrder.Enabled = false;
			}
			else
			{
				this.bt_SalesOrder.Enabled = true;
			}
		}
		else
		{
			this.bt_SalesOrder.Enabled = false;
		}
	}


	private void bt_SalesOrder_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here ** 
		if(this.bt_SalesOrder.Enabled)
		{
			SearchOnSalesOrderAdapterShowDialog();		
		}
	}

Additionally, I have implemented a textbox that the user can use instead of searching with the button and using that textbox to pull and populate fields seems to work perfectly.

Any tips or tricks are appreciated.

What does it do? Does it throw an error? Did you implement the SearchOnAdapter method you called? What does that look like ?

@josecgomez

The button does nothing at all. It is clickable, but no dialog or error messages occur.

As for the search on adapter here is the code where it is referenced. Sorry, I didn’t have it in the original post.

Create custom code
this.bt_SalesOrder.Click += new System.EventHandler(this.bt_SalesOrder_Click);

Destroy custom code
this.bt_SalesOrder.Click -= new System.EventHandler(this.bt_SalesOrder_Click);
	
	private void bt_SalesOrder_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here ** 
		if(this.bt_SalesOrder.Enabled)
		{
			SearchOnSalesOrderAdapterShowDialog();		
		}
	}

	
	private void SearchOnSalesOrderAdapterShowDialog()
	{
		// Wizard Generated Search Method
		// You will need to call this method from another method in custom code
		// For example, [Form]_Load or [Button]_Click

		bool recSelected;
		string whereClause = string.Empty;
		System.Data.DataSet dsSalesOrderAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "SalesOrderAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsSalesOrderAdapter.Tables[0].Rows[0];
			int orderNum = (int)adapterRow["OrderNum"];

			//Check if SalesOrderHead has detail row
			bool hasDtl = false;

			SalesOrderAdapter adapterSalesOrder = new SalesOrderAdapter(this.oTrans);
			adapterSalesOrder.BOConnect();

			adapterSalesOrder.GetByID(orderNum);
			hasDtl = adapterSalesOrder.SalesOrderData.OrderDtl.Rows.Count > 0;

			adapterSalesOrder.Dispose();
			
			if(!hasDtl)
			{
				EpiMessageBox.Show("No Detail attached to Sales Order " + orderNum.ToString());
			}
			else
			{
				// Map Search Fields to Application Fields
				EpiDataView edvJobHead = ((EpiDataView)(this.oTrans.EpiDataViews["JobHead"]));
				System.Data.DataRow edvJobHeadRow = edvJobHead.CurrentDataRow;
				if ((edvJobHeadRow != null))
				{
					edvJobHeadRow.BeginEdit();
					edvJobHeadRow["ContractOrder_c"] = adapterRow["OrderNum"];
					edvJobHeadRow.EndEdit();
					oTrans.NotifyAll();
				}
			}
		}
	}

Thanks for looking at this!

After trying a few minor adjustments to the adapter call and then rebuilding the button and code all together I get the same issue. Does anyone know what I may be missing?

If you put a messagebox on the button does it work?

@josecgomez,

Okay, weird storytime. So I spent the better part of yesterday chasing my tail on this thing and it not doing what I wanted. Dropped it and came back to it this morning. The thing still wasn’t working after a few hours so I updated the post. After trying the message box thing the button magically works now.

I think for some reason I hadn’t closed out of our Pilot System the entire time I was coding, last night and this morning. But for the button bit I had logged out and back in to test it… Have you had this happen before?