Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }