public void ClearWorksheets() { Budget.Unprotect(); CashFlow.Unprotect(); ClearWorksheet(Budget); ClearWorksheet(CashFlow); Budget.Protect(); CashFlow.Protect(); CashFlow.Activate(); }
public bool OpenBudget(SqlConnection conn, int commandTimeout = 30, bool includeActivePeriods = false, bool includeOrderBook = false) { try { reportMode = ReportMode.Budget; CashFlow.Activate(); CashFlow.Range["A1"].Select(); Budget.Unprotect(); ClearWorksheet(Budget); dataContext = new DataContext(conn); dataContext.CommandTimeout = commandTimeout; dataContext.Open(); SetActivePeriod(Budget, Properties.Resources.BudgetStatementTitle); InitialiseWorksheet(Budget); InitialisePeriods(Budget); LoadCategories(Budget, CashType.Trade, includeActivePeriods, includeOrderBook, false); dataContext.Close(); Budget.Activate(); FreezeFrames(); Budget.Protect(); return(true); } catch (Exception err) { DataContext data = new DataContext(conn); data.ErrorLog($"{ err.Source}.{ err.TargetSite.Name} {err.Message}"); return(false); } }
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); } }