First: I’m not sure if I should post it here or in the Code Review section as this code isn’t working yet.
Last week, I did a customization on the Sold It? tab to pull in extra data not on the default grids. Between Jose’s grid video, shamelessly borrowing code for button actions, and asking for help on filtering the BAQ results for the other tabs, I got it working; https://epiusers.help/t/part-adviser-baq-custom-grid-views-on-sold-it-tab/48480.
Maybe working too well, now need to pull these same fields into the Quoted It? tab. I figured this would be an easy copy/paste and code change. Like before I created the BAQ and it works great, then modified the code.
The problem is: If I open the form, enter a part number, then click “Retrieve” in either the Quoted It or Sold It tab it works, but the other tab wont unless I close the form and reopen. I’ve coded it totally separate binding and var for the buttons but still no-go.
extern alias Erp_Contracts_BO_PartAdvisor;
extern alias Erp_Contracts_BO_Part;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
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;
using Ice.Lib.Broadcast;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
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 **
string pubBinding;
IPublisher pub;
BAQDataView baqQuoteView; //QuotedIT
EpiButton quotedItBtn; //QuotedIT
string pubBinding2; //SoldIt TS
IPublisher pub2; //SoldIt TS
EpiButton SoldItBtn; //SoldIT button
BAQDataView baqOrderView; //SoldIT All tab
EpiUltraGrid SoldITOpen; //SoldIT Open UltraGrid
EpiUltraGrid SoldITClosed; //SoldIT Closed UltraGrid
EpiUltraGrid SoldITQuoted; //SoldIT Linked Quotes UltraGrid
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
pubBinding = "PartView.PartNum";
pub = oTrans.GetPublisher(pubBinding);
pubBinding2 = "PartView.PartNum"; //SoldIt TS
pub2 = oTrans.GetPublisher(pubBinding2); //SoldIt TS
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
// QuotedIT tab
CreateBAQView();
quotedItBtn = (EpiButton)csm.GetNativeControlReference("57f83d8e-8c24-4cb1-a33c-460af798b46f");
quotedItBtn.Click += new EventHandler(quoteItBtn_Click);
// SoldIT Tab
CreateOrdersBAQView(); // All tab
SoldItBtn = (EpiButton)csm.GetNativeControlReference("8a3c63cf-5510-4631-b911-57f2cb8b5b2c");
SoldItBtn.Click += new EventHandler(SoldItBtn_Click);
}
public void CreateBAQView() //QuotedIt Tab
{
baqQuoteView = new BAQDataView("QuotedIT");
oTrans.Add("QuotedITBAQ",baqQuoteView);
}
public void quoteItBtn_Click(object sender, System.EventArgs args)
{
//string pubBinding = "PartView.PartNum";
//IPublisher pub = oTrans.GetPublisher(pubBinding);
if( pub == null )
{
oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
pub = oTrans.GetPublisher(pubBinding);
baqQuoteView.SubscribeToPublisher(pub.PublishName, "QuoteDtl_PartNum"); //grid guid: 2a6ee4a6-71ae-47f9-afae-209137d771a1
}
if( pub != null )
{
oTrans.Refresh();
}
}
// Sold It start
public void CreateOrdersBAQView() // SoldIt Tab BAQ: SoldITAllBAQ (Master BAQ for tabs)
{
baqOrderView = new BAQDataView("SoldIT_All");
oTrans.Add("SoldITAllBAQ",baqOrderView);
}
public void SoldItBtn_Click(object sender, System.EventArgs args)
{
if( pub2 == null )
{
oTrans.PublishColumnChange(pubBinding2, "MyCustomPublish2");
pub2 = oTrans.GetPublisher(pubBinding2);
baqOrderView.SubscribeToPublisher(pub2.PublishName, "OrderDtl_PartNum"); //All Tab guid: a038104e-d4d9-459e-bcde-1e151b56752a
this.SoldITOpen = (EpiUltraGrid)csm.GetNativeControlReference("21dc0f20-5dca-40ab-a8cc-4560a2a550e0"); //Open Grid GUID
SoldITOpen.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_OpenLine"].FilterConditions.Add(FilterComparisionOperator.Equals, true); //Open Tab (Grid-Filter)
this.SoldITClosed = (EpiUltraGrid)csm.GetNativeControlReference("88ec1f93-ee07-453b-8b29-8ea4f9757770"); //Closed Grid GUID
SoldITClosed.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_OpenLine"].FilterConditions.Add(FilterComparisionOperator.Equals, false); //Closed Tab (Grid-Filter)
this.SoldITQuoted = (EpiUltraGrid)csm.GetNativeControlReference("ada360a7-35ae-438e-a85c-c75bab95c9f3"); //Linked Quotes Grid GUID
this.SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_QuoteNum"].FilterConditions.Add(FilterComparisionOperator.NotEquals, FilterCondition.BlankCellValue); //Linked Quotes Tab (Grid-Filter)
this.SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_QuoteNum"].FilterConditions.Add(FilterComparisionOperator.GreaterThan, 5); //Linked Quotes Tab (Grid-Filter)
}
if( pub2 != null )
{
oTrans.Refresh();
}
}
// SoldIT Tab End
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
quotedItBtn.Click -= new EventHandler(quoteItBtn_Click);
SoldItBtn.Click -= new EventHandler(quoteItBtn_Click);
}
}
I believe it’s pulling the data just not displaying it on grid. If I load a second part in Advisor without closing the form first it’ll populate the grids. What ever refresh it does when switching parts is updating the grids so they display but the button isn’t.
I tried putting oTrans.Refresh(); into the block loading the grid data but no joy even Googled and tried it with oTrans.Update();.
This way the publish/subscribe relationship is formed if not present, and it sends up a notification and refresh every time instead of just on subsequent updates. I don’t know if it will work or if the notification is necessary, but it shouldn’t hurt anything…
I took a different approach.
Instead of setting the publishers on retrieve, I it set them both on initialize.
On load, it sets the filter to some non-existent part.
Then, when the ‘Retrieve’ button is clicked, it clears the bad filter and puts the proper ones on.
Performance could be improved since it loads the data when the part is initially entered in in all BAQ Views instead of loading only when ‘Retrieve’ is clicked, but it works.
// **************************************************
// Custom code for PartAdvisorForm
// Created: 5/10/2017 2:26:05 PM
// **************************************************
extern alias Erp_Contracts_BO_PartAdvisor;
extern alias Erp_Contracts_BO_Part;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
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;
using Ice.Lib.Broadcast;
using Infragistics.Shared; //used for SoldIt
using Infragistics.Win; //used for SoldIt
using Infragistics.Win.UltraWinGrid; //used for SoldIt
using System.Diagnostics; //used for SoldIt
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 **
BAQDataView baqQuoteView; //QuotedIT tab
EpiButton quotedItBtn; //QuotedIT button
EpiButton SoldItBtn; //SoldIT tab button
BAQDataView baqOrderView; //SoldIT All tab
EpiUltraGrid SoldITOpen; //SoldIT Open UltraGrid
EpiUltraGrid SoldITClosed; //SoldIT Closed UltraGrid
EpiUltraGrid SoldITQuoted; //SoldIT Linked Quotes UltraGrid
EpiUltraGrid SoldITAll;
EpiUltraGrid quotedITgrid;
string pubBinding;
IPublisher pub;
//string pubBinding2; // SoldIT button
IPublisher pub2; // SoldIT button action var ?
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
pubBinding = "PartView.PartNum";
pub = oTrans.GetPublisher(pubBinding);
//pubBinding2 = "PartView.PartNum";
pub2 = oTrans.GetPublisher(pubBinding); //SoldIt
// End Wizard Added Variable Initialization
quotedITgrid = (EpiUltraGrid)csm.GetNativeControlReference("2a6ee4a6-71ae-47f9-afae-209137d771a1");
this.SoldITOpen = (EpiUltraGrid)csm.GetNativeControlReference("21dc0f20-5dca-40ab-a8cc-4560a2a550e0"); //Open Grid GUID
this.SoldITClosed = (EpiUltraGrid)csm.GetNativeControlReference("88ec1f93-ee07-453b-8b29-8ea4f9757770"); //Closed Grid GUID
this.SoldITQuoted = (EpiUltraGrid)csm.GetNativeControlReference("ada360a7-35ae-438e-a85c-c75bab95c9f3"); //Linked Quotes Grid GUID
this.SoldITAll = (EpiUltraGrid)csm.GetNativeControlReference("a038104e-d4d9-459e-bcde-1e151b56752a"); //Linked Quotes Grid GUID
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
CreateBAQView();
// QuotedIT tab
quotedItBtn = (EpiButton)csm.GetNativeControlReference("57f83d8e-8c24-4cb1-a33c-460af798b46f");
quotedItBtn.Click += new EventHandler(quoteItBtn_Click);
// SoldIT Tab
SoldItBtn = (EpiButton)csm.GetNativeControlReference("8a3c63cf-5510-4631-b911-57f2cb8b5b2c");
SoldItBtn.Click += new EventHandler(SoldItBtn_Click);
}
public void CreateBAQView()
{
baqQuoteView = new BAQDataView("QuotedIT");
oTrans.Add("QuotedITBAQ",baqQuoteView);
baqOrderView = new BAQDataView("SoldIT_All");
oTrans.Add("SoldITAllBAQ",baqOrderView);
if( pub == null )
{
oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
pub = oTrans.GetPublisher(pubBinding);
baqQuoteView.SubscribeToPublisher(pub.PublishName, "QuoteDtl_PartNum");
baqOrderView.SubscribeToPublisher(pub.PublishName, "OrderDtl_PartNum");
}
if( pub != null )
{
oTrans.Refresh();
}
}
public void quoteItBtn_Click(object sender, System.EventArgs args)
{
quotedITgrid.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
}
public void SoldItBtn_Click(object sender, System.EventArgs args)
{
SoldITAll.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
SoldITOpen.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
SoldITClosed.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
SoldITOpen.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_OpenLine"].FilterConditions.Add(FilterComparisionOperator.Equals, true); //Open Tab (Grid-Filter)
SoldITClosed.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_OpenLine"].FilterConditions.Add(FilterComparisionOperator.Equals, false); //Closed Tab (Grid-Filter)
this.SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_QuoteNum"].FilterConditions.Add(FilterComparisionOperator.NotEquals, FilterCondition.BlankCellValue); //Linked Quotes Tab (Grid-Filter)
this.SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_QuoteNum"].FilterConditions.Add(FilterComparisionOperator.GreaterThan, 5); //Linked Quotes Tab (Grid-Filter)
}
// SoldIT Tab End
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
quotedItBtn.Click -= new EventHandler(quoteItBtn_Click);
SoldItBtn.Click -= new EventHandler(SoldItBtn_Click);
quotedITgrid = null;
SoldITAll = null;
SoldITOpen = null;
SoldITClosed = null;
SoldITQuoted = null;
}
private void PartAdvisorForm_Load(object sender, EventArgs args)
{
// Add Event Handler Code
quotedITgrid.DisplayLayout.Bands[0].ColumnFilters["QuoteDtl_PartNum"].FilterConditions.Add(FilterComparisionOperator.Equals, "AARON_IS_AWESOME"); //Open Tab (Grid-Filter)
SoldITAll.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_PartNum"].FilterConditions.Add(FilterComparisionOperator.Equals, "AARON_IS_AWESOME");
SoldITOpen.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_PartNum"].FilterConditions.Add(FilterComparisionOperator.Equals, "AARON_IS_AWESOME");
SoldITClosed.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_PartNum"].FilterConditions.Add(FilterComparisionOperator.Equals, "AARON_IS_AWESOME");
SoldITQuoted.DisplayLayout.Bands[0].ColumnFilters["OrderDtl_PartNum"].FilterConditions.Add(FilterComparisionOperator.Equals, "AARON_IS_AWESOME");
}
}