you can customize and add your own print button and write your own BAQ to get data based on report data POForm:
BAQ:
select
[PODetail].[Company] as [PODetail_Company],
[PODetail].[PONUM] as [PODetail_PONUM],
[PODetail].[POLine] as [PODetail_POLine],
[PODetail].[LineDesc] as [PODetail_LineDesc],
[PODetail].[IUM] as [PODetail_IUM],
[PODetail].[OrderQty] as [PODetail_OrderQty],
[PODetail].[XOrderQty] as [PODetail_XOrderQty],
[PODetail].[UnitCost] as [PODetail_UnitCost],
[PODetail].[DocUnitCost] as [PODetail_DocUnitCost],
[PODetail].[PUM] as [PODetail_PUM],
[PORel].[PORelNum] as [PORel_PORelNum],
[PORel].[DueDate] as [PORel_DueDate],
[PORel].[XRelQty] as [PORel_XRelQty],
[PORel].[RelQty] as [PORel_RelQty],
[PORel].[Plant] as [PORel_Plant],
[PORel].[OrderRelNum] as [PORel_OrderRelNum],
[Company].[Name] as [Company_Name],
[Company].[Address1] as [Company_Address1],
[Company].[Address2] as [Company_Address2],
[Company].[Address3] as [Company_Address3],
[Company].[City] as [Company_City],
[Company].[Company] as [Company_Company],
[Company].[Country] as [Company_Country],
[Company].[PhoneNum] as [Company_PhoneNum],
[Company].[FaxNum] as [Company_FaxNum],
[Company].[StateTaxID] as [Company_StateTaxID],
[Company].[TaxRegionCode] as [Company_TaxRegionCode],
[Company].[TaxRegReason] as [Company_TaxRegReason],
[Company].[Character03] as [Company_Character03],
[PODetail].[CostPerCode] as [PODetail_CostPerCode],
[PODetail].[CommentText] as [PODetail_CommentText],
[PODetail].[DocInUnitCost] as [PODetail_DocInUnitCost],
[PODetail].[PartNum] as [PODetail_PartNum],
[PODetail].[VenPartNum] as [PODetail_VenPartNum],
[POHeader].[ApprovedBy] as [POHeader_ApprovedBy],
[POHeader].[ApprovedDate] as [POHeader_ApprovedDate],
[POHeader].[BuyerID] as [POHeader_BuyerID],
[POHeader].[CurrencyCode] as [POHeader_CurrencyCode],
[POHeader].[DocTotalMisc] as [POHeader_DocTotalMisc],
[POHeader].[DocTotalOrder] as [POHeader_DocTotalOrder],
[POHeader].[FOB] as [POHeader_FOB],
[POHeader].[TermsCode] as [POHeader_TermsCode],
[POHeader].[DocTotalTax] as [POHeader_DocTotalTax],
[POHeader].[OrderDate] as [POHeader_OrderDate],
[POHeader].[ShortChar04] as [POHeader_ShortChar04],
[VendorPP].[Name] as [VendorPP_Name],
[VendorPP].[Address1] as [VendorPP_Address1],
[VendorPP].[Address2] as [VendorPP_Address2],
[VendorPP].[Address3] as [VendorPP_Address3],
[VendorPP].[City] as [VendorPP_City],
[VendorPP].[Country] as [VendorPP_Country],
[PurAgent].[Name] as [PurAgent_Name],
[PurAgent].[EMailAddress] as [PurAgent_EMailAddress],
[Vendor].[PhoneNum] as [Vendor_PhoneNum],
[Vendor].[FaxNum] as [Vendor_FaxNum],
[FOB].[Description] as [FOB_Description],
[FOB].[DeliveryTerms] as [FOB_DeliveryTerms],
[PurTerms].[Description] as [PurTerms_Description],
[POHeader].[CommentText] as [POHeader_CommentText],
[POHeader].[ShipName] as [POHeader_ShipName],
[POHeader].[ShipAddress1] as [POHeader_ShipAddress1],
[POHeader].[ShipCity] as [POHeader_ShipCity],
[POHeader].[ShipCountry] as [POHeader_ShipCountry],
[Company].[Character02] as [Company_Character02],
[PODetail].[DueDate] as [PODetail_DueDate]
from Erp.PODetail as PODetail
inner join Erp.POHeader as POHeader on
PODetail.Company = POHeader.Company
and PODetail.PONUM = POHeader.PONum
inner join Erp.VendorPP as VendorPP on
POHeader.Company = VendorPP.Company
and POHeader.VendorNum = VendorPP.VendorNum
and POHeader.PurPoint = VendorPP.PurPoint
inner join Erp.Vendor as Vendor on
VendorPP.Company = Vendor.Company
and VendorPP.VendorNum = Vendor.VendorNum
inner join Erp.PurAgent as PurAgent on
POHeader.Company = PurAgent.Company
and POHeader.BuyerID = PurAgent.BuyerID
left outer join Erp.FOB as FOB on
POHeader.Company = FOB.Company
and POHeader.FOB = FOB.FOB
inner join Erp.PurTerms as PurTerms on
POHeader.Company = PurTerms.Company
and POHeader.TermsCode = PurTerms.TermsCode
inner join Erp.PORel as PORel on
PODetail.Company = PORel.Company
and PODetail.PONUM = PORel.PONum
and PODetail.POLine = PORel.POLine
inner join Erp.Company as Company on
Company.Company = PODetail.Company
where (PODetail.PONUM = @PONum)
here is the code to add the print button to the print menu:
// Add Custom Module Level Variables Here **
PopupMenuTool menuActionTool;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
menuActionTool = (PopupMenuTool)baseToolbarsManager.Tools["ActionsMenu"];//Chú ý GroupTool là name của menu Group debug hoặc dùng message show để lấy đc thông tin này
this.baseToolbarsManager.ShowToolTips = true;
this.baseToolbarsManager.ToolTipDisplayStyle = Infragistics.Win.UltraWinToolbars.ToolTipDisplayStyle.Formatted;
//bổ sung menu PrintPayment
ButtonTool PrintPaymentInv = new ButtonTool("PrintPaymentInv");
PrintPaymentInv.SharedProps.Caption = "**DMS - Print Payment Invoice"; // Sets the visible name
PrintPaymentInv.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText;
PrintPaymentInv.SharedProps.ToolTipText = "Sử dụng nút này để in đề nghị thanh toán theo hóa đơn";
//muốn biết Item name của Image vào đây xem: https://www.epiusers.help/t/i-want-to-know-the-item-name-from-the-resource-to-use-for-epiuiimages-getimage-itemname/87912/2
PrintPaymentInv.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.GetImage("SBPrint"); // Item name from the resource
baseToolbarsManager.Tools.Add(PrintPaymentInv);
menuActionTool.Tools.AddTool("PrintPaymentInv");
//bổ sung menu PrintPaymentGroup
ButtonTool PrintPaymentGrp = new ButtonTool("PrintPaymentGrp");
PrintPaymentGrp.SharedProps.Caption = "**DMS - Print Payment Group"; // Sets the visible name
PrintPaymentGrp.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText;
PrintPaymentGrp.SharedProps.ToolTipText = "Sử dụng nút này để in đề nghị thanh toán theo Group";
//muốn biết Item name của Image vào đây xem: https://www.epiusers.help/t/i-want-to-know-the-item-name-from-the-resource-to-use-for-epiuiimages-getimage-itemname/87912/2
PrintPaymentGrp.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.GetImage("SBPrint"); // Item name from the resource
baseToolbarsManager.Tools.Add(PrintPaymentGrp);
menuActionTool.Tools.AddTool("PrintPaymentGrp");
private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
switch (args.Tool.Key)
{
case "PrintPaymentInv":
PrintReport("PATC_PaymentRequest.rpt",0);
break;
case "PrintPaymentGrp":
PrintReport("PATC_PaymentRequest.rpt",1);
break;
}
}
here is the code in:
private void PrintReport(string reportfile, int PrintGrp)
{
try{
session= (Session)this.oTrans.Session;
//string invoicenum="";
string PathRoot=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
/* if(txtListInv.Text=="")
{
EpiDataView view = oTrans.EpiDataViews["InvcHead"] as EpiDataView;
invoicenum = view.dataView[view.Row]["InvoiceNum"].ToString()+"~";
}
else
{
invoicenum=txtListInv.Text.Replace(",","~")+"~";
} */
string Key_link11="";
string Key_link12="";
Key_link11=GetBAQUD05("SelectUD05","ReportData").Item2;
Key_link12=GetBAQUD05("SelectUD05","ReportDirectory").Item2;
//string [] Parameter ={invoicenum.Substring(0,invoicenum.Length-1)};
string Parameter=string.Empty, InvoiceNum=string.Empty;
DataRow CurrentInvoiceNumRow =null;
EpiDataView grdInvoiceList = (EpiDataView)(oTrans.EpiDataViews["InvListView"]);
if(grdInvoiceList.dataView.Count>0 && grdInvoiceList.CurrentDataRow != null)
{
CurrentInvoiceNumRow = grdInvoiceList.CurrentDataRow;
InvoiceNum = CurrentInvoiceNumRow["InvoiceNum"].ToString();//dùng cách này mới lấy đúng số InvoiceNum vì có code remove số 0 ở sự kiện textchange của InvoiceNum
Parameter = CurrentInvoiceNumRow["GroupID"].ToString();
}
DataTable tmpGrp = GetData("PaymentRequest",Parameter);
DataTable tmpInv = new DataTable();
if(PrintGrp!=1)
{
tmpInv = tmpGrp.AsEnumerable().Where(row=>row.Field<string>("LogAPInv_InvoiceNum") == InvoiceNum).CopyToDataTable();
/*IEnumerable<DataRow> query =from order in tmpGrp.AsEnumerable()
where order.Field<string>("LogAPInv_InvoiceNum")==InvoiceNum
select order;
tmpInv = query.CopyToDataTable<DataRow>();*/
tmpInv.TableName = "Results";//phải set lại tên TableName giống với hàm private DataTable GetData(string BAQID,string s) để mapping với report và có tên table mới ghi file XML đc
}
string strPat=@"\\"+session.AppServer.Split('/')[2].Split(':')[0];
string PathXml=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\PaymentRequest.XML";
string PathDesRpt=Key_link11+"\\"+((Session)this.oTrans.Session).UserID+"\\" +reportfile;
string PathRpt=Key_link12+"\\"+reportfile;
File.Copy(PathRpt,PathDesRpt);
if(PrintGrp==1)//in theo Group
tmpGrp.WriteXml(PathXml,XmlWriteMode.WriteSchema);
else//in theo Inv
tmpInv.WriteXml(PathXml,XmlWriteMode.WriteSchema);
Ice.Lib.Report.EpiCrystalViewer report = new Ice.Lib.Report.EpiCrystalViewer(PathDesRpt, PathXml,"Payment Request");
report.ShowDialog();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
DMS_GetPOPrintSendMaill.baq (44.7 KB)

Thank you have a nice day!
