public void Save(CashBoxSettings settings) { using (var core = new StandardBusinessLayer(this)) { core.Connect(); core.Save(settings); Settings = settings; } }
private void saveButton_Click(object sender, EventArgs e) { if (ValidateForm()) { int accountingYear = int.Parse(accountingYearTextBox.Text.Trim()); using (var core = new StandardBusinessLayer(DataCache)) { core.Connect(); CashBoxSettings settings = core.GetCashBoxSettings(CashBoxSettingsNo.CurrentApplicationNo); settings.AccountingYear = accountingYear; core.Save(settings); //CurrentApplication.CurrentVerification = core.GetFullVerification(core.GetLastVerification(accountingYear).No); //CurrentApplication.CurrentVerification = DataCache.GetVerification(DataCache.GetLastVerification().No); } if (accountingYear != _fromAccountingYear) { var settings = DataCache.Settings; settings.AccountingYear = accountingYear; DataCache.Save(settings); ApplicationEvents.OnAccountingYearChanged(_fromAccountingYear, accountingYear); } DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show("Formuläret innehåller fel.", "Valideringsfel", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Inits the database on create. /// </summary> /// <remarks> /// This method should be updated with every new database version, and should always work for the last database version, i.e. there /// is no need to handle previous versions since this is an init method. All help methods start with "Init". /// </remarks> public override void InitDatabaseOnCreate() { CashBoxSettings settings = new CashBoxSettings(CashBoxSettingsNo.CurrentApplicationNo, CurrentApplication.DateTimeNow.Year); Save(settings); Category category = new Category(null, CategoryType.Income, "Lön", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Income, "Korrigering", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Expense, "Mat", false, CurrentApplication.DateTimeNow, true); Save(category); Category foodCategory = category; category = new Category(foodCategory.No, CategoryType.Expense, "Mat", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(foodCategory.No, CategoryType.Expense, "Utemat", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Expense, "Bil", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Expense, "Resor", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Expense, "Hus", false, CurrentApplication.DateTimeNow, true); Save(category); category = new Category(null, CategoryType.Expense, "Korrigering", false, CurrentApplication.DateTimeNow, true); Save(category); // Add calls to more Init-methods here... }