Here is an old V8 example of an MES End Activity customization
- pops up different messages depending on previous qtys and new qty being reported
'//**************************************************
'// Custom VB.NET code for EndActForm
'// Rev01: 7/12/2010 - 8.03.04.409C
'//**************************************************
'// Custom Assembly References
'// Epicor.Mfg.AD.JobEntry
'// Epicor.Mfg.BO.JobEntry
'// Epicor.Mfg.IF.IJobEntry
'// Epicor.Mfg.AD.JobOperSearch
'// Epicor.Mfg.BO.JobOperSearch
'// Epicor.Mfg.IF.IJobOperSearch
'// Epicor.Mfg.AD.Labor
'// Epicor.Mfg.BO.Labor
'// Epicor.Mfg.IF.ILabor
'****************************************************
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
Module 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 **
Sub InitializeCustomCode()
'// ** Wizard
Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization'
lines **
'// Begin
Wizard Added Variable Intialization
'// End
Wizard Added Variable Intialization
'// Begin
Custom Method Calls
'// End
Custom Method Calls
SetExtendedProperties()
End Sub
Sub 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
End Sub
Private Sub
SetExtendedProperties()
Dim edvcJobOper As
EpiDataView = CType(oTrans.EpiDataViews("cJobOper"),EpiDataView)
If edvcJobOper.dataView.Table.Columns.Contains("RunQty")
Then
' Begin
Wizard Added ExtendedProperty Settings: edvcJobOper-RunQty
edvcJobOper.dataView.Table.Columns("RunQty").ExtendedProperties("Format")
= "->>>,>>>,>>>,>>9.99"
' End
Wizard Added ExtendedProperty Settings: edvcJobOper-RunQty
End If
End Sub
Private Sub LaborDtl_BeforeFieldChange(ByVal sender As
object, ByVal args As DataColumnChangeEventArgs) Handles LaborDtl_Column.ColumnChanging
'// ** Argument
Properties and Uses **
'// args.Row("[FieldName]")
'// args.Column,
args.ProposedValue, args.Row
'
'Add Event
Handler Code
'
Select Case
args.Column.ColumnName
Case "LaborQty"
' Imports Epicor.Mfg.UI.Adapters
Dim joAdapt As
JobOperSearchAdapter = New JobOperSearchAdapter(EndActForm)
joAdapt.BOConnect()
Dim gotJo As
Boolean = false
try
gotJo = joAdapt.GetByID(args.Row("jobNum"),
args.Row("assemblySeq"), args.Row("oprSeq"))
catch e as
exception
'oTrans.PushStatusText("Did
not get Job " + args.Row("JobNum"),false)
end try
Dim
previousQuantityReported as decimal = 0
try
previousQuantityReported = GetPreviousQuantityReported(args.Row("JobNum"),args.Row("AssemblySeq"),args.Row("oprSeq"))
catch e as
exception
' oTrans.PushStatusText("Did
not get Previous Quantity for Job " + args.Row("JobNum") +
", " + e.message,false)
end try
Dim currentQuantityReported
as decimal = args.ProposedValue
Dim
totalQuantityReported as decimal = CDEC(previousQuantityReported) + CDEC(currentQuantityReported)
Dim
remainingQuantity as decimal = joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty")
- previousQuantityReported
if gotJo
try
Dim dRes
As DialogResult
if
totalQuantityReported > joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty")
MessageBox.Show("The current quantity entered of " + args.ProposedValue.ToString()
+ ", along with the previous quantity entered of " + previousQuantityReported.ToString()
+ ", gives a total quantity of " + totalQuantityReported.ToString() +
" which is greater than the " + joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty").ToString
+ " defined as the production quantity for this job assembly operation. Please try again", "Confirm Labor
Quantity")
args.Proposedvalue = 0
else
if args.ProposedValue
< joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty")
if
previousQuantityReported = 0
dRes = MessageBox.Show("The current quantity of " + args.ProposedValue.ToString()
+ " entered is less than the job assembly operation quantity of "+ joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty").ToString
+ ". To continue anyway, click Yes. Click No to correct your quantity.", "Confirm
Labor Quantity", MessageBoxButtons.YesNo)
else
if (args.ProposedValue
+ PreviousQuantityReported) < joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty")
Dim messageString as string = "The current quantity entered of "
+ args.ProposedValue.ToString() + ", along with the previous quantity
entered of " + previousQuantityReported.ToString() + ", gives a total
quantity of " + totalQuantityReported.ToString() + " which is less
than the " + joAdapt.JobOperSearchData.Tables("JobOper").Rows(0)("RunQty").ToString
+ " defined as the quantity for the job assembly operation. To continue anyway, click Yes. Click No to correct your quantity, and note
that a quantity of " + remainingQuantity.ToString()
+ " would complete this job."
dRes = MessageBox.Show(messageString, "Confirm Labor Quantity",
MessageBoxButtons.YesNo)
else
'Its
OK - they are reporting up to the valid job production quanity
dRes
= DialogResult.Yes
end if
end
if
If (dRes
= DialogResult.Yes) Then
'Continue
'args.Cancel
= True
Else
args.proposedValue = 0
End If
End if
End if
catch e
as exception
'oTrans.PushStatusText("Problem
checking quantities for " + args.Row("JobNum") + ", "
+ e.message,false)
end try
Else
'oTrans.PushStatusText("Did
not get Job Number " + args.Row("JobNum"),false)
End if
joAdapt.Dispose()
Case
Else
End Select
End Sub
Private Function
GetPreviousQuantityReported(jobNum as string, assemblySeq as integer, oprSeq as
integer) as decimal
Dim
previousQty as decimal = 0
DIm lbrDS as
System.Data.DataSet
Dim
whereClause as string = "JobNum = '" + jobNum + "' and
AssemblySeq = '" + assemblySeq.ToString() + "' and OprSeq = '" +
oprSeq.ToString() + "'"
Dim
recSelected as boolean = false
try
'try to
get labor transactions for job
lbrDS = SearchFunctions.listLookup(oTrans,"LaborDtlSearchAdapter",recSelected,false,whereClause)
if
recSelected
for
each lbrRow as DataRow in lbrDS.Tables(0).Rows
if
lbrRow("LaborQty") > 0
previousQty = previousQty + lbrRow("LaborQty")
end if
next
else
'messagebox.show
("No Labor Detail Records Found for whereClause " + whereClause)
end
if
catch e as
exception
'messagebox.show ("Problem getting
labor transactions for Job " + jobNum.ToString() + ", " + e.message
+ " using whereClause" + whereClause)
end try
return
previousQty
End Function
End Module