Example #1
0
        private void activeLoansToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (ReportService.GetInstance().CanLoadDocument())
                {
                    var reportName       = (sender as ToolStripMenuItem).Tag.ToString();
                    var report           = ReportService.GetInstance().GetReportByName(reportName);
                    var reportParamsForm = new ReportParamsForm(report.Params, report.Title);

                    if (reportParamsForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    var progressForm = new ReportLoadingProgressForm();
                    progressForm.Show();

                    var bw = new BackgroundWorker
                    {
                        WorkerReportsProgress      = true,
                        WorkerSupportsCancellation = true,
                    };
                    bw.DoWork += (obj, args) =>
                    {
                        ReportService.GetInstance().LoadReport(report);
                        bw.ReportProgress(100);
                    };
                    bw.RunWorkerCompleted += (obj, args) =>
                    {
                        progressForm.Close();
                        if (args.Error != null)
                        {
                            Fail(args.Error.Message);
                            return;
                        }
                        if (args.Cancelled)
                        {
                            return;
                        }

                        report.OpenCount++;
                        report.SaveOpenCount();
                        var reportViewer = new ReportViewerForm(report);
                        reportViewer.Show();
                    };
                    bw.RunWorkerAsync(report);
                }
                else
                {
                    var translationService = new TranslationService();
                    MessageBox.Show(translationService.Translate("Crystal reports haven't been installed."));
                }
            }
            catch (Exception ex)
            {
                Fail(ex.Message);
            }
        }
Example #2
0
        private void OnReportsClick(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                var reportName       = (sender as LinkLabel).Tag.ToString();
                var report           = ReportService.GetInstance().GetReportByName(reportName);
                var reportParamsForm = new ReportParamsForm(report.Params, report.Title);

                if (reportParamsForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var progressForm = new ReportLoadingProgressForm();
                progressForm.Show();

                var bw = new BackgroundWorker
                {
                    WorkerReportsProgress      = true,
                    WorkerSupportsCancellation = true,
                };
                bw.DoWork += (obj, args) =>
                {
                    ReportService.GetInstance().LoadReport(report);
                    bw.ReportProgress(100);
                };
                bw.RunWorkerCompleted += (obj, args) =>
                {
                    progressForm.Close();
                    if (args.Error != null)
                    {
                        Fail(args.Error.Message);
                        return;
                    }
                    if (args.Cancelled)
                    {
                        return;
                    }

                    report.OpenCount++;
                    report.SaveOpenCount();
                    var reportViewer = new ReportViewerForm(report);
                    reportViewer.Show();
                };
                bw.RunWorkerAsync(report);
            }
            catch (Exception ex)
            {
                Fail(ex.Message);
            }
        }
Example #3
0
        private void PrintReport(Guid guid)
        {
            ReportService rs     = ReportService.GetInstance();
            Report        report = rs.GetReport(guid);

            if (null == report)
            {
                return;
            }

            try
            {
                List <ReportParamV2> additionalParams
                    = report.Params
                      .Where(p => p.Additional && p.Visible)
                      .ToList();
                if (additionalParams.Count != 0)
                {
                    ReportParamsForm reportParamsForm = new ReportParamsForm(additionalParams, report.Title);
                    if (reportParamsForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }

                ReportInitializer(report);

                try
                {
                    StartProgress();
                    rs.LoadReport(report);
                }
                finally
                {
                    StopProgress();
                }
            }
            catch (Exception exception)
            {
                new frmShowError(
                    CustomExceptionHandler.ShowExceptionText(exception)
                    ).ShowDialog();
                throw;
            }

            ReportViewerForm frm = new ReportViewerForm(report);

            frm.Show();
        }
        private void activeLoansToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var reportName = (sender as ToolStripMenuItem).Tag.ToString();
                var report = ReportService.GetInstance().GetReportByName(reportName);
                var reportParamsForm = new ReportParamsForm(report.Params, report.Title);

                if (reportParamsForm.ShowDialog() != DialogResult.OK) return;

                var progressForm = new ReportLoadingProgressForm();
                progressForm.Show();

                var bw = new BackgroundWorker
                {
                    WorkerReportsProgress = true,
                    WorkerSupportsCancellation = true,
                };
                bw.DoWork += (obj, args) =>
                {
                    ReportService.GetInstance().LoadReport(report);
                    bw.ReportProgress(100);
                };
                bw.RunWorkerCompleted += (obj, args) =>
                {
                    progressForm.Close();
                    if (args.Error != null)
                    {
                        Fail(args.Error.Message);
                        return;
                    }
                    if (args.Cancelled) return;

                    report.OpenCount++;
                    report.SaveOpenCount();
                    var reportViewer = new ReportViewerForm(report);
                    reportViewer.Show();
                };
                bw.RunWorkerAsync(report);
            }
            catch (Exception ex)
            {
                Fail(ex.Message);
            }
        }
Example #5
0
        private void buttonPrepareExport_Click(object sender, EventArgs e)
        {
            if (cbProcNames.Items.Count > 0)
            {
                List <ReportParamV2> paramList = new List <ReportParamV2>();

                Dictionary <string, string> parameters =
                    ServicesProvider.GetInstance().GetAccountingServices().SelectExportAccountingProcParams("ExportAccounting_" + cbProcNames.Text);

                if (parameters != null && parameters.Count > 0)
                {
                    foreach (var parameter in parameters)
                    {
                        ReportParamV2 reportParam;
                        string        paramName = parameter.Key.TrimStart('@');
                        if (paramName.Equals("branch_id", StringComparison.CurrentCultureIgnoreCase))
                        {
                            reportParam = new BranchParam(string.Empty);
                        }
                        else
                        {
                            string paramType = parameter.Value;
                            switch (paramType)
                            {
                            case "bit":
                                reportParam = new BoolParam(false);
                                break;

                            case "datetime":
                                reportParam = new DateParam(DateTime.Today);
                                break;

                            case "char":
                                reportParam = new CharParam(' ');
                                break;

                            case "nvarchar":
                            case "varchar":
                            case "text":
                                reportParam = new StringParam(string.Empty);
                                break;

                            case "int":
                                reportParam = new IntParam(1);
                                break;

                            case "float":
                                reportParam = new DoubleParam(1d);
                                break;

                            case "money":
                                reportParam = new DecimalParam(1m);
                                break;

                            default:
                                throw new NotImplementedException(string.Format("Sql type:{0} is not handled.", paramName));
                            }
                        }

                        reportParam.Label = paramName;
                        reportParam.Name  = paramName;
                        paramList.Add(reportParam);
                    }
                    ReportParamsForm frm = new ReportParamsForm(paramList, cbProcNames.Text);
                    frm.ShowDialog();
                }

                _dataTable =
                    ServicesProvider.GetInstance().GetAccountingServices().FindElementaryMvtsToExport(
                        "ExportAccounting_"
                        + cbProcNames.Text, paramList, out _idTable);

                _total = _dataTable.Rows.Count;

                _bwSelect = new BackgroundWorker {
                    WorkerSupportsCancellation = true
                };
                _bwSelect.DoWork += BwSelect_DoWork;

                ExportBookings_Load(this, null);
            }
        }
Example #6
0
        private void PrintReport(Guid guid)
        {
            ReportService rs     = ReportService.GetInstance();
            Report        report = rs.GetReport(guid);

            if (null == report)
            {
                return;
            }

            try
            {
                ReportInitializer(report);
                if (report.DisableIfLoanIsPending)
                {
                    var loan = (Loan)report.GetExtra("loan");
                    if (loan == null || loan.ContractStatus == OContractStatus.None ||
                        loan.ContractStatus == OContractStatus.Pending)
                    {
                        MessageBox.Show(
                            MultiLanguageStrings.GetString(Ressource.PrintButton, "pleaseApproveLoan"),
                            MultiLanguageStrings.GetString(Ressource.PrintButton, "warning"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning);
                        return;
                    }
                }

                List <ReportParamV2> additionalParams
                    = report.Params
                      .Where(p => p.Additional && p.Visible)
                      .ToList();
                if (additionalParams.Count != 0)
                {
                    ReportParamsForm reportParamsForm = new ReportParamsForm(additionalParams, report.Title);
                    if (reportParamsForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }

                try
                {
                    StartProgress();
                    rs.LoadReport(report);
                }
                finally
                {
                    StopProgress();
                }
            }
            catch (Exception exception)
            {
                new frmShowError(
                    CustomExceptionHandler.ShowExceptionText(exception)
                    ).ShowDialog();
                throw;
            }

            ReportViewerForm frm = new ReportViewerForm(report);

            frm.Show();
        }
Example #7
0
        private void buttonPrepareExport_Click(object sender, EventArgs e)
        {
            if (cbProcNames.Items.Count > 0)
            {
                List<ReportParamV2> paramList = new List<ReportParamV2>();

                Dictionary<string, string> parameters =
                    ServicesProvider.GetInstance().GetAccountingServices().SelectExportAccountingProcParams("ExportAccounting_" + cbProcNames.Text);

                if (parameters != null && parameters.Count > 0)
                {
                    foreach (var parameter in parameters)
                    {
                        ReportParamV2 reportParam;
                        string paramName = parameter.Key.TrimStart('@');
                        if (paramName.Equals("branch_id", StringComparison.CurrentCultureIgnoreCase))
                            reportParam = new BranchParam(string.Empty);
                        else
                        {
                            string paramType = parameter.Value;
                            switch (paramType)
                            {
                                case "bit":
                                    reportParam = new BoolParam(false);
                                    break;
                                case "datetime":
                                    reportParam = new DateParam(DateTime.Today);
                                    break;
                                case "char":
                                    reportParam = new CharParam(' ');
                                    break;
                                case "nvarchar":
                                case "varchar":
                                case "text":
                                    reportParam = new StringParam(string.Empty);
                                    break;
                                case "int":
                                    reportParam = new IntParam(1);
                                    break;
                                case "float":
                                    reportParam = new DoubleParam(1d);
                                    break;
                                case "money":
                                    reportParam = new DecimalParam(1m);
                                    break;
                                default:
                                    throw new NotImplementedException(string.Format("Sql type:{0} is not handled.", paramName));
                            }
                        }

                        reportParam.Label = paramName;
                        reportParam.Name = paramName;
                        paramList.Add(reportParam);
                    }
                    ReportParamsForm frm = new ReportParamsForm(paramList, cbProcNames.Text);
                    frm.ShowDialog();
                }

                _dataTable =
                    ServicesProvider.GetInstance().GetAccountingServices().FindElementaryMvtsToExport(
                        "ExportAccounting_"
                        + cbProcNames.Text, paramList, out _idTable);

                _total = _dataTable.Rows.Count;

                _bwSelect = new BackgroundWorker {WorkerSupportsCancellation = true};
                _bwSelect.DoWork += BwSelect_DoWork;

                ExportBookings_Load(this, null);
            }
        }