Ejemplo n.º 1
0
        public void ClearWorksheets()
        {
            Budget.Unprotect();
            CashFlow.Unprotect();

            ClearWorksheet(Budget);
            ClearWorksheet(CashFlow);

            Budget.Protect();
            CashFlow.Protect();

            CashFlow.Activate();
        }
Ejemplo n.º 2
0
        public bool OpenCashFlow(SqlConnection conn,
                                 int commandTimeout        = 30,
                                 bool includeActivePeriods = false,
                                 bool includeOrderBook     = false,
                                 bool includeBankBalances  = false,
                                 bool includeBankTypes     = false,
                                 bool includeTaxAccruals   = false,
                                 bool includeVatDetails    = false,
                                 bool includeBalanceSheet  = false)
        {
            try
            {
                reportMode = ReportMode.CashFlow;

                Budget.Activate(); Budget.Range["A1"].Select();

                CashFlow.BeginInit();
                CashFlow.Unprotect();
                ClearWorksheet(CashFlow);

                dataContext = new DataContext(conn);
                dataContext.CommandTimeout = commandTimeout;
                dataContext.Open();

                SetActivePeriod(CashFlow, Properties.Resources.TextStatementTitle);
                InitialiseWorksheet(CashFlow);
                InitialisePeriods(CashFlow);

                LoadCategories(CashFlow, CashType.Trade, includeActivePeriods, includeOrderBook, false);
                LoadCategories(CashFlow, CashType.Money, false, false, false);
                LoadTotals(CashFlow, CashType.Trade, CategoryType.Total);

                LoadCategories(CashFlow, CashType.Tax, includeActivePeriods, false, includeTaxAccruals);
                LoadTotals(CashFlow, CashType.Tax, CategoryType.Total);

                LoadTotalsFormula(CashFlow);
                LoadExpressions(CashFlow);

                if (includeBankTypes)
                {
                    LoadCategories(CashFlow, CashType.Money, false, false, false);
                }

                if (includeBankBalances)
                {
                    LoadBankBalances(CashFlow);
                }

                if (includeVatDetails)
                {
                    LoadVatRecurrenceTotals(CashFlow, includeActivePeriods, includeTaxAccruals);
                    LoadVatPeriodTotals(CashFlow, includeActivePeriods, includeTaxAccruals);
                }

                if (includeBalanceSheet)
                {
                    LoadBalanceSheet(CashFlow);
                }

                dataContext.Close();
                CashFlow.EndInit();

                CashFlow.Activate();
                FreezeFrames();
                CashFlow.Protect();

                return(true);
            }
            catch (Exception err)
            {
                dataContext = new DataContext(conn);
                dataContext.ErrorLog($"{ err.Source}.{ err.TargetSite.Name} {err.Message}");
                return(false);
            }
        }