Пример #1
0
        /// <summary>
        /// Print or reprint the posting report for this batch.
        /// </summary>
        public static void PrintPostingRegister(Int32 ALedgerNumber, Int32 ABatchNumber, Boolean AEditTemplate = false)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Batch Posting Register");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(ALedgerNumber, ABatchNumber);
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = BatchTDS.ALedger[0];

            //Call RegisterData to give the data to the template
            ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch");
            ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal");
            ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction");

            Calc.AddParameter("param_batch_number_i", ABatchNumber);
            Calc.AddParameter("param_ledger_number_i", ALedgerNumber);
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerName);

            if (AEditTemplate)
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
        private void ViewReportTemplate(TRptCalculator ACalc)
        {
            String ReportName = "";

            if (chkFees.Enabled && chkFees.Checked)
            {
                ReportName = "Fees";
            }

            if (chkStewardship.Enabled && chkStewardship.Checked)
            {
                ReportName = "Stewardship";
            }

            if (chkHOSA.Enabled && chkHOSA.Checked)
            {
                ReportName = "HOSA";
            }

            if (ReportName == "")
            {
                return;
            }

            MyFastReportsPlugin = new FastReportsWrapper(ReportName);

            if (chkFees.Enabled && chkFees.Checked)
            {
                MyFastReportsPlugin.SetDataGetter(LoadFeesReportData);
            }

            if (chkStewardship.Enabled && chkStewardship.Checked)
            {
                MyFastReportsPlugin.SetDataGetter(LoadStewardshipReportData);
            }

            if (chkHOSA.Enabled && chkHOSA.Checked)
            {
                MyFastReportsPlugin.SetDataGetter(LoadHosaReportData);
            }

            MyFastReportsPlugin.DesignReport(ACalc);
        }
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Account Hierarchy");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            if (!FMainDS.AAccount.Columns.Contains("AccountPath"))
            {
                FMainDS.AAccount.Columns.Add("AccountPath", typeof(String));
                FMainDS.AAccount.Columns.Add("AccountLevel", typeof(Int32));
            }

            DataView PathView = new DataView(FMainDS.AAccountHierarchyDetail);
            PathView.Sort = "a_reporting_account_code_c";

            DataView AccountView = new DataView(FMainDS.AAccount);
            AccountView.Sort = "a_account_code_c";

            // I need to make the "AccountPath" field that will be used to sort the table for printout:
            foreach (DataRowView rv in PathView)
            {
                DataRow Row = rv.Row;
                String AccountCode = Row["a_reporting_account_code_c"].ToString();
                String Path = Row["a_report_order_i"] + "-" + AccountCode + '~';
                Int32 Level = 0;
                String ReportsTo = Row["a_account_code_to_report_to_c"].ToString();

                while (ReportsTo != "")
                {
                    Int32 ParentIdx = PathView.Find(ReportsTo);

                    if (ParentIdx >= 0)
                    {
                        DataRow ParentRow = PathView[ParentIdx].Row;
                        ReportsTo = ParentRow["a_account_code_to_report_to_c"].ToString();
                        Path = ParentRow["a_report_order_i"] + "-" + ParentRow["a_reporting_account_code_c"].ToString() + "~" + Path;
                        Level++;

                        if (Level > 100) // Surely this is a fault. If I just break here,
                        {
                            break;  // the report will print and I should be able to see what the fault is.
                        }
                    }
                    else
                    {
                        ReportsTo = "";
                    }
                }

                Int32 AccountIdx = AccountView.Find(AccountCode);
                DataRow AccountRow = AccountView[AccountIdx].Row;
                AccountRow["AccountPath"] = Path;
                AccountRow["AccountLevel"] = Level;
            }

            AccountView.Sort = "AccountPath";
            DataTable SortedByPath = AccountView.ToTable();

            ReportingEngine.RegisterData(SortedByPath, "AccountHierarchy");
            ReportingEngine.RegisterData(FMainDS.AAnalysisAttribute, "AnalysisAttribute");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            TLogging.Log("CostCentreHierarchy.File Print..");
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Cost Centre Hierarchy");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            if (!FMainDS.ACostCentre.Columns.Contains("CostCentrePath"))
            {
                FMainDS.ACostCentre.Columns.Add("CostCentrePath", typeof(String));
                FMainDS.ACostCentre.Columns.Add("CostCentreLevel", typeof(Int32));
            }

            DataView PathView = new DataView(FMainDS.ACostCentre);
            PathView.Sort = "a_cost_centre_code_c";
            TLogging.Log("CostCentreHierarchy.File Print calculating paths..");

            // I need to make the "CostCentrePath" field that will be used to sort the table for printout:
            foreach (DataRowView rv in PathView)
            {
                DataRow Row = rv.Row;
                String Path = Row["a_cost_centre_code_c"].ToString() + '~';
                Int32 Level = 0;
                String ReportsTo = Row["a_cost_centre_to_report_to_c"].ToString();

                while (ReportsTo != "")
                {
                    Int32 ParentIdx = PathView.Find(ReportsTo);

                    if (ParentIdx >= 0)
                    {
                        DataRow ParentRow = PathView[ParentIdx].Row;
                        ReportsTo = ParentRow["a_cost_centre_to_report_to_c"].ToString();
                        Path = ParentRow["a_cost_centre_code_c"].ToString() + "~" + Path;
                        Level++;

                        if (Level > 100) // Surely this is a fault. If I just break here,
                        {
                            break;  // the report will print and I should be able to see what the fault is.
                        }
                    }
                    else
                    {
                        ReportsTo = "";
                    }
                }

                Row["CostCentrePath"] = Path;
                Row["CostCentreLevel"] = Level;
            }

            PathView.Sort = "CostCentrePath";
            DataTable SortedByPath = PathView.ToTable();

            TLogging.Log("CostCentreHierarchy.File Print paths all done.");

            ReportingEngine.RegisterData(SortedByPath, "CostCentreHierarchy");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_nunmber", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            TLogging.Log("CostCentreHierarchy.File Print calling FastReport...");

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
        /// <summary>
        /// Print out the Motivation Details using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            // Add in the Fees applicable for each row:

            if (!FMainDS.AMotivationDetail.Columns.Contains("Fees"))
            {
                FMainDS.AMotivationDetail.Columns.Add("Fees", typeof(String));
                FMainDS.AMotivationDetail.Columns.Add("KeyMin", typeof(String));
            }

            foreach (AMotivationDetailRow Row in FMainDS.AMotivationDetail.Rows)
            {
                FMainDS.AMotivationDetailFee.DefaultView.RowFilter = String.Format(
                    "a_motivation_group_code_c='{0}' AND a_motivation_detail_code_c='{1}'",
                    Row.MotivationGroupCode,
                    Row.MotivationDetailCode);
                String Fees = "";

                foreach (DataRowView rv in FMainDS.AMotivationDetailFee.DefaultView)
                {
                    AMotivationDetailFeeRow FeeRow = (AMotivationDetailFeeRow)rv.Row;

                    if (Fees != "")
                    {
                        Fees += ", ";
                    }

                    Fees += FeeRow.FeeCode;
                }

                Row["Fees"] = Fees;

                if (Row.RecipientKey != 0)
                {
                    String mPartnerShortName;
                    TPartnerClass mPartnerClass;

                    if (TServerLookup.TMPartner.GetPartnerShortName(Row.RecipientKey, out mPartnerShortName, out mPartnerClass, true))
                    {
                        Row["KeyMin"] = mPartnerShortName;
                    }
                }
            } // foreach

            //
            // Ensure the proper sorting for the printout:

            FMainDS.AMotivationDetail.DefaultView.Sort = "a_motivation_group_code_c, a_motivation_detail_code_c";
            ReportingEngine.RegisterData(FMainDS.AMotivationDetail.DefaultView.ToTable(), "MotivationDetail");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);
            Calc.AddParameter("param_TD", FTaxDeductiblePercentageEnabled);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
/*
 *      private void GenerateReports(Object Sender, EventArgs e)
 *      {
 *          String CurrencySelect = (this.rbtBase.Checked ? MFinanceConstants.CURRENCY_BASE : MFinanceConstants.CURRENCY_INTERNATIONAL);
 *          bool DoGenerateHOSAReports = chkHOSAReport.Checked;
 *          bool DoEmailHOSAReports = chkEmailHOSAReport.Checked;
 *          bool DoGenerateHOSAFiles = chkHOSAFile.Checked;
 *          bool DoEmailHOSAFiles = chkEmailHOSAFile.Checked;
 *
 *          TVerificationResultCollection VerificationResults;
 *
 *          string msg = string.Empty;
 *          string SuccessfullCostCentres = string.Empty;
 *          string FailedCostCentres = string.Empty;
 *
 *          int SelectedReportPeriod = cmbReportPeriod.GetSelectedInt32();
 *          int SelectedICHNumber = cmbICHNumber.GetSelectedInt32();
 *
 *          if (!ValidReportPeriod())
 *          {
 *              return;
 *          }
 *
 *          String HOSAFilePrefix = txtHOSAPrefix.Text;
 *
 *          if (HOSAFilePrefix.Length == 0)
 *          {
 *              HOSAFilePrefix = Catalog.GetString("HOSAFilesExportFor");
 *          }
 *          else
 *          {
 *              Int32 IndexOfInvalidFilenameCharacter = HOSAFilePrefix.IndexOfAny(Path.GetInvalidFileNameChars());
 *
 *              if (IndexOfInvalidFilenameCharacter >= 0)
 *              {
 *                  msg = String.Format("The HOSA File Prefix: '{0}', contains characters not valid in a filename: {1}{2}{2}Please remove and retry.",
 *                      HOSAFilePrefix,
 *                      String.Join(", ", Path.GetInvalidFileNameChars()),
 *                      Environment.NewLine);
 *
 *                  MessageBox.Show(msg, "Generate HOSA Reports and Files", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 *
 *                  txtHOSAPrefix.Focus();
 *                  txtHOSAPrefix.Select(IndexOfInvalidFilenameCharacter, 1);
 *                  return;
 *              }
 *          }
 *
 *          try
 *          {
 *              Cursor = Cursors.WaitCursor;
 *
 *              DataTable ICHNumbers = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.ICHStewardshipList, FLedgerNumber);
 *
 *              //Filter for current period
 *              if (SelectedICHNumber != 0)
 *              {
 *                  ICHNumbers.DefaultView.RowFilter = String.Format("{0}={1} And {2}={3}",
 *                      AIchStewardshipTable.GetPeriodNumberDBName(),
 *                      SelectedReportPeriod,
 *                      AIchStewardshipTable.GetIchNumberDBName(),
 *                      SelectedICHNumber);
 *              }
 *              else
 *              {
 *                  ICHNumbers.DefaultView.RowFilter = String.Format("{0}={1}",
 *                      AIchStewardshipTable.GetPeriodNumberDBName(),
 *                      SelectedReportPeriod);
 *              }
 *
 *              ICHNumbers.DefaultView.Sort = AIchStewardshipTable.GetCostCentreCodeDBName();
 *
 *              foreach (DataRowView tmpRow in ICHNumbers.DefaultView)
 *              {
 *                  AIchStewardshipRow ichRow = (AIchStewardshipRow)tmpRow.Row;
 *                  bool HOSASuccess = false;
 *
 *                  String CostCentreCode = ichRow.CostCentreCode;
 *
 *                  if (DoGenerateHOSAReports)
 *                  {
 *                      //TODO code to generate the HOSA reports
 *                      TRemote.MFinance.ICH.WebConnectors.GenerateHOSAReports(FLedgerNumber,
 *                          cmbReportPeriod.GetSelectedInt32(),
 *                          cmbICHNumber.GetSelectedInt32(),
 *                          CurrencySelect,
 *                          out VerificationResults);
 *                      HOSASuccess = !VerificationResults.HasCriticalErrors;
 *                  }
 *                  else if (DoGenerateHOSAFiles)
 *                  {
 *                      String FileName = TClientSettings.PathTemp + Path.DirectorySeparatorChar + HOSAFilePrefix + CostCentreCode + ".csv";
 *                      HOSASuccess = TRemote.MFinance.ICH.WebConnectors.GenerateHOSAFiles(FLedgerNumber, cmbReportPeriod.GetSelectedInt32(),
 *                          cmbICHNumber.GetSelectedInt32(), CostCentreCode, CurrencySelect, FileName, out VerificationResults);
 *                  }
 *
 *                  if (HOSASuccess)
 *                  {
 *                      if (SuccessfullCostCentres.Length == 0)
 *                      {
 *                          SuccessfullCostCentres = CostCentreCode;
 *                      }
 *                      else
 *                      {
 *                          SuccessfullCostCentres += ", " + CostCentreCode;
 *                      }
 *                  }
 *                  else
 *                  {
 *                      if (FailedCostCentres.Length == 0)
 *                      {
 *                          FailedCostCentres = CostCentreCode;
 *                      }
 *                      else
 *                      {
 *                          FailedCostCentres += ", " + CostCentreCode;
 *                      }
 *                  }
 *              }
 *
 *              Cursor = Cursors.Default;
 *
 *              if (SuccessfullCostCentres.Length > 0)
 *              {
 *                  msg = String.Format(Catalog.GetString("HOSA file generated successfully for Cost Centre(s):{0}{0}{1}{0}{0}"),
 *                      Environment.NewLine,
 *                      SuccessfullCostCentres);
 *              }
 *
 *              if (FailedCostCentres.Length > 0)
 *              {
 *                  msg += String.Format(Catalog.GetString("HOSA generation FAILED for Cost Centre(s):{0}{0}{1}"),
 *                      Environment.NewLine,
 *                      FailedCostCentres);
 *              }
 *
 *              if (msg.Length == 0)
 *              {
 *                  msg = Catalog.GetString("Stewardship Calculations haven't been run or no transactions to process.");
 *              }
 *
 *              MessageBox.Show(msg, Catalog.GetString("Generate Reports"));
 *          }
 *          finally
 *          {
 *              Cursor = Cursors.Default;
 *          }
 *      }
 *      private bool ValidReportPeriod()
 *      {
 *          if (cmbReportPeriod.SelectedIndex > -1)
 *          {
 *              return true;
 *          }
 *          else if (cmbReportPeriod.Count > 0)
 *          {
 *              MessageBox.Show(Catalog.GetString("Please select a valid reporting period first."));
 *              cmbReportPeriod.Focus();
 *          }
 *
 *          return false;
 *      }
 */
        private void ViewReportTemplate(TRptCalculator ACalc)
        {
            String ReportName = "";

            if (chkRecipient.Checked)
            {
                ReportName = "Recipient Gift Statement";
            }

            if (chkFees.Checked)
            {
                ReportName = "Fees";
            }

            if (chkStewardship.Checked)
            {
                ReportName = "Stewardship";
            }

            if (chkHOSA.Checked)
            {
                ReportName = "HOSA";
            }

            if (ReportName == "")
            {
                return;
            }

            MyFastReportsPlugin = new FastReportsWrapper(ReportName);
            MyFastReportsPlugin.DesignReport(ACalc);
        }
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Duplicate Address Check");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            ReportingEngine.RegisterData(FDuplicateLocations, "DuplicateLocations");
            TRptCalculator Calc = new TRptCalculator();

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
        /// <summary>
        /// Print out the Motivation Details using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            ReportingEngine.RegisterData(FMainDS.AMotivationDetail, "MotivationDetail");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }