Can anyone help me create a button on our Job Entry screen that will Print Preview the associated Sales Order? Our Engineering department prints out a copy of the Sales Order Acknowledgement for our shop, but we want to try to avoid them having to open the Sales Order just to do a print preview and then print. Any help is greatly appreciated!
How comfortable are you at making customizations?
The following will point you in the right direction.
You can also use the salesOrderAckAdapter and pull the order number off the JobProd data view. Seems like most boxed reports have an adapter that works the same way, I tweaked some code I had for the JobTravAdapter. I used the wizards to create a button click event and EpiDataView reference, then referenced Erp.Contracts.Rpt.SalesOrderAck , Erp.UIRpt.SalesOrderAck , and Ice.Core.Session via the custom assembly reference manager.
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvJobProd = ((EpiDataView)(this.oTrans.EpiDataViews["JobProd"]));
this.edvJobProd.EpiViewNotification += new EpiViewNotification(this.edvJobProd_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonSOA.Click += new System.EventHandler(this.epiButtonSOA_Click);
// End Wizard Added Custom Method Calls
}
private void epiButtonSOA_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
//Invoke the BO
salesOrderAckAdapter soaAdapter = new salesOrderAckAdapter(oTrans);
soaAdapter.BOConnect();
//Get Paramters
soaAdapter.GetNewParameters();
//Set Parameters
soaAdapter.ReportData.SalesOrderAckParam[0].OrderNum = Int32.Parse(this.edvJobProd.dataView[0]["OrderNum"].ToString());
soaAdapter.ReportData.SalesOrderAckParam[0].AutoAction = "SSRSPreview";
soaAdapter.ReportData.SalesOrderAckParam[0].AgentID = "Main";
soaAdapter.ReportData.SalesOrderAckParam[0].WorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Ice.Core.Session)oTrans.Session);
soaAdapter.ReportData.SalesOrderAckParam[0].ArchiveCode = 1;
soaAdapter.ReportData.SalesOrderAckParam[0].SSRSRenderFormat = "PDF";
soaAdapter.ReportData.SalesOrderAckParam[0].ReportCurrencyCode = "USD";
soaAdapter.ReportData.SalesOrderAckParam[0].ReportCultureCode = "en-US";
soaAdapter.ReportData.SalesOrderAckParam[0].DateFormat = "m/d/yyyy";
soaAdapter.ReportData.SalesOrderAckParam[0].NumericFormat = ",.";
soaAdapter.ReportData.SalesOrderAckParam[0].SSRSEnableRouting = false;
soaAdapter.ReportData.SalesOrderAckParam[0].RecurringTask = false;
soaAdapter.ReportData.SalesOrderAckParam[0].PrintReportParameters = false;
soaAdapter.SubmitToAgent("Main",0,0);
}
private void edvJobProd_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** 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))
{
if ((args.Row > -1))
{
this.epiButtonSOA.ReadOnly = false;
}
else
{
this.epiButtonSOA.ReadOnly = true;
}
}
}
Alot of the parameters aren’t needed.
If I replicate what you posted, that will provide me a button with the ability to Print Preview the Sales Order directly from the Job Entry screen?
Yes it should. I used several of the wizards to generate most of the code, the only thing you would need to paste in is whats in the epiButtonSOA_Click event (after generating the click event with the wizard). I’ll post some snips here shortly.
Add references:
Create button with toolbox (i renamed my button epiButtonSOA):
Add epiViewNotification for JobProd table (this will generate code for the dataView we pull the order number off).
Create click event for newly made button:
Paste in code above post (in click event) to newly generated click event:
Using the epiViewNotification, you can enable/disable the button whenever a job is loaded/ not loaded. You’ll need to change the notification type to initialize. I also added a check to see if there’s actually a make to order demand link tied to the job, otherwise it will stay disabled (the check isn’t in the above code).
you’ll add the following code to the epiViewNotification:
if ((args.Row > -1) && Int32.Parse(view.dataView[0]["OrderNum"].ToString()) > 0)
{
this.epiButtonSOA.ReadOnly = false;
}
else
{
this.epiButtonSOA.ReadOnly = true;
}
After all that you should have a working button: