Example #1
0
        /// <summary>
        /// Prints the preview report.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="reportId">The s report identifier.</param>
        /// <param name="isPint">if set to <c>true</c> [is pint].</param>
        public void PrintPreviewReport(XtraForm frmParent, string reportId, bool isPint)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                _reportListModel = ReportLists.Find(item => item.ReportID == reportId);
                if (_reportListModel == null)
                {
                    return;
                }
                _frmParentForm = frmParent;
                var reportListSource = GetDataSource(frmParent, _reportListModel);
                if (reportListSource == null)
                {
                    return;
                }
                if (reportListSource.Count <= 0)
                {
                    XtraMessageBox.Show("Dữ liệu lấy lên báo cáo Không có bản ghi nào.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (!string.IsNullOrEmpty(_reportListModel.TableName))
                {
                    DataMember = _reportListModel.TableName.Trim();
                }
                DisplayReport(ref reportListSource, _reportListModel, false, frmParent, false, isPint, DateTime.MinValue);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
        /// <summary>
        /// Prints the preview report by report.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="param">The e parameter.</param>
        /// <param name="isPrint">if set to <c>true</c> [is print].</param>
        public void PrintPreviewReportByReport(XtraForm frmParent, DrilldownReportParam param, bool isPrint)
        {
            try
            {
                Cursor.Current   = Cursors.WaitCursor;
                _reportListModel = ReportLists.Find(item => item.ReportID == param.ArgParameter[0].ToString());
                if (_reportListModel == null)
                {
                    return;
                }
                _frmParentForm = frmParent;

                var reportListSource = GetDrillDownDataSource(frmParent, _reportListModel, param.ArgParameter);
                if (reportListSource == null || reportListSource.Count <= 0)
                {
                    return;
                }
                if (reportListSource.Count > 0)
                {
                    if (!string.IsNullOrEmpty(_reportListModel.TableName))
                    {
                        DataMember = _reportListModel.TableName.Trim();
                    }
                    DisplayReport(ref reportListSource, _reportListModel, false, frmParent, false, isPrint, DateTime.MinValue);
                }
                else
                {
                    XtraMessageBox.Show("Không có bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
        public void PrintPreviewReport(XtraForm frmParent, string reportID, bool isPint)
        {
            try
            {
                List <ReportListModel> reportList       = _reportListPresenter.GetAllReportList();
                ReportListModel        _reportListModel = reportList.Find(item => item.ReportID == reportID);
                if (_reportListModel == null)
                {
                    return;
                }
                //  var reportListSource = GetDataSource(frmParent, _reportListModel);
                List <C30BBModel> lstC30BB = new List <C30BBModel>();
                for (int i = 0; i < gridViewDetail.RowCount; i++)
                {
                    var rowData = (C30BBModel)gridViewDetail.GetRow(i);
                    lstC30BB.Add(rowData);
                }
                if (lstC30BB.Count <= 0)
                {
                    XtraMessageBox.Show("Dữ liệu lấy lên báo cáo Không có bản ghi nào.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                var reportHelper = new ReportHelper();

                // reportHelper.DisplayReport(ref lstC30BB, _reportListModel, false, frmParent, false, false, DateTime.MinValue);
                //        DisplayReport(ref reportListSource, _reportListModel, false, frmParent, false, isPint, DateTime.MinValue);
                // DisplayReport(lstC30BB, _reportListModel, false, frmParent, false, isPint, DateTime.MinValue);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #4
0
        /// <summary>
        /// Gets the data source.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="reportList">The report list.</param>
        /// <returns></returns>
        private ICollection GetDataSource(XtraForm frmParent, ReportListModel reportList)
        {
            IList dataSource = null;

            try
            {
                if (!string.IsNullOrEmpty(reportList.InputTypeName))
                {
                    var type   = Assembly.GetExecutingAssembly().GetType((GetType().Namespace + "." + reportList.InputTypeName));
                    var target = (BaseReport)Activator.CreateInstance(type);
                    if (!string.IsNullOrEmpty(reportList.ProcedureName))
                    {
                        if (CommonVariable == null)
                        {
                            CommonVariable = new GlobalVariable();
                        }
                        CommonVariable.StoreProcedureName = reportList.ProcedureName;
                        CommonVariable.ReportList         = reportList;
                        CommonVariable.IsDrillDownReport  = false;
                        var args = new object[] { frmParent, CommonVariable, _rsTool };
                        dataSource = (IList)(type.InvokeMember(reportList.FunctionReportName, BindingFlags.InvokeMethod, null, target, args));
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(dataSource);
        }
Example #5
0
        private ReportListModel GetReportList(IEnumerable <AppReport> rptDataList, int tileID = 0)
        {
            string          userAlias = Session["UserName"] == null ? "" : Session["UserName"].ToString();
            ReportListModel rptList   = new ReportListModel();

            foreach (AppReport data in rptDataList)
            {
                ReportItem item = new ReportItem();
                item.ID         = data.Id.GetValueOrDefault();
                item.ReportName = data.Title;

                item.ReprotStatus      = data.Status.Name;
                item.ReportDescription = data.Description;
                item.ReportFeaturePics = data.Images;
                item.ReportOwners      = data.Owners;
                item.ReportTags        = data.Tags;
                item.ReprotContent     = data.Content;
                item.ReportCategory    = data.Categories.Where(_ => _.ParentId != null).Select(_ => new AppCategory()
                {
                    CategoryName = _.CategoryName, Id = _.Id
                }).ToList <AppCategory>();
                bool IsOwner = data.Owners.Any(u => string.Compare(u.UserName, userAlias, true) == 0);

                // if current user is site admin or data owner
                if (userAlias != "")
                {
                    if (IsOwner || service.GetUserAdminTeams(userAlias).Count() > 0)
                    {
                        item.Editable = true;
                    }
                }
                else
                {
                    item.Editable = false;
                }


                if (tileID == SystemDefinedTile.MyReports_Recommended.SystemDefinedTileId)
                {
                    //foreach (var rec in data.Recommendations)
                    //{
                    //    ReportRecommendViewModel recViewModel = new ReportRecommendViewModel();
                    //    recViewModel.UserName = rec.Recommender.DisplayName;
                    //    recViewModel.Comment = rec.Comment;

                    //    item.RecommendList.Add(recViewModel);
                    //}
                }

                //GetOpenSetting(ref item, data);

                rptList.ReportItemList.Add(item);
            }

            return(rptList);
        }
Example #6
0
        /// <summary>
        /// Displays the report.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="reportList">The report list.</param>
        /// <param name="isVoucher">if set to <c>true</c> [b is voucher].</param>
        /// <param name="frmForm">The   form.</param>
        /// <param name="isShowDialog">if set to <c>true</c> [b show dialog].</param>
        /// <param name="isPrint">if set to <c>true</c> [is print].</param>
        /// <param name="voucherDate">The d voucher date.</param>
        public void DisplayReport(ref ICollection dataSource, ReportListModel reportList, bool isVoucher, XtraForm frmForm, bool isShowDialog, bool isPrint, DateTime voucherDate)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (dataSource == null)
                {
                    return;
                }
                //CommonVariable = new GlobalVariable();
                var oRsTool = ReportSharpTool;
                var str     = GlobalVariable.ReportPath + (string.IsNullOrEmpty(oRsTool.ReportFileName) ? reportList.ReportFile : oRsTool.ReportFileName);
                oRsTool.RssObject.VoucherDate = voucherDate;
                oRsTool.ListDataSource        = dataSource;
                oRsTool.DataMember            = reportList.TableName.Trim();
                oRsTool.LayoutReportPath      = GlobalVariable.ReportPath;
                oRsTool.ReportFileName        = str;

                if (!AddParameter(ref dataSource))
                {
                    return;
                }
                oRsTool.IsPrint            = isPrint;
                oRsTool.ReportTitle        = reportList.ReportName;
                oRsTool.ProductName        = GlobalVariable.ProducName;
                oRsTool.DisplayProductName = false;
                _frmParentForm             = frmForm;
                var model = new Model();
                //tam thoi comment
                CurrencyModels          = model.GetCurrencies();
                NumberToWord.Currencies = new List <Currency>();
                foreach (var currencyModel in CurrencyModels)
                {
                    NumberToWord.Currencies.Add(new Currency
                    {
                        //CurrencyId = currencyModel.CurrencyId,
                        CurrencyCode = currencyModel.CurrencyCode,
                        CurrencyName = currencyModel.CurrencyName,
                        Prefix       = currencyModel.Prefix,
                        Suffix       = currencyModel.Suffix
                    });
                }
                oRsTool.RunReport(frmForm, isShowDialog);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString() + ex.InnerException, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #7
0
 public void ExtractXMLKhoBac(string reportId)
 {
     _reportListModel = ReportLists.Find(item => item.ReportId == reportId);
     if (!string.IsNullOrEmpty(_reportListModel.InputTypeName))
     {
         var type   = Assembly.GetExecutingAssembly().GetType(GetType().Namespace + "." + "ExportXML");
         var target = (BaseReport)Activator.CreateInstance(type);
         if (!string.IsNullOrEmpty(_reportListModel.ProcedureName))
         {
             var args       = new object[] { ReportParameter, _rsTool, null, false };
             var dataSource = (IList)(type.InvokeMember(_reportListModel.FunctionReportName + "XML", BindingFlags.InvokeMethod, null, target, args));
         }
     }
 }
Example #8
0
        private DataSet GetDataSet(XtraForm frmParent, ReportListModel reportList, object[] parms)
        {
            DataSet ds = new DataSet();

            if (!string.IsNullOrEmpty(reportList.InputTypeName))
            {
                var type   = Assembly.GetExecutingAssembly().GetType(GetType().Namespace + "." + reportList.InputTypeName);
                var target = (BaseReport)Activator.CreateInstance(type);
                if (!string.IsNullOrEmpty(reportList.ProcedureName))
                {
                    var args = new object[] { reportList.ProcedureName, parms };
                    ds = (DataSet)(type.InvokeMember(reportList.FunctionReportName, BindingFlags.InvokeMethod, null, target, args));
                }
            }
            return(ds);
        }
Example #9
0
 public static void PreviewReport(XtraForm frmParent, ReportListModel reportListModel, object[] paramStore, Dictionary <string, object> paramReport)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         var reportHelper = new ReportHelper();
         reportHelper.PreviewReportUsingDataSet(frmParent, reportListModel, paramStore, paramReport);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Lỗi: " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Example #10
0
        public void PreviewReportUsingDataSet(XtraForm frmParent, ReportListModel reportListModel, object[] paramStore, Dictionary <string, object> paramReport)
        {
            if (reportListModel == null)
            {
                return;
            }
            _frmParentForm = frmParent;
            ParamReport    = paramReport;
            var dataSet = GetDataSet(frmParent, reportListModel, paramStore);

            if (dataSet == null)
            {
                return;
            }

            DisplayReport(dataSet, reportListModel, frmParent);
        }
        public ActionResult ReportResults(ReportModel model, ReportListModel models)
        {
            /*
             * var mods = new List<ReportModel>();
             *
             * var rec1 = new ReportModel();
             * rec1.LName = "Bolden";
             * rec1.FName = "Robert";
             * rec1.Amount = 100.0;
             *
             * mods.Add(rec1);
             */

            ViewBag.MyModel = ReportModel.getReport(model, models);

            return(View());
        }
Example #12
0
        public IActionResult GetList([FromQuery] ReportViewModel model)
        {
            var messages  = _messageRepository.GetMessagesByDavaId(model.DavaId).ToList();
            var documents = _documentRepository.GetDocuments().Where(d => d.DavaId == model.DavaId).ToList();
            var masrafs   = _masrafRepository.GetMasrafs().Where(d => d.DavaId == model.DavaId).ToList();

            if (model.DateDisabled)
            {
                messages.Where(m => m.Date <= model.EndDate && m.Date >= model.StartDate).ToList();
                documents.Where(m => m.Date <= model.EndDate && m.Date >= model.StartDate).ToList();
                masrafs.Where(m => m.Date <= model.EndDate && m.Date >= model.StartDate).ToList();
            }

            var reportListModel = new ReportListModel()
            {
                Masrafs = masrafs, Documents = documents, Messages = messages
            };
            var result = _mapper.Map <ReportListViewModel>(reportListModel);

            return(Ok(result));
        }
Example #13
0
        private DataTable GetDataSourceDataTable(XtraForm frmParent, ReportListModel reportList)
        {
            DataTable dataSource = null;

            try
            {
                if (!string.IsNullOrEmpty(reportList.InputTypeName))
                {
                    var type   = Assembly.GetExecutingAssembly().GetType(GetType().Namespace + "." + reportList.InputTypeName);
                    var target = (BaseReport)Activator.CreateInstance(type);
                    if (!string.IsNullOrEmpty(reportList.ProcedureName))
                    {
                        var args = new object[] { ReportParameter, _rsTool };
                        dataSource = (DataTable)(type.InvokeMember(reportList.FunctionReportName, BindingFlags.InvokeMethod, null, target, args));
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Có lỗi xảy ra trong quá trình truy vấn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(dataSource);
        }
Example #14
0
        private string GetReports()
        {
            string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString();
            string output;
            string siteType = Request["siteType"];
            string teamGuid = Request["SiteGuid"];

            JavaScriptSerializer jss = new JavaScriptSerializer();
            var paramDes             = jss.Deserialize <WebApplication1.Models.QueryParameterViewModel>(Request["queryParam"]);

            int tileId = int.Parse(paramDes.TileId);


            // Get the reports from the reports list
            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                ReportRepository         rep       = new ReportRepository(context);
                TileRepository           tileRep   = new TileRepository(context);
                TileQueryLogicRepository tileQuery = new TileQueryLogicRepository(context);
                TileServices             tService  = new TileServices(tileRep, null, null, null, null, null, tileQuery);

                var tile = tService.GetTileById(tileId);

                EditReportService editReport = new EditReportService(rep, null, null, null, null, tileRep, tileQuery);


                #region Get ReportFilter
                ReportFilter filer = new ReportFilter();
                foreach (WebApplication1.Models.FilterModel vm in paramDes.FilterEntityList)
                {
                    switch (vm.FilterType)
                    {
                    case "Tag":
                        filer.TagsIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList();
                        break;

                    case "Owner":
                        filer.OwnerIdCollection = (from fl in vm.FilterItemList select fl.Value).ToList();
                        break;

                    case "Sub Category":
                        filer.SubCategoryIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList();
                        break;

                    default:
                        break;
                    }
                }
                #endregion


                // TO-DO: Team admin is set to true
                var reports = editReport.GetReportsByTeamWithReportsRequire(teamGuid,
                                                                            tileId, filer, true, userName, paramDes.CurrentPage,
                                                                            paramDes.PageSize,
                                                                            SortField.ReportTitle, (paramDes.SortAscending ? SortOrder.ASC : SortOrder.DESC)).ToArray();


                ReportListModel rptList = GetReportList(reports, Convert.ToInt32(paramDes.TileId));

                output = jss.Serialize(rptList);
                return(output);
            }
        }
Example #15
0
 public int ModifyTemplateReport(ReportListModel model)
 {
     return(dal.ModifyTemplateReport(model));
 }
Example #16
0
 public int EnableReport(ReportListModel model)
 {
     return(dal.EnableReport(model));
 }
Example #17
0
        public void DisplayReport(DataSet dataSource, ReportListModel reportList, XtraForm frmForm)
        {
            dataSource.DataSetName = "DataSource";
            var manager = new ReportManager();

            manager.GetReportParameter += manager_GetReportParameter;
            manager.OwnerForm           = frmForm;

            if (string.IsNullOrEmpty(reportList.TableName))
            {
                return;
            }

            var objectPointerCollection = new ObjectPointerCollection();
            // Các table name cách nhau = dấu ;
            var _listTableName = reportList.TableName.Split(';');

            if (_listTableName.Length > dataSource.Tables.Count || (dataSource.Tables.Count > 0 && dataSource.Tables[0].Rows.Count <= 0))
            {
                XtraMessageBox.Show("Dữ liệu báo cáo không có bản ghi nào!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            for (int i = 0; i < _listTableName.Length; i++)
            {
                DataTable dt = new DataTable();
                dt           = dataSource.Tables[i];
                dt.TableName = _listTableName[i];

                var colDecimalPlaces = new DataColumn();
                colDecimalPlaces.ColumnName   = nameof(TextFormat.DecimalPlaces); // Số chữ số sau dấu phẩy
                colDecimalPlaces.DataType     = typeof(int);
                colDecimalPlaces.DefaultValue = ReportSharpTool?.RssObject?.CurrencyFormat?.DecimalPlaces;

                var colDecimalSeparator = new DataColumn();
                colDecimalSeparator.ColumnName   = nameof(TextFormat.DecimalSeparator);
                colDecimalSeparator.DataType     = typeof(string);
                colDecimalSeparator.DefaultValue = ReportSharpTool?.RssObject?.CurrencyFormat?.DecimalSeparator;

                var colGroupSeparator = new DataColumn();
                colGroupSeparator.ColumnName   = nameof(TextFormat.GroupSeparator);
                colGroupSeparator.DataType     = typeof(string);
                colGroupSeparator.DefaultValue = ReportSharpTool?.RssObject?.CurrencyFormat?.GroupSeparator;
                dt.Columns.AddRange(new DataColumn[] { colDecimalPlaces, colDecimalSeparator, colGroupSeparator });

                objectPointerCollection.Add(dt.TableName, dt);
            }
            //objectPointerCollection.Add(nameof(dataSource), dataSource);
            manager.DataSources = objectPointerCollection;

            var reportSlot = new FileReportSlot {
                FilePath = GlobalVariable.ReportPath + reportList.ReportFile
            };

            manager.Reports.Add(reportSlot);
            AddParamSystem();
            reportSlot.RenderDocument();
            reportSlot.Document.Name = reportList.ReportName;

            var previewForm = new PreviewForm(reportSlot);

            previewForm.WindowState = FormWindowState.Maximized;
            previewForm.ReportViewer.DocumentLoaded += ReportViewer_DocumentLoaded;
            previewForm.ShowDialog();
        }
 /// <summary>
 /// Updates the report list.
 /// </summary>
 /// <param name="reportListModel">The report list model.</param>
 /// <returns></returns>
 public string UpdateReportList(ReportListModel reportListModel)
 {
     return(null);
     //return Model.UpdateReportList(reportListModel);
 }
 /// <summary>
 /// Updates the report list.
 /// </summary>
 /// <param name="reportListModel">The report list model.</param>
 /// <returns></returns>
 public string UpdateReportList(ReportListModel reportListModel)
 {
     return(Model.UpdateReportList(reportListModel));
 }