Hi All!
I am working to optimize one of my dashboards. My goal is to have a dashboard with one ultragrid (not native), and to use that ultragrid to display either the results of one BAQ or another, based on whether or not the part/rev is checked out.
I setup a new dashboard with an empty tracker view, and my updatable BAQ. I’d like to ignore the native grid added to the dashboard, and work only on my custom ultragrid. So I put the native grid into a separate tab, and use the tracker view in full screen.
To the tracker view I added a few unbound controls. My part number text box, and a combo box for selecting the revision. Below that I have a button to initiate the search, and an ultra grid to display the results.
My question is in defining the epibinding and updating the ultragrid. The code I have posted here returns all the rows of the BAQ, not just the part/rev I want. I think it is because of how I link the part and rev fields to their underlying BAQs. I have done this successfully with bound fields. What’s the best way to link an ultragrid to a BAQ with two unbound criteria fields?
Here is my complete customization code, as well as the dashboard, BAQ and customization files if you want to try it yourself.
Thank you for your time!
Nate
// **************************************************
// Custom code for MainController
// Created: 5/6/2021 9:17:20 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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 System.Reflection;
public class Script
{
public BAQCombo cmbpartrev;
public EpiTextBox txtPart;
BAQDataView ecoRevOpsBAQDV;
BAQDataView partRevOpsBAQDV;
// ** 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()
{
CreatePartRevOpsBAQDV();
// ** 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
this.txtPartNum.ValueChanged += new System.EventHandler(this.txtPartNum_ValueChanged);
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
// End Wizard Added Custom Method Calls
txtPart = (EpiTextBox)csm.GetNativeControlReference("85eb5e53-1a90-4a85-8277-3321f576de88");
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.txtPartNum.ValueChanged -= new System.EventHandler(this.txtPartNum_ValueChanged);
this.btnSearch.Click -= new System.EventHandler(this.btnSearch_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void RefreshMe()
{
MainController.AppControlPanel.HandleToolClick("RefreshTool", new
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));
}
private void ClearMe()
{
MainController.AppControlPanel.HandleToolClick("ClearTool", new
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["ClearTool"], null));
}
public void CreateEcoRevOpsBAQDV()
{
ecoRevOpsBAQDV = new BAQDataView("getPartRevOpECO"); //baq name
oTrans.Add("EcoRevOpsBAQDV",ecoRevOpsBAQDV);
UpdateEcoRevOpsBAQDV();
}
public void UpdateEcoRevOpsBAQDV()
{
if (txtPartNum.Value != null)
{
string pub1Binding = txtPartNum.Text; //Native form linking field 1
IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
if(pub1==null)
{
string pubName = Guid.NewGuid().ToString();
oTrans.PublishColumnChange(pub1Binding, pubName);
pub1 = oTrans.GetPublisher(pub1Binding);
}
if(pub1 !=null)
ecoRevOpsBAQDV.SubscribeToPublisher(pub1.PublishName, "ECORev_PartNum"); //BAQ linking field 1
string pub2Binding = cmbpartrev.Text; //Native form linking field 2
IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
if(pub2==null)
{
string pubName = Guid.NewGuid().ToString();
oTrans.PublishColumnChange(pub2Binding, pubName);
pub2 = oTrans.GetPublisher(pub2Binding);
}
if(pub2 !=null)
ecoRevOpsBAQDV.SubscribeToPublisher(pub2.PublishName, "ECORev_RevisionNum");//BAQ linking field 2
}
}
public void CreatePartRevOpsBAQDV()
{
partRevOpsBAQDV = new BAQDataView("EditAnyOp"); //baq name
oTrans.Add("PartRevOpsBAQDV",partRevOpsBAQDV);
UpdatePartRevOpsBAQDV();
}
public void UpdatePartRevOpsBAQDV()
{
if (txtPartNum.Value != null)
{
string pub1Binding = txtPartNum.Text; //Native form linking field 1
IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
if(pub1==null)
{
string pubName = Guid.NewGuid().ToString();
oTrans.PublishColumnChange(pub1Binding, pubName);
pub1 = oTrans.GetPublisher(pub1Binding);
}
if(pub1 !=null)
partRevOpsBAQDV.SubscribeToPublisher(pub1.PublishName, "PartRev_PartNum"); //BAQ linking field 1
string pub2Binding = cmbpartrev.Text; //Native form linking field 2
IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
if(pub2==null)
{
string pubName = Guid.NewGuid().ToString();
oTrans.PublishColumnChange(pub2Binding, pubName);
pub2 = oTrans.GetPublisher(pub2Binding);
}
if(pub2 !=null)
partRevOpsBAQDV.SubscribeToPublisher(pub2.PublishName, "PartRev_RevisionNum");//BAQ linking field 2
}
}
private void getRevs()
{
cmbpartrev = (Ice.Lib.Framework.BAQCombo)csm.GetNativeControlReference("67f0a748-4944-468b-96b0-cce76dfb5588");
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("getPartRev");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("part", txtPartNum.Text, "nvarchar", false, Guid.NewGuid(), "A");
dqa.ExecuteByID("getPartRev", qeds);
if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
cmbpartrev.DataSource = dqa.QueryResults.Tables["Results"];
cmbpartrev.DisplayMember = "PartRev_RevisionNum";
cmbpartrev.ValueMember = "PartRev_RevisionNum";
oTrans.NotifyAll();
}
}
private void CheckForCheckedOut()
{
if (partRevOpsBAQDV == null) {CreatePartRevOpsBAQDV();}
if (partRevOpsBAQDV.dataView.Count > 0) //Rev is checked out!
{
//Show ECORev in grid
MessageBox.Show("Checked Out!");
if(ecoRevOpsBAQDV == null) {CreateEcoRevOpsBAQDV();}
UpdateEcoRevOpsBAQDV();
epiUltraGridC1.EpiBinding = "EcoRevOpsBAQDV";
epiUltraGridC1.Refresh();
MethodInfo mi = ecoRevOpsBAQDV.GetType().GetMethod("InvokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(ecoRevOpsBAQDV, new object[]{ true });
}
else
{
//Show PartRev in grid
MessageBox.Show("Not Checked Out!");
UpdatePartRevOpsBAQDV();
epiUltraGridC1.EpiBinding = "PartRevOpsBAQDV";
epiUltraGridC1.Refresh();
MethodInfo mi2 = partRevOpsBAQDV.GetType().GetMethod("InvokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
mi2.Invoke(partRevOpsBAQDV, new object[]{ true });
}
}
private void txtPartNum_ValueChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
getRevs();
}
private void btnSearch_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
CheckForCheckedOut();
epiUltraGridC1.Refresh();
}
}
EditAnyOp_New.dbd (509.2 KB)
EditAnyOp.baq (299.7 KB) getPartRevOpECO.baq (23.4 KB) getPartRev.baq (13.5 KB) App.EditAnyOp_New.MainController_Customization_Custom1_CustomExport.xml (92.8 KB)