/// <summary> /// Thachnn: 28/10/2005 /// Preview the report for this form /// Using the "InventoryDetailReport.xml" layout /// </summary> /// <history>Thachnn: 29/12/2005: Add parameter display to the report. Change USECASE.</history> /// <param name="sender"></param> /// <param name="e"></param> public DataTable ExecuteReport(string pstrCCNID, string pstrMasterLocationID, string pstrLocationID, string pstrBinID, string pstrCategoryID, string pstrParameterModel) { #region Constants string mstrReportDefFolder = mstrReportDefinitionFolder; const string REPORT_LAYOUT_FILE = "InventoryDetailReport.xml"; const string TABLE_NAME = "InventoryDetailReport"; const string REPORT_NAME = "Inventory Detail"; const string PAGE = "Page"; const string HEADER = "Header"; const string REPORTFLD_TITLE = "fldTitle"; const string REPORTFLD_COMPANY = "fldCompany"; const string REPORTFLD_ADDRESS = "fldAddress"; const string REPORTFLD_TEL = "fldTel"; const string REPORTFLD_FAX = "fldFax"; const string REPORTFLD_DATETIME = "fldDateTime"; #endregion #region GETTING THE PARAMETER PCSComUtils.Common.BO.UtilsBO boUtil = new PCSComUtils.Common.BO.UtilsBO(); PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO objBO = new PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO(); string strCCN = boUtil.GetCCNCodeFromID(int.Parse(pstrCCNID)); string strMasterLocation = objBO.GetMasterLocationCodeFromID(int.Parse(pstrMasterLocationID)) + ": " + objBO.GetMasterLocationNameFromID(int.Parse(pstrMasterLocationID)); string strLocation = string.Empty; try { strLocation = objBO.GetLocationCodeFromID(int.Parse(pstrLocationID)); } catch {} string strBin = string.Empty; try { strBin = objBO.GetBinCodeFromID(int.Parse(pstrBinID)); } catch {} string strCategory = string.Empty; try { strCategory = objBO.GetCategoryCodeFromID(int.Parse(pstrCategoryID)); } catch {} #endregion float fActualPageSize = 9000f; #region Build dtbResult DataTable DataTable dtbResult; try { dtbResult = GetInventoryDetailData(pstrCCNID, pstrMasterLocationID, pstrLocationID, pstrBinID, pstrCategoryID, pstrParameterModel); } catch { dtbResult = new DataTable(); } #endregion ReportBuilder objRB; objRB = new ReportBuilder(); objRB.ReportName = REPORT_NAME; objRB.SourceDataTable = dtbResult; #region INIT REPORT BUIDER OBJECT try { objRB.ReportDefinitionFolder = mstrReportDefinitionFolder; objRB.ReportLayoutFile = REPORT_LAYOUT_FILE; if (objRB.AnalyseLayoutFile() == false) { // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND, MessageBoxIcon.Error); return(new DataTable()); } //objRB.UseLayoutFile = objRB.AnalyseLayoutFile(); // use layout file if any , auto drawing if not found layout file objRB.UseLayoutFile = true; // always use layout file } catch { objRB.UseLayoutFile = false; // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND,MessageBoxIcon.Error); } C1.C1Report.Layout objLayout = objRB.Report.Layout; fActualPageSize = objLayout.PageSize.Width - (float)objLayout.MarginLeft - (float)objLayout.MarginRight; #endregion objRB.MakeDataTableForRender(); //grid.DataSource = objRB.RenderDataTable; #region RENDER TO PRINT PREVIEW // and show it in preview dialog PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog printPreview = new PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog(); printPreview.FormTitle = REPORT_NAME; objRB.ReportViewer = printPreview.ReportViewer; objRB.RenderReport(); #region COMPANY INFO header information get from system params // try // { // objRB.DrawPredefinedField(REPORTFLD_COMPANY,SystemProperty.SytemParams.Get(SystemParam.COMPANY_NAME)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_ADDRESS,SystemProperty.SytemParams.Get(SystemParam.ADDRESS)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_TEL,SystemProperty.SytemParams.Get(SystemParam.TEL)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_FAX,SystemProperty.SytemParams.Get(SystemParam.FAX)); // } // catch{} #endregion #region DRAW Parameters const string CCN = "CCN"; const string MASTER_LOCATION = "Master Location"; const string LOCATION = "Location"; const string BIN = "Bin"; const string CATEGORY = "Category"; const string MODEL = "Model"; System.Collections.Specialized.NameValueCollection arrParamAndValue = new System.Collections.Specialized.NameValueCollection(); arrParamAndValue.Add(CCN, strCCN); arrParamAndValue.Add(MASTER_LOCATION, strMasterLocation); if (pstrLocationID.Trim() != string.Empty) { arrParamAndValue.Add(LOCATION, strLocation); } if (pstrBinID.Trim() != string.Empty) { arrParamAndValue.Add(BIN, strBin); } if (pstrCategoryID.Trim() != string.Empty) { arrParamAndValue.Add(CATEGORY, strCategory); } if (pstrParameterModel.Trim() != string.Empty) { arrParamAndValue.Add(MODEL, pstrParameterModel); } /// anchor the Parameter drawing canvas cordinate to the fldTitle C1.C1Report.Field fldTitle = objRB.GetFieldByName(REPORTFLD_TITLE); double dblStartX = fldTitle.Left; double dblStartY = fldTitle.Top + 1.3 * fldTitle.RenderHeight; objRB.GetSectionByName(PAGE + HEADER).CanGrow = true; objRB.DrawParameters(objRB.GetSectionByName(PAGE + HEADER), dblStartX, dblStartY, arrParamAndValue, objRB.Report.Font.Size); #endregion /// there are some hardcode numbers here /// but these numbers are use ONLY ONE and ONLY USED HERE, so we don't need to define constant for it. objRB.DrawBoxGroup_Madeby_Checkedby_Approvedby(objRB.GetSectionByName(PAGE + HEADER), 15945 - 1400 - 1400 - 1400, 600, 1400, 1300, 200); #region DAY--MONTH--YEAR INFO DateTime dtm; try { dtm = objUtilBO.GetDBDate(); } catch { dtm = DateTime.Now; } try { objRB.DrawPredefinedField(REPORTFLD_DATETIME, dtm.ToString("dd-MM-yyyy hh:mm")); } catch {} #endregion objRB.RefreshReport(); printPreview.Show(); #endregion UseReportViewerRenderEngine = false; mResult = dtbResult; return(dtbResult); }
/// <summary> /// Thachnn: 28/10/2005 /// Preview the report for this form /// Using the "InventoryStatusSummaryByMasterLocationReport.xml" layout /// </summary> /// <history>Thachnn: 29/12/2005: Add parameter display to the report. Change USECASE.</history> /// <param name="sender"></param> /// <param name="e"></param> public DataTable ExecuteReport(string pstrCCNID, string pstrMasterLocationID, string pstrCategoryID, string pstrParameterModel) { #region Constants string mstrReportDefFolder = mstrReportDefinitionFolder; const string REPORT_LAYOUT_FILE = "InventoryStatusSummaryByMasterLocationReport.xml"; const string TABLE_NAME = "InventoryStatusSummaryByMasterLocationReport"; const string REPORT_NAME = "Inventory Status Summary By Master Location"; const string PAGE = "Page"; const string HEADER = "Header"; const string REPORTFLD_TITLE = "fldTitle"; const string REPORTFLD_COMPANY = "fldCompany"; const string REPORTFLD_ADDRESS = "fldAddress"; const string REPORTFLD_TEL = "fldTel"; const string REPORTFLD_FAX = "fldFax"; const string REPORTFLD_DAY = "fldDay"; const string REPORTFLD_MONTH = "fldMonth"; const string REPORTFLD_YEAR = "fldYear"; const string REPORTFLD_CATEGORY = "fldCategory"; const string REPORTFLD_PARTNUMBER = "fldPartNumber"; const string REPORTFLD_PARTNAME = "fldPartName"; const string REPORTFLD_MODEL = "fldModel"; const string REPORTFLD_STOCKUM = "fldStockUM"; const string REPORTFLD_LOCATION = "fldLocation"; const string REPORTFLD_OHQTY = "fldOHQty"; const string REPORTFLD_COMMITQTY = "fldCommitQty"; const string REPORTFLD_AVAILABLEQTY = "fldAvailableQty"; const string REPORTFLD_TYPE = "fldType"; const string REPORTFLD_SOURCE = "fldSource"; const string REPORTFLD_SAFETYSTOCK = "fldSafetyStock"; const string REPORTFLD_LOT = "fldLot"; const string REPORTFLD_WARNING = "fldWarning"; #region QUERY COLUMMS const string CATEGORY_COL = "[Category]"; const string PARTNUMBER_COL = "[Part No.]"; const string PARTNAME_COL = "[Part Name]"; const string MODEL_COL = "[Model]"; const string STOCKUM_COL = "[Stock UM]"; const string LOCATION_COL = "[Location]"; const string OHQTY_COL = "[OH Qty]"; const string COMMITQTY_COL = "[Commit Qty]"; const string AVAILABLEQTY_COL = "[Available Qty]"; const string TYPE_COL = "[Type]"; const string SOURCE_COL = "[Source]"; const string SAFETYSTOCK_COL = "[Safety Stock]"; const string LOT_COL = "[Lot]"; const string WARNING_COL = "[Warning]"; #endregion #endregion #region GETTING THE PARAMETER PCSComUtils.Common.BO.UtilsBO boUtil = new PCSComUtils.Common.BO.UtilsBO(); PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO objBO = new PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO(); string strCCN = boUtil.GetCCNCodeFromID(int.Parse(pstrCCNID)); string strMasterLocation = objBO.GetMasterLocationCodeFromID(int.Parse(pstrMasterLocationID)) + ": " + objBO.GetMasterLocationNameFromID(int.Parse(pstrMasterLocationID)); string strCategory = string.Empty; try { strCategory = objBO.GetCategoryCodeFromID(pstrCategoryID); } catch {} #endregion float fActualPageSize = 9000f; #region Build dtbResult DataTable DataTable dtbResult; try { dtbResult = GetInventoryStatusData(pstrCCNID, pstrMasterLocationID, pstrCategoryID, pstrParameterModel); } catch { dtbResult = new DataTable(); } #endregion ReportBuilder objRB; objRB = new ReportBuilder(); objRB.ReportName = REPORT_NAME; objRB.SourceDataTable = dtbResult; #region INIT REPORT BUIDER OBJECT try { objRB.ReportDefinitionFolder = mstrReportDefinitionFolder; objRB.ReportLayoutFile = REPORT_LAYOUT_FILE; if (objRB.AnalyseLayoutFile() == false) { // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND, MessageBoxIcon.Error); return(new DataTable()); } //objRB.UseLayoutFile = objRB.AnalyseLayoutFile(); // use layout file if any , auto drawing if not found layout file objRB.UseLayoutFile = true; // always use layout file } catch { objRB.UseLayoutFile = false; // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND,MessageBoxIcon.Error); } C1.C1Report.Layout objLayout = objRB.Report.Layout; fActualPageSize = objLayout.PageSize.Width - (float)objLayout.MarginLeft - (float)objLayout.MarginRight; #endregion objRB.MakeDataTableForRender(); //grid.DataSource = objRB.RenderDataTable; #region RENDER TO PRINT PREVIEW // and show it in preview dialog PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog printPreview = new PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog(); printPreview.FormTitle = REPORT_NAME; objRB.ReportViewer = printPreview.ReportViewer; objRB.RenderReport(); #region COMPANY INFO header information get from system params // try // { // objRB.DrawPredefinedField(REPORTFLD_COMPANY,SystemProperty.SytemParams.Get(SystemParam.COMPANY_NAME)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_ADDRESS,SystemProperty.SytemParams.Get(SystemParam.ADDRESS)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_TEL,SystemProperty.SytemParams.Get(SystemParam.TEL)); // } // catch{} // try // { // objRB.DrawPredefinedField(REPORTFLD_FAX,SystemProperty.SytemParams.Get(SystemParam.FAX)); // } // catch{} #endregion #region DRAW Parameters const string CCN = "CCN"; const string MASTER_LOCATION = "Master Location"; const string LOCATION = "Location"; const string CATEGORY = "Category"; const string MODEL = "Model"; System.Collections.Specialized.NameValueCollection arrParamAndValue = new System.Collections.Specialized.NameValueCollection(); arrParamAndValue.Add(CCN, strCCN); arrParamAndValue.Add(MASTER_LOCATION, strMasterLocation); if (pstrCategoryID.Trim() != string.Empty) { arrParamAndValue.Add(CATEGORY, strCategory); } if (pstrParameterModel.Trim() != string.Empty) { arrParamAndValue.Add(MODEL, pstrParameterModel); } /// anchor the Parameter drawing canvas cordinate to the fldTitle C1.C1Report.Field fldTitle = objRB.GetFieldByName(REPORTFLD_TITLE); double dblStartX = fldTitle.Left; double dblStartY = fldTitle.Top + 1.3 * fldTitle.RenderHeight; objRB.GetSectionByName(PAGE + HEADER).CanGrow = true; objRB.DrawParameters(objRB.GetSectionByName(PAGE + HEADER), dblStartX, dblStartY, arrParamAndValue, objRB.Report.Font.Size); #endregion /// there are some hardcode numbers here /// but these numbers are use ONLY ONE and ONLY USED HERE, so we don't need to define constant for it. objRB.DrawBoxGroup_Madeby_Checkedby_Approvedby(objRB.GetSectionByName(PAGE + HEADER), 16005 - 1400 - 1400 - 1400, 600, 1400, 1300, 200); #region DAY--MONTH--YEAR INFO DateTime dtm; try { dtm = objUtilBO.GetDBDate(); } catch { dtm = DateTime.Now; } try { objRB.DrawPredefinedField(REPORTFLD_DAY, dtm.Day.ToString("00")); } catch {} try { objRB.DrawPredefinedField(REPORTFLD_MONTH, dtm.Month.ToString("00")); } catch {} try { objRB.DrawPredefinedField(REPORTFLD_YEAR, dtm.Year.ToString("0000")); } catch {} #endregion try // mapping report field with table column { objRB.DrawPredefinedField(REPORTFLD_CATEGORY, CATEGORY_COL); objRB.DrawPredefinedField(REPORTFLD_PARTNUMBER, PARTNUMBER_COL); objRB.DrawPredefinedField(REPORTFLD_PARTNAME, PARTNAME_COL); objRB.DrawPredefinedField(REPORTFLD_MODEL, MODEL_COL); objRB.DrawPredefinedField(REPORTFLD_STOCKUM, STOCKUM_COL); objRB.DrawPredefinedField(REPORTFLD_LOCATION, LOCATION_COL); objRB.DrawPredefinedField(REPORTFLD_OHQTY, OHQTY_COL); objRB.DrawPredefinedField(REPORTFLD_COMMITQTY, COMMITQTY_COL); objRB.DrawPredefinedField(REPORTFLD_AVAILABLEQTY, AVAILABLEQTY_COL); objRB.DrawPredefinedField(REPORTFLD_TYPE, TYPE_COL); objRB.DrawPredefinedField(REPORTFLD_SOURCE, SOURCE_COL); objRB.DrawPredefinedField(REPORTFLD_SAFETYSTOCK, SAFETYSTOCK_COL); objRB.DrawPredefinedField(REPORTFLD_LOT, LOT_COL); objRB.DrawPredefinedField(REPORTFLD_WARNING, WARNING_COL); } catch {} objRB.RefreshReport(); printPreview.Show(); #endregion UseReportViewerRenderEngine = false; mResult = dtbResult; return(dtbResult); }
/// <summary> /// Main function, generate the result data Table for the REPORT VIEWER /// Modify the REPORT VIEWER to display the report /// ------------------------------ MAIN FLOW OF THIS REPORT ---------------------------------- /// BUILD THE PO LIST TABLE /// /// GETTING RAW DATA USING DataHelper Class /// FILL TO THE DTB TABLE /// /// RENDER TO REPORT /// /// SHOW THE REPORT /// END -------------------------- MAIN FLOW OF THIS REPORT ---------------------------------- /// </summary> /// <param name="pstrYear"></param> /// <param name="pstrMonth"></param> /// <param name="pstrPPMDefault"></param> /// <param name="pstrPPMDefault">Base Item</param> /// <returns></returns> public DataTable ExecuteReport(string pstrCCNID, string pstrPurchaseOrderID_LIST, string pstrPartyID_LIST, string pstrProductID_LIST) { #region My variables /// Report layout file constant const string REPORT_LAYOUT_FILE = "PurchaseOrderManagementReport.xml"; const string REPORT_NAME = "PurchaseOrderManagementReport"; short COPIES = 1; /// all parameter are Mandatory const string REPORTFLD_PARAMETER_CCN = "lblCCN"; const string REPORTFLD_PARAMETER_PURCHASEORDER = "lblPurchaseOrder"; const string REPORTFLD_PARAMETER_MAKER = "lblMaker"; const string REPORTFLD_PARAMETER_PRODUCT = "lblProduct"; PurchaseOrderManagementReport.pnCCNID = int.Parse(pstrCCNID); PurchaseOrderManagementReport.pstrPurchaseOrderID_LIST = pstrPurchaseOrderID_LIST; PurchaseOrderManagementReport.pstrPartyID_LIST = pstrPartyID_LIST; PurchaseOrderManagementReport.pstrProductID_LIST = pstrProductID_LIST; string strCCN = string.Empty; string strPurchaseOrderLIST = string.Empty; string strPartyLIST = string.Empty; string strProductLIST = string.Empty; const string REPORTFLD_TITLE = "fldTitle"; float fActualPageSize = 9000.0f; /// custom object to access and modify the dtbPurchaseOrderList PLReportDataHelper objPLTable = new PLReportDataHelper(); #endregion /// ------------------------------ MAIN FLOW OF THIS REPORT ---------------------------------- /// ##1## BUILD THE PRODUCTION LINE LIST TABLE #region BUILD some RAW DATA TABLE and Array objPLTable.GetDataAndCache(); #endregion BUILD some RAW DATA TABLE #region GETTING THE PARAMETER PCSComUtils.Common.BO.UtilsBO boUtil = new PCSComUtils.Common.BO.UtilsBO(); PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO objBO = new PCSComUtils.Framework.ReportFrame.BO.C1PrintPreviewDialogBO(); strCCN = boUtil.GetCCNCodeFromID(PurchaseOrderManagementReport.pnCCNID); strPurchaseOrderLIST = GetListFromDataTable(objPLTable.GetDataTable(1)); strPartyLIST = GetListFromDataTable(objPLTable.GetDataTable(2)); strProductLIST = GetListFromDataTable(objPLTable.GetDataTable(3)); #endregion #region BUILD DATA OF REPORT #endregion BUILD DATA OF REPORT /// #### RENDER TO REPORT #region RENDER REPORT ReportBuilder objRB = mReportBuilder; objRB.ReportName = REPORT_NAME; objRB.SourceDataTable = objPLTable.PurchaseOrderList; // we build report base on HashTable, not DataTable, so we put new empty DataTable in to ReportBuilder to avoid error of outside processing //return objPLTable.PurchaseOrderList; #region INIT REPORT BUIDER OBJECT try { objRB.ReportDefinitionFolder = mstrReportDefinitionFolder; objRB.ReportLayoutFile = REPORT_LAYOUT_FILE; if (objRB.AnalyseLayoutFile() == false) { // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND, MessageBoxIcon.Error); return(new DataTable()); } //objRB.UseLayoutFile = objRB.AnalyseLayoutFile(); // use layout file if any , auto drawing if not found layout file objRB.UseLayoutFile = true; // always use layout file } catch { objRB.UseLayoutFile = false; // PCSMessageBox.Show(ErrorCode.MESSAGE_REPORT_TEMPLATE_FILE_NOT_FOUND,MessageBoxIcon.Error); } C1.C1Report.Layout objLayout = objRB.Report.Layout; fActualPageSize = objLayout.PageSize.Width - (float)objLayout.MarginLeft - (float)objLayout.MarginRight; #endregion objRB.MakeDataTableForRender(); // and show it in preview dialog PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog printPreview = new PCSUtils.Framework.ReportFrame.C1PrintPreviewDialog(); printPreview.FormTitle = REPORT_NAME; objRB.ReportViewer = printPreview.ReportViewer; objRB.RenderReport(); #region MODIFY THE REPORT LAYOUT #region DRAW Parameters const int MAX_PARA_LENGTH_TO_SHOW = 150; System.Collections.Specialized.NameValueCollection arrParamAndValue = new System.Collections.Specialized.NameValueCollection(); arrParamAndValue.Add(objRB.GetFieldByName(REPORTFLD_PARAMETER_CCN).Text, strCCN); if (strPurchaseOrderLIST.Length > 100) { strPurchaseOrderLIST = strPurchaseOrderLIST.Substring(0, MAX_PARA_LENGTH_TO_SHOW) + " ..."; } if (strPartyLIST.Length > 100) { strPartyLIST = strPartyLIST.Substring(0, MAX_PARA_LENGTH_TO_SHOW) + " ..."; } if (strProductLIST.Length > 100) { strProductLIST = strProductLIST.Substring(0, MAX_PARA_LENGTH_TO_SHOW) + " ..."; } if (pstrPurchaseOrderID_LIST != string.Empty) { arrParamAndValue.Add(objRB.GetFieldByName(REPORTFLD_PARAMETER_PURCHASEORDER).Text, strPurchaseOrderLIST); } if (pstrPartyID_LIST != string.Empty) { arrParamAndValue.Add(objRB.GetFieldByName(REPORTFLD_PARAMETER_MAKER).Text, strPartyLIST); } if (pstrProductID_LIST != string.Empty) { arrParamAndValue.Add(objRB.GetFieldByName(REPORTFLD_PARAMETER_PRODUCT).Text, strProductLIST); } /// anchor the Parameter drawing canvas cordinate to the fldTitle C1.C1Report.Field fldTitle = objRB.GetFieldByName(REPORTFLD_TITLE); double dblStartX = fldTitle.Left; double dblStartY = fldTitle.Top + 1.3 * fldTitle.RenderHeight; objRB.GetSectionByName(PAGE + HEADER).CanGrow = true; objRB.DrawParameters(objRB.GetSectionByName(PAGE + HEADER), dblStartX, dblStartY, arrParamAndValue, objRB.Report.Font.Size); #endregion #endregion // ReportBuilder.ReformatNumberInC1Report(objRB.Report); objRB.MarkRedToNegativeNumberField(); objRB.RefreshReport(); /// #### SHOW THE REPORT /// force the copies number printPreview.FormTitle = objRB.GetFieldByName(FLD + TITLE).Text; printPreview.Show(); #endregion /// END ----------------------- MAIN FLOW OF THIS REPORT ---------------------------------- UseReportViewerRenderEngine = false; mResult = objPLTable.PurchaseOrderList; return(objPLTable.PurchaseOrderList); }