Hi
For the second thing to send over only the item selected in the tracker i
used a xml as follows
There are other options too but thats what i used
PLACE IN CALLING PROGRAM
BUTTON OR MENU TO CALL
Private Sub importClick(sender As Object, e As
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
Dim edvPart As EpiDataView = CType(oTrans.EpiDataViews("Part"),
EpiDataView)
Dim strPartNum As String = edvpart.dataView(edvpart.Row)("PartNum")
WriteReportParam(PartForm.Session,strPartNum)
ProcessCaller.LaunchForm(oTrans, "UDPL")
End Sub
Private Function WriteReportParam(FormSession As Object, ParamArray args As
String()) As Boolean
' function will take as many parameters as you like and pass them over
to report
' make sure your report is expecting at least the number you are
passing.
' you can pass less, the extra fields on the report side will just be
left blank.
' object explorer claims you can do this directly but without the cast
you get compile errors.
Try
Dim Session As Epicor.Mfg.Core.Session = DirectCast(FormSession,
Epicor.Mfg.Core.Session)
' the called report will use the same name to read the data
' in 9.05 the session id has illegal characters for use in a
filename
' so we remove them.
Dim SessionID As String = Session.SessionID
Dim sb As New System.Text.StringBuilder()
For i As Integer = 0 To SessionID.Length - 1
If Char.IsLetterOrDigit(SessionID(i)) Then
sb.Append(SessionID(i))
End If
Next
Dim ReportName As String = Convert.ToString(sb) & ".xml"
Dim FieldName As String = String.Empty
Dim PreFix As String = "Field"
Dim ReportParam As DataTable
' tell GetTable we need as many columns as we have arguments.
ReportParam = GetTable(args.Length)
' create a blank row
Dim Row As DataRow = ReportParam.NewRow()
For i As Integer = 1 To args.Length
' populate field with value passed over
FieldName = PreFix & i.ToString()
Row(FieldName) = args(i - 1)
Next
ReportParam.Rows.Add(Row)
ReportParam.WriteXml(ReportName)
Return True
Catch e As Exception
ExceptionBox.Show(e)
Return False
End Try
End Function
Private Function GetTable(howMany As Integer) As DataTable
'
' Here we create a DataTable that holds all the needed information
'
Dim table As New DataTable()
' this name matches name of report parameter table
' if you change it here you need to change it in the report form
' field names will match the fields in the report parameter table
table.TableName = "ReportParam"
Dim colWork As DataColumn
Dim fieldname As [String] = [String].Empty
' make as many columns as we have arguments/parameters
For i As Integer = 1 To howMany
fieldname = "Field" & i.ToString()
colWork = New DataColumn(fieldname, GetType(String))
table.Columns.Add(colWork)
Next
Return table
End Function
PLACE IN BAQ FORM
Imports System.IO
' code to get report parameters
Private Sub GetReportParam()
Dim Session As Epicor.Mfg.Core.Session =
DirectCast(BAQReportForm.Session, Epicor.Mfg.Core.Session)
' in 9.05 the session id has illegal characters for use in a filename
' so we remove them.
Dim SessionID As [String] = Session.SessionID
Dim sb As New System.Text.StringBuilder()
For i As Integer = 0 To SessionID.Length - 1
If Char.IsLetterOrDigit(SessionID(i)) Then
sb.Append(SessionID(i))
End If
Next
Dim SourceFile As [String] = Convert.ToString(sb) & ".xml"
' dataset xml read is simpler than using datatable xml read
Dim ds As New DataSet()
Try
If File.Exists(SourceFile) Then
ds.ReadXml(SourceFile)
File.Delete(SourceFile)
Dim TableName As [String] = "ReportParam"
Dim edvReport As EpiDataView =
DirectCast(oTrans.EpiDataViews(TableName), EpiDataView)
Dim FieldName As [String] = [String].Empty
Dim Prefix As [String] = "Field"
For i As Integer = 1 To ds.Tables(TableName).Columns.Count
FieldName = Prefix & i.ToString()
If edvReport.dataView.Table.Columns.Contains(FieldName) Then
edvReport.dataView(edvReport.Row)(FieldName) =
ds.Tables(TableName).Rows(0)(FieldName)
Else
MessageBox.Show("Too many Parameters have been passed to
report")
End If
Next
' cheat and notify all
oTrans.NotifyAll()
' nothing special at the moment
Else
End If
Catch e As Exception
ExceptionBox.Show(e)
End Try
End Sub
Private Sub BAQReportForm_Load(ByVal sender As Object, ByVal args As
EventArgs)
'Add Event Handler Code
GetReportParam()
End Sub
For the second thing to send over only the item selected in the tracker i
used a xml as follows
There are other options too but thats what i used
PLACE IN CALLING PROGRAM
BUTTON OR MENU TO CALL
Private Sub importClick(sender As Object, e As
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
Dim edvPart As EpiDataView = CType(oTrans.EpiDataViews("Part"),
EpiDataView)
Dim strPartNum As String = edvpart.dataView(edvpart.Row)("PartNum")
WriteReportParam(PartForm.Session,strPartNum)
ProcessCaller.LaunchForm(oTrans, "UDPL")
End Sub
Private Function WriteReportParam(FormSession As Object, ParamArray args As
String()) As Boolean
' function will take as many parameters as you like and pass them over
to report
' make sure your report is expecting at least the number you are
passing.
' you can pass less, the extra fields on the report side will just be
left blank.
' object explorer claims you can do this directly but without the cast
you get compile errors.
Try
Dim Session As Epicor.Mfg.Core.Session = DirectCast(FormSession,
Epicor.Mfg.Core.Session)
' the called report will use the same name to read the data
' in 9.05 the session id has illegal characters for use in a
filename
' so we remove them.
Dim SessionID As String = Session.SessionID
Dim sb As New System.Text.StringBuilder()
For i As Integer = 0 To SessionID.Length - 1
If Char.IsLetterOrDigit(SessionID(i)) Then
sb.Append(SessionID(i))
End If
Next
Dim ReportName As String = Convert.ToString(sb) & ".xml"
Dim FieldName As String = String.Empty
Dim PreFix As String = "Field"
Dim ReportParam As DataTable
' tell GetTable we need as many columns as we have arguments.
ReportParam = GetTable(args.Length)
' create a blank row
Dim Row As DataRow = ReportParam.NewRow()
For i As Integer = 1 To args.Length
' populate field with value passed over
FieldName = PreFix & i.ToString()
Row(FieldName) = args(i - 1)
Next
ReportParam.Rows.Add(Row)
ReportParam.WriteXml(ReportName)
Return True
Catch e As Exception
ExceptionBox.Show(e)
Return False
End Try
End Function
Private Function GetTable(howMany As Integer) As DataTable
'
' Here we create a DataTable that holds all the needed information
'
Dim table As New DataTable()
' this name matches name of report parameter table
' if you change it here you need to change it in the report form
' field names will match the fields in the report parameter table
table.TableName = "ReportParam"
Dim colWork As DataColumn
Dim fieldname As [String] = [String].Empty
' make as many columns as we have arguments/parameters
For i As Integer = 1 To howMany
fieldname = "Field" & i.ToString()
colWork = New DataColumn(fieldname, GetType(String))
table.Columns.Add(colWork)
Next
Return table
End Function
PLACE IN BAQ FORM
Imports System.IO
' code to get report parameters
Private Sub GetReportParam()
Dim Session As Epicor.Mfg.Core.Session =
DirectCast(BAQReportForm.Session, Epicor.Mfg.Core.Session)
' in 9.05 the session id has illegal characters for use in a filename
' so we remove them.
Dim SessionID As [String] = Session.SessionID
Dim sb As New System.Text.StringBuilder()
For i As Integer = 0 To SessionID.Length - 1
If Char.IsLetterOrDigit(SessionID(i)) Then
sb.Append(SessionID(i))
End If
Next
Dim SourceFile As [String] = Convert.ToString(sb) & ".xml"
' dataset xml read is simpler than using datatable xml read
Dim ds As New DataSet()
Try
If File.Exists(SourceFile) Then
ds.ReadXml(SourceFile)
File.Delete(SourceFile)
Dim TableName As [String] = "ReportParam"
Dim edvReport As EpiDataView =
DirectCast(oTrans.EpiDataViews(TableName), EpiDataView)
Dim FieldName As [String] = [String].Empty
Dim Prefix As [String] = "Field"
For i As Integer = 1 To ds.Tables(TableName).Columns.Count
FieldName = Prefix & i.ToString()
If edvReport.dataView.Table.Columns.Contains(FieldName) Then
edvReport.dataView(edvReport.Row)(FieldName) =
ds.Tables(TableName).Rows(0)(FieldName)
Else
MessageBox.Show("Too many Parameters have been passed to
report")
End If
Next
' cheat and notify all
oTrans.NotifyAll()
' nothing special at the moment
Else
End If
Catch e As Exception
ExceptionBox.Show(e)
End Try
End Sub
Private Sub BAQReportForm_Load(ByVal sender As Object, ByVal args As
EventArgs)
'Add Event Handler Code
GetReportParam()
End Sub
On Thu, Feb 3, 2011 at 2:45 PM, cooner_55421 <cooner_55421@...> wrote:
>
>
> Hi,
>
> I want to add a BAQ report to a part tracker screen.
> I haven't had to do the following before:
>
> - add it to the action menu of the part tracker
> - Include only details for part loaded in tracker
>
> Looks like I need to use Infragistics.Win.UltraWinToolbars.ButtonTool?
> Not sure what else might be involved.
>
> Anybody have pointers or a sample I can look at?
>
> Thanks
>
>
>
[Non-text portions of this message have been removed]