Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Created September 28, 2022 13:27
Show Gist options
  • Save hasokeric/f07b2aac5508c680deb9c63a797a7a90 to your computer and use it in GitHub Desktop.
Save hasokeric/f07b2aac5508c680deb9c63a797a7a90 to your computer and use it in GitHub Desktop.
Example BAQDataView with Params
// **************************************************
// Custom code for RcptToInvForm
// Created: 7/21/2022 2:05:06 PM
//
// **************************************************
extern alias Erp_Contracts_BO_ReceiptsFromMfg;
extern alias Erp_Contracts_BO_PkgControlIDMaint;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Warehse;
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.Win.UltraWinDock;
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 **
BAQDataView MaterialBAQDV;
BAQDataView OperationBAQDV;
// 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
CreateBAQDV();
CreateRowRuleMaterialBAQDVCalculated_IsExceptionEquals_Y();;
CreateRowRuleOperationBAQDVCalculated_IsExceptionEquals_Y();;
this.radExceptionsOnly.CheckedChanged += new System.EventHandler(this.radExceptionsOnly_CheckedChanged);
this.radAll.CheckedChanged += new System.EventHandler(this.radAll_CheckedChanged);
// 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
this.radExceptionsOnly.CheckedChanged -= new System.EventHandler(this.radExceptionsOnly_CheckedChanged);
this.radAll.CheckedChanged -= new System.EventHandler(this.radAll_CheckedChanged);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
public void CreateBAQDV()
{
// Set up the BAQ(s) to be Called
MaterialBAQDV = new BAQDataView("CODE-IssuedExMaterial");
OperationBAQDV = new BAQDataView("CODE-IssuedExOperation");
// Add BAQ DataViews to the oTrans
oTrans.Add("MaterialBAQDV", MaterialBAQDV);
oTrans.Add("OperationBAQDV", OperationBAQDV);
// Set up the Strings (Field to Monitor, New Guid string, BAQ Parameter name)
Tuple<string, string, string>[] publishers =
{
Tuple.Create("PartTran.JobNum", Guid.NewGuid().ToString(), "JobNum"),
Tuple.Create("PartTran.AssemblySeq", Guid.NewGuid().ToString(), "AssemblySeq"),
Tuple.Create("PartTran.ActTranQty", Guid.NewGuid().ToString(), "ChangeQty"),
Tuple.Create("PartTran.DispUOM", Guid.NewGuid().ToString(), "OriginalUOM"),
Tuple.Create("PartTran.ActTransUOM", Guid.NewGuid().ToString(), "ChangeUOM"),
Tuple.Create("PartTran.PartNum", Guid.NewGuid().ToString(), "PartNum")
};
// Set up the Publisher Columns with the Guids
IPublisher pub1 = oTrans.GetPublisher(publishers[0].Item1);
if (pub1 == null)
{
foreach (var row in publishers)
{
oTrans.PublishColumnChange(row.Item1, row.Item2);
}
}
// Add the BAQ Parameters(BAQ Parameter Name, Comment, GUID Associated with the PublishColumnChange
foreach (var row in publishers)
{
this.MaterialBAQDV.AddBAQParameter(new BAQViewParameter(row.Item3, "", row.Item2));
this.OperationBAQDV.AddBAQParameter(new BAQViewParameter(row.Item3, "", row.Item2));
}
}
private void RcptToInvForm_Load(object sender, EventArgs args)
{
// version
RcptToInvForm.Text = RcptToInvForm.Text + " 22.7.25";
// dock grids
grdMaterialsIssueEx.Dock = DockStyle.Fill;
grdOperationIssueEx.Dock = DockStyle.Fill;
// hide the blue headings on the grids
this.HideTheCaption(MatIssMaterialsDockPanel, "");
this.HideTheCaption(MatIssOperationsDockPanel, "");
// Center Form
RcptToInvForm.StartPosition = FormStartPosition.CenterScreen;
System.Drawing.Rectangle wa = Screen.PrimaryScreen.WorkingArea;
RcptToInvForm.Location = new System.Drawing.Point((wa.Right - RcptToInvForm.Width) / 2, (wa.Bottom - RcptToInvForm.Height) / 2);
// Set the filter button to default to Exceptions
//EpiRadioButton radExceptionsOnly = (EpiRadioButton)csm.GetNativeControlReference("66043cb7-2a55-4f0e-80f3-264391447bad");
radExceptionsOnly.Checked = true;
}
private void HideTheCaption(Ice.Lib.Framework.EpiBasePanel p_Panel, string p_SetText)
{
Infragistics.Win.UltraWinDock.DockableWindow dockWindow = (Infragistics.Win.UltraWinDock.DockableWindow) p_Panel.Parent;
Infragistics.Win.UltraWinDock.DockableControlPane dockPane = (Infragistics.Win.UltraWinDock.DockableControlPane) dockWindow.Pane;
dockPane.Settings.ShowCaption = Infragistics.Win.DefaultableBoolean.False;
if (p_SetText != "")
{
dockPane.Text = p_SetText;
}
}
private void radExceptionsOnly_CheckedChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (radExceptionsOnly.Checked)
{
FilterTheIssueGrids("Calculated_IsException = 'Y'");
}
}
private void radAll_CheckedChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (radAll.Checked)
{
FilterTheIssueGrids("");
}
}
private void FilterTheIssueGrids(string strFilter)
{
MaterialBAQDV.dataView.RowFilter = strFilter;
MaterialBAQDV.Notify(new EpiNotifyArgs(oTrans, grdMaterialsIssueEx.Rows.Count - 1, EpiTransaction.NotifyType.Initialize));
// this is to work around the first time you go to All rows, the view was sticking to the bottom of the grid.
if (grdMaterialsIssueEx.Rows.Count > 0)
{
grdMaterialsIssueEx.ActiveRow = grdMaterialsIssueEx.Rows.GetFilteredInNonGroupByRows()[0];
}
OperationBAQDV.dataView.RowFilter = strFilter;
OperationBAQDV.Notify(new EpiNotifyArgs(oTrans, grdOperationIssueEx.Rows.Count - 1, EpiTransaction.NotifyType.Initialize));
if (grdOperationIssueEx.Rows.Count > 0)
{
grdOperationIssueEx.ActiveRow = grdOperationIssueEx.Rows.GetFilteredInNonGroupByRows()[0];
}
}
#region "Row Rules"
private void CreateRowRuleMaterialBAQDVCalculated_IsExceptionEquals_Y()
{
// Description: MaterialExceptions
// **** begin autogenerated code ****
RuleAction warningMaterialBAQDV_RowAction = RuleAction.AddRowSettings(this.oTrans, "MaterialBAQDV", false, SettingStyle.Warning);
RuleAction[] ruleActions = new RuleAction[] {
warningMaterialBAQDV_RowAction};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleMaterialBAQDVCalculated_IsExceptionEquals_Y = new RowRule("MaterialBAQDV.Calculated_IsException", RuleCondition.Equals, "Y", ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["MaterialBAQDV"])).AddRowRule(rrCreateRowRuleMaterialBAQDVCalculated_IsExceptionEquals_Y);
// **** end autogenerated code ****
}
private void CreateRowRuleOperationBAQDVCalculated_IsExceptionEquals_Y()
{
// Description: OperationExceptions
// **** begin autogenerated code ****
RuleAction warningOperationBAQDV_RowAction = RuleAction.AddRowSettings(this.oTrans, "OperationBAQDV", false, SettingStyle.Warning);
RuleAction[] ruleActions = new RuleAction[] {
warningOperationBAQDV_RowAction};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleOperationBAQDVCalculated_IsExceptionEquals_Y = new RowRule("OperationBAQDV.Calculated_IsException", RuleCondition.Equals, "Y", ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["OperationBAQDV"])).AddRowRule(rrCreateRowRuleOperationBAQDVCalculated_IsExceptionEquals_Y);
// **** end autogenerated code ****
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment