Here is some code to try:
As sales order entry does (did?) not update data before printing, this code hides the form's print 'buttons' and inserts buttons you can capture the click event on, so you can make sure data has been updated.
I added a dataview notification event and set the enabled properties of the print buttons to be equal to the OrderHed.ReadyToCalc value
this may accomplish what you want.....
bw
'//**************************************************
'// Custom VB.NET code for SalesOrderForm
'// Created: 4/17/2009 1:32:16 PM
'//**************************************************
Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Searches
Imports Epicor.Mfg.BO
Imports System.Reflection
Imports System.Collections
Module Script
'// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
'// Begin Wizard Added Module Level Variables **
Private WithEvents edvOrderHed As EpiDataView
'// End Wizard Added Module Level Variables **
'// Add Custom Module Level Variables Here **
dim tools as Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
dim printButton as Infragistics.Win.UltraWinToolbars.ButtonTool
Sub InitializeCustomCode()
'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization' lines **
'// Begin Wizard Added Variable Intialization
edvOrderHed = CType(oTrans.EpiDataViews("OrderHed"), EpiDataView)
'// End Wizard Added Variable Intialization
'// Begin Custom Method Calls
dim obj as Object = GetType(Epicor.Mfg.UI.App.SalesOrderEntry.SalesOrderForm).InvokeMember("baseToolbarsManager", BindingFlags.Instance Or BindingFlags.GetField Or BindingFlags.NonPublic, Nothing, SalesOrderForm, Nothing)
tools = ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
printButton = addMyPrintButton()
addhandler printButton.ToolClick, addressof printClick
'// End Custom Method Calls
End Sub
Function addMyPrintButton() As Infragistics.Win.UltraWinToolbars.ButtonTool
dim printButton as new Infragistics.Win.UltraWinToolbars.ButtonTool("MyPrintTool")
dim pop as Infragistics.Win.UltraWinToolbars.PopupMenuTool
dim std as Infragistics.Win.UltraWinToolbars.UltraToolbar
printButton.SharedProps.Caption = "Print Sales Oder Ack"
if tools.Tools.Exists("MyPrintTool") = false
tools.Tools.Add(printButton)
pop = CType(tools.Tools("ActionsMenu"), Infragistics.Win.UltraWinToolbars.PopupMenuTool)
pop.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase() {printButton})
Tools.Toolbars("Standard Tools").Tools.Add(printButton)
dim internalFunctionImage As System.Drawing.Image = EpiUIImages.GetImage("Print")
dim appearance As New Infragistics.Win.Appearance
appearance.Image = internalFunctionImage
tools.Tools("MyPrintTool").SharedProps.AppearancesLarge.Appearance = appearance
tools.Tools("MyPrintTool").SharedProps.AppearancesSmall.Appearance = appearance
end if
if tools.Tools.Exists("SalesOrderPrintTool")
'//MessageBox.Show("SalesOrderPrintTool")
tools.Tools("SalesOrderPrintTool").SharedProps.Visible = false
end if
if tools.Tools.Exists("PrintTool")
'//MessageBox.Show("SalesOrderPrintTool")
tools.Tools("PrintTool").SharedProps.Visible = false
end if
return printButton
End Function
Sub DestroyCustomCode()
'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
'// Begin Wizard Added Object Disposal
edvOrderHed = Nothing
'// End Wizard Added Object Disposal
'// Begin Custom Code Disposal
removehandler printButton.ToolClick, addressof printClick
'// End Custom Code Disposal
End Sub
Private Sub printClick(sender As Object, e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
oTrans.Update()
dim num as Integer = Integer.Parse(oTrans.CurrentOrderNum)
If (num > 0) Then
Try
Dim options2 As New LaunchFormOptions()
options2.SuppressFormSearch = True
options2.ValueIn = num.ToString
ProcessCaller.LaunchForm(oTrans, "Epicor.Mfg.UIRpt.SalesOrderAck", options2)
Catch
End Try
End If
End Sub
Private Sub edvOrderHed_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs) Handles edvOrderHed.EpiViewNotification
'// ** 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.NotifyType = EpiTransaction.NotifyType.Initialize) Then
If (args.Row > -1) Then
tools.Tools("MyPrintTool").SharedProps.Enabled = view.dataView(args.Row)("ReadyToCalc")
End If
End If
End Sub
End Module
As sales order entry does (did?) not update data before printing, this code hides the form's print 'buttons' and inserts buttons you can capture the click event on, so you can make sure data has been updated.
I added a dataview notification event and set the enabled properties of the print buttons to be equal to the OrderHed.ReadyToCalc value
this may accomplish what you want.....
bw
'//**************************************************
'// Custom VB.NET code for SalesOrderForm
'// Created: 4/17/2009 1:32:16 PM
'//**************************************************
Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Searches
Imports Epicor.Mfg.BO
Imports System.Reflection
Imports System.Collections
Module Script
'// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
'// Begin Wizard Added Module Level Variables **
Private WithEvents edvOrderHed As EpiDataView
'// End Wizard Added Module Level Variables **
'// Add Custom Module Level Variables Here **
dim tools as Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
dim printButton as Infragistics.Win.UltraWinToolbars.ButtonTool
Sub InitializeCustomCode()
'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization' lines **
'// Begin Wizard Added Variable Intialization
edvOrderHed = CType(oTrans.EpiDataViews("OrderHed"), EpiDataView)
'// End Wizard Added Variable Intialization
'// Begin Custom Method Calls
dim obj as Object = GetType(Epicor.Mfg.UI.App.SalesOrderEntry.SalesOrderForm).InvokeMember("baseToolbarsManager", BindingFlags.Instance Or BindingFlags.GetField Or BindingFlags.NonPublic, Nothing, SalesOrderForm, Nothing)
tools = ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
printButton = addMyPrintButton()
addhandler printButton.ToolClick, addressof printClick
'// End Custom Method Calls
End Sub
Function addMyPrintButton() As Infragistics.Win.UltraWinToolbars.ButtonTool
dim printButton as new Infragistics.Win.UltraWinToolbars.ButtonTool("MyPrintTool")
dim pop as Infragistics.Win.UltraWinToolbars.PopupMenuTool
dim std as Infragistics.Win.UltraWinToolbars.UltraToolbar
printButton.SharedProps.Caption = "Print Sales Oder Ack"
if tools.Tools.Exists("MyPrintTool") = false
tools.Tools.Add(printButton)
pop = CType(tools.Tools("ActionsMenu"), Infragistics.Win.UltraWinToolbars.PopupMenuTool)
pop.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase() {printButton})
Tools.Toolbars("Standard Tools").Tools.Add(printButton)
dim internalFunctionImage As System.Drawing.Image = EpiUIImages.GetImage("Print")
dim appearance As New Infragistics.Win.Appearance
appearance.Image = internalFunctionImage
tools.Tools("MyPrintTool").SharedProps.AppearancesLarge.Appearance = appearance
tools.Tools("MyPrintTool").SharedProps.AppearancesSmall.Appearance = appearance
end if
if tools.Tools.Exists("SalesOrderPrintTool")
'//MessageBox.Show("SalesOrderPrintTool")
tools.Tools("SalesOrderPrintTool").SharedProps.Visible = false
end if
if tools.Tools.Exists("PrintTool")
'//MessageBox.Show("SalesOrderPrintTool")
tools.Tools("PrintTool").SharedProps.Visible = false
end if
return printButton
End Function
Sub DestroyCustomCode()
'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
'// Begin Wizard Added Object Disposal
edvOrderHed = Nothing
'// End Wizard Added Object Disposal
'// Begin Custom Code Disposal
removehandler printButton.ToolClick, addressof printClick
'// End Custom Code Disposal
End Sub
Private Sub printClick(sender As Object, e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
oTrans.Update()
dim num as Integer = Integer.Parse(oTrans.CurrentOrderNum)
If (num > 0) Then
Try
Dim options2 As New LaunchFormOptions()
options2.SuppressFormSearch = True
options2.ValueIn = num.ToString
ProcessCaller.LaunchForm(oTrans, "Epicor.Mfg.UIRpt.SalesOrderAck", options2)
Catch
End Try
End If
End Sub
Private Sub edvOrderHed_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs) Handles edvOrderHed.EpiViewNotification
'// ** 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.NotifyType = EpiTransaction.NotifyType.Initialize) Then
If (args.Row > -1) Then
tools.Tools("MyPrintTool").SharedProps.Enabled = view.dataView(args.Row)("ReadyToCalc")
End If
End If
End Sub
End Module
--- In vantage@yahoogroups.com, "Mark Wonsil" <mark_wonsil@...> wrote:
>
> Brian wrote:
> > Yes unfortunately the BOs do not expose an OnPrint() event handler.
> >
> > Seems like this would be a nice feature to add to the
> > Business Object Layer in Vantage. The handlers wouldn't have
> > to *do* anything except get fired before the handoff to the
> > print routines, but they'd give BPM authors a place to insert
> > messages and exceptions, etc.
>
> As I mentioned in a different post, Epicor 9 has added Data Directives to
> the BPM model. This allows one to trigger on the
> addition/deleting/modification of a record in a table. Could one look at the
> SysRptLst table and do something? I haven't tried but it may be a
> possibility.
>
> I made a suggestion to Epicor to introduce Process Directives so that one
> could do pre-post processing on print jobs, cost rollups, scheduling, MRP,
> etc. No word back but maybe if others chirped in...
>
> Mark W.
>