Hi Ephraim,
I trimmed some of the code because I was just trying to show the part to
access the selected rows.
Here is my full code:
Add these lines to the "Custom Module Level Variables" section:
private static Process current = null;
private static System.IntPtr hProcess = default(System.IntPtr);
private static int consoleSessionID = 0;
[DllImport("Epicor.Mfg.Lib.GetConsoleSessionID.dll", CharSet =
CharSet.Auto)]
public static extern int getSession(IntPtr pHandle);
Add these lines to the InitializeCustomCode() section:
current = Process.GetCurrentProcess();
hProcess = current.Handle;
consoleSessionID = getSession(hProcess);
if ((consoleSessionID < 0))
{
consoleSessionID = 0;
}
Here is my function that I've attached to the Click event of a button on
my dashboard:
private static void btnPrintPickList_Click(object sender,
System.EventArgs args)
{
// ** Place Event Handling Code Here **
Infragistics.Win.UltraWinGrid.SelectedRowsCollection selectedRows;
Session epiSession;
epiSession = (Session) MainController.Session;
SOPickListReport rptSOPickList = new
SOPickListReport(epiSession.ConnectionPool);
SOPickListReportDataSet rptDSSOPickList =
rptSOPickList.GetNewParameters();
//Get reference to grid on grid view
EpiUltraGrid myGrid = (EpiUltraGrid)
csm.GetNativeControlReference("0bd59551-a244-41dc-86c1-d2c884c45fb4");
//Check to see if any rows are selected.
If not, stop.
if (myGrid.Selected.Rows.Count < 1)
{
myGrid = null;
rptDSSOPickList = null;
rptSOPickList = null;
epiSession = null;
MessageBox.Show("Please
select an order and then try again.");
return;
}
//Iterate through selected rows, build
order list and determine greatest shipby date
selectedRows = myGrid.Selected.Rows;
List<string> lstOrderNums = new List<string>();
DateTime dtFromDate = DateTime.Today;
DateTime dtToDate = DateTime.Today;
DateTime dtShipBy;
// Loop through all the selected rows
//
for ( int i = 0; i < selectedRows.Count; i++ )
{
Infragistics.Win.UltraWinGrid.UltraGridRow row;
row = selectedRows[i];
//add the order number
to the list if it isn't already
if
(!lstOrderNums.Contains(row.Cells["OrderHed.OrderNum"].Text))
{
lstOrderNums.Add(row.Cells["OrderHed.OrderNum"].Text);
}
//get ship by date from
current row
dtShipBy =
Convert.ToDateTime(row.Cells["OrderRel.ReqDate"].Text);
if
(DateTime.Compare(dtFromDate, dtShipBy) > 0)
{
//if
ship by date is earlier than dtFromDate then set dtFromDate accordingly
//back
up one extra day just to make sure
dtFromDate = dtShipBy.AddDays(-1);
}
else if
(DateTime.Compare(dtToDate, dtShipBy) < 0)
{
//if
ship by date is later than dtToDate then set dtToDate accordingly
//add
one extra day just to make sure
dtToDate
= dtShipBy.AddDays(1);
}
}
//build order number string
StringBuilder sb = new StringBuilder();
foreach (string orderNum in
lstOrderNums)
{
if (sb.Length > 0)
{
sb.Append("~");
}
sb.Append(orderNum);
}
//Set fields accordingly
//Some of these field are set because it was observed from
tracing that these
//values changed from default dataset
//
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["OrderList"] =
sb.ToString();
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["FromDate"] =
dtFromDate;
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ToDate"] =
dtToDate;
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AutoAction"] =
"Preview";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AgentID"] =
"SystemTaskAgent";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ReportStyleNum"
] = 2; //MATS Style
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["WorkstationID"]
= Environment.MachineName + " " + consoleSessionID.ToString();
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["DateFormat"] =
"mm/dd/yyyy";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["NumericFormat"]
= ",.";
//Send Pick List to System Agent for
printing
rptSOPickList.SubmitToAgent(rptDSSOPickList, "SystemTaskAgent", 0, 0,
"Epicor.Mfg.UIRpt.SOPickListReport");
MessageBox.Show("Pick List Print Job
Submitted.");
}
}
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of effgroups@...
Sent: Friday, March 04, 2011 12:42 PM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Accessing all selected rows in an grid
Hi Joe
That's a good piece of code to store when the need arises and I see
already a few uses for it.
But what do you do after that with the string? How do you print the
picking slips?
Ephraim Feldman
Programmer / Analyst
Axis Lighting
Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring
This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
-----Original Message-----
From: Joe Rojas <jrojas@... <mailto:jrojas%40matsinc.com> >
Sender: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Date: Fri, 4 Mar 2011 09:12:15
To: <vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> >
Reply-To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Subject: RE: [Vantage] Accessing all selected rows in an grid
I managed to find an answer on the Infragistics web site.
I thought I would share my solution in case anyone has a similar need.
I have a dashboard that lists open sales order releases.
I wanted the user to be able to select multiple releases and print the
associated Sales Order Pick List(s).
My code iterates through each select row and then builds a ~ delimited
list of unique sales order numbers.
Infragistics.Win.UltraWinGrid.SelectedRowsCollection selectedRows;
//Get reference to grid on grid view
EpiUltraGrid myGrid = (EpiUltraGrid)
csm.GetNativeControlReference("0bd59551-a244-41dc-86c1-d2c884c45fb4");
//Check to see if any rows are selected. If not, stop.
if (myGrid.Selected.Rows.Count < 1)
{
myGrid = null;
MessageBox.Show("Please select an order and then try
again.");
return;
}
//Iterate through selected rows and build order list
selectedRows = myGrid.Selected.Rows;
List<string> lstOrderNums = new List<string>();
for ( int i = 0; i < selectedRows.Count; i++ )
{
Infragistics.Win.UltraWinGrid.UltraGridRow row;
row = selectedRows[i];
//add the order number to the list if it doesn't already
exist
if
(!lstOrderNums.Contains(row.Cells["OrderHed.OrderNum"].Text))
{
lstOrderNums.Add(row.Cells["OrderHed.OrderNum"].Text);
}
}
//build order number string
StringBuilder sb = new StringBuilder();
foreach (string orderNum in lstOrderNums)
{
if (sb.Length > 0)
{
sb.Append("~");
}
sb.Append(orderNum);
}
From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
Of Joe Rojas
Sent: Wednesday, March 02, 2011 1:41 PM
To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Subject: [Vantage] Accessing all selected rows in an grid
Hello,
We are on E9.04.507A
I have a dashboard with a customization that lets me identify and read
the values in selected row of a grid view.
The grid allows me to select multiple lines.
Is there a way to access and iterate through all the selected line?
Thanks.
Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... <mailto:jrojas%40matsinc.com>
<mailto:jrojas%40matsinc.com> | www.matsinc.com Ask
us about our clean, green and beautiful matting and flooring
This message is intended only for the individual named. If you are not
the named addressee you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately by e-mail if you have
received this e-mail by mistake. Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of the company.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
I trimmed some of the code because I was just trying to show the part to
access the selected rows.
Here is my full code:
Add these lines to the "Custom Module Level Variables" section:
private static Process current = null;
private static System.IntPtr hProcess = default(System.IntPtr);
private static int consoleSessionID = 0;
[DllImport("Epicor.Mfg.Lib.GetConsoleSessionID.dll", CharSet =
CharSet.Auto)]
public static extern int getSession(IntPtr pHandle);
Add these lines to the InitializeCustomCode() section:
current = Process.GetCurrentProcess();
hProcess = current.Handle;
consoleSessionID = getSession(hProcess);
if ((consoleSessionID < 0))
{
consoleSessionID = 0;
}
Here is my function that I've attached to the Click event of a button on
my dashboard:
private static void btnPrintPickList_Click(object sender,
System.EventArgs args)
{
// ** Place Event Handling Code Here **
Infragistics.Win.UltraWinGrid.SelectedRowsCollection selectedRows;
Session epiSession;
epiSession = (Session) MainController.Session;
SOPickListReport rptSOPickList = new
SOPickListReport(epiSession.ConnectionPool);
SOPickListReportDataSet rptDSSOPickList =
rptSOPickList.GetNewParameters();
//Get reference to grid on grid view
EpiUltraGrid myGrid = (EpiUltraGrid)
csm.GetNativeControlReference("0bd59551-a244-41dc-86c1-d2c884c45fb4");
//Check to see if any rows are selected.
If not, stop.
if (myGrid.Selected.Rows.Count < 1)
{
myGrid = null;
rptDSSOPickList = null;
rptSOPickList = null;
epiSession = null;
MessageBox.Show("Please
select an order and then try again.");
return;
}
//Iterate through selected rows, build
order list and determine greatest shipby date
selectedRows = myGrid.Selected.Rows;
List<string> lstOrderNums = new List<string>();
DateTime dtFromDate = DateTime.Today;
DateTime dtToDate = DateTime.Today;
DateTime dtShipBy;
// Loop through all the selected rows
//
for ( int i = 0; i < selectedRows.Count; i++ )
{
Infragistics.Win.UltraWinGrid.UltraGridRow row;
row = selectedRows[i];
//add the order number
to the list if it isn't already
if
(!lstOrderNums.Contains(row.Cells["OrderHed.OrderNum"].Text))
{
lstOrderNums.Add(row.Cells["OrderHed.OrderNum"].Text);
}
//get ship by date from
current row
dtShipBy =
Convert.ToDateTime(row.Cells["OrderRel.ReqDate"].Text);
if
(DateTime.Compare(dtFromDate, dtShipBy) > 0)
{
//if
ship by date is earlier than dtFromDate then set dtFromDate accordingly
//back
up one extra day just to make sure
dtFromDate = dtShipBy.AddDays(-1);
}
else if
(DateTime.Compare(dtToDate, dtShipBy) < 0)
{
//if
ship by date is later than dtToDate then set dtToDate accordingly
//add
one extra day just to make sure
dtToDate
= dtShipBy.AddDays(1);
}
}
//build order number string
StringBuilder sb = new StringBuilder();
foreach (string orderNum in
lstOrderNums)
{
if (sb.Length > 0)
{
sb.Append("~");
}
sb.Append(orderNum);
}
//Set fields accordingly
//Some of these field are set because it was observed from
tracing that these
//values changed from default dataset
//
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["OrderList"] =
sb.ToString();
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["FromDate"] =
dtFromDate;
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ToDate"] =
dtToDate;
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AutoAction"] =
"Preview";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AgentID"] =
"SystemTaskAgent";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ReportStyleNum"
] = 2; //MATS Style
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["WorkstationID"]
= Environment.MachineName + " " + consoleSessionID.ToString();
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["DateFormat"] =
"mm/dd/yyyy";
rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["NumericFormat"]
= ",.";
//Send Pick List to System Agent for
printing
rptSOPickList.SubmitToAgent(rptDSSOPickList, "SystemTaskAgent", 0, 0,
"Epicor.Mfg.UIRpt.SOPickListReport");
MessageBox.Show("Pick List Print Job
Submitted.");
}
}
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of effgroups@...
Sent: Friday, March 04, 2011 12:42 PM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Accessing all selected rows in an grid
Hi Joe
That's a good piece of code to store when the need arises and I see
already a few uses for it.
But what do you do after that with the string? How do you print the
picking slips?
Ephraim Feldman
Programmer / Analyst
Axis Lighting
Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring
This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
-----Original Message-----
From: Joe Rojas <jrojas@... <mailto:jrojas%40matsinc.com> >
Sender: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Date: Fri, 4 Mar 2011 09:12:15
To: <vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> >
Reply-To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Subject: RE: [Vantage] Accessing all selected rows in an grid
I managed to find an answer on the Infragistics web site.
I thought I would share my solution in case anyone has a similar need.
I have a dashboard that lists open sales order releases.
I wanted the user to be able to select multiple releases and print the
associated Sales Order Pick List(s).
My code iterates through each select row and then builds a ~ delimited
list of unique sales order numbers.
Infragistics.Win.UltraWinGrid.SelectedRowsCollection selectedRows;
//Get reference to grid on grid view
EpiUltraGrid myGrid = (EpiUltraGrid)
csm.GetNativeControlReference("0bd59551-a244-41dc-86c1-d2c884c45fb4");
//Check to see if any rows are selected. If not, stop.
if (myGrid.Selected.Rows.Count < 1)
{
myGrid = null;
MessageBox.Show("Please select an order and then try
again.");
return;
}
//Iterate through selected rows and build order list
selectedRows = myGrid.Selected.Rows;
List<string> lstOrderNums = new List<string>();
for ( int i = 0; i < selectedRows.Count; i++ )
{
Infragistics.Win.UltraWinGrid.UltraGridRow row;
row = selectedRows[i];
//add the order number to the list if it doesn't already
exist
if
(!lstOrderNums.Contains(row.Cells["OrderHed.OrderNum"].Text))
{
lstOrderNums.Add(row.Cells["OrderHed.OrderNum"].Text);
}
}
//build order number string
StringBuilder sb = new StringBuilder();
foreach (string orderNum in lstOrderNums)
{
if (sb.Length > 0)
{
sb.Append("~");
}
sb.Append(orderNum);
}
From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
Of Joe Rojas
Sent: Wednesday, March 02, 2011 1:41 PM
To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
Subject: [Vantage] Accessing all selected rows in an grid
Hello,
We are on E9.04.507A
I have a dashboard with a customization that lets me identify and read
the values in selected row of a grid view.
The grid allows me to select multiple lines.
Is there a way to access and iterate through all the selected line?
Thanks.
Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... <mailto:jrojas%40matsinc.com>
<mailto:jrojas%40matsinc.com> | www.matsinc.com Ask
us about our clean, green and beautiful matting and flooring
This message is intended only for the individual named. If you are not
the named addressee you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately by e-mail if you have
received this e-mail by mistake. Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of the company.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]