/// <summary> /// Handles the Click event of the lbSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } var rockContext = new RockContext(); var financialStatementTemplateService = new FinancialStatementTemplateService(rockContext); var statementTemplateId = hfStatementTemplateId.Value.AsIntegerOrNull(); FinancialStatementTemplate financialStatementTemplate = null; if (statementTemplateId.HasValue) { financialStatementTemplate = financialStatementTemplateService.Get(statementTemplateId.Value); } var isNew = financialStatementTemplate == null; if (isNew) { financialStatementTemplate = new FinancialStatementTemplate(); financialStatementTemplateService.Add(financialStatementTemplate); } financialStatementTemplate.Name = tbName.Text; financialStatementTemplate.Description = tbDescription.Text; financialStatementTemplate.IsActive = cbIsActive.Checked; financialStatementTemplate.ReportTemplate = ceReportTemplate.Text; financialStatementTemplate.FooterSettings.HtmlFragment = ceFooterTemplateHtmlFragment.Text; financialStatementTemplate.ReportSettings.PDFSettings.MarginTopMillimeters = nbMarginTopMillimeters.IntegerValue; financialStatementTemplate.ReportSettings.PDFSettings.MarginBottomMillimeters = nbMarginBottomMillimeters.IntegerValue; financialStatementTemplate.ReportSettings.PDFSettings.MarginLeftMillimeters = nbMarginLeftMillimeters.IntegerValue; financialStatementTemplate.ReportSettings.PDFSettings.MarginRightMillimeters = nbMarginRightMillimeters.IntegerValue; financialStatementTemplate.ReportSettings.PDFSettings.PaperSize = ddlPaperSize.SelectedValueAsEnumOrNull <FinancialStatementTemplatePDFSettingsPaperSize>() ?? FinancialStatementTemplatePDFSettingsPaperSize.Letter; var transactionSetting = new FinancialStatementTemplateTransactionSetting(); transactionSetting.CurrencyTypesForCashGiftGuids = dvpCurrencyTypesCashGifts.SelectedValuesAsInt.Select(a => DefinedValueCache.Get(a)?.Guid).Where(a => a.HasValue).Select(a => a.Value).ToList(); transactionSetting.CurrencyTypesForNonCashGuids = dvpCurrencyTypesNonCashGifts.SelectedValuesAsInt.Select(a => DefinedValueCache.Get(a)?.Guid).Where(a => a.HasValue).Select(a => a.Value).ToList(); transactionSetting.TransactionTypeGuids = dvpTransactionType.SelectedValuesAsInt.Select(a => DefinedValueCache.Get(a)?.Guid).Where(a => a.HasValue).Select(a => a.Value).ToList(); transactionSetting.HideRefundedTransactions = cbHideRefundedTransactions.Checked; transactionSetting.HideCorrectedTransactionOnSameData = cbHideModifiedTransactions.Checked; if (rbAllTaxDeductibleAccounts.Checked) { transactionSetting.AccountSelectionOption = FinancialStatementTemplateTransactionSettingAccountSelectionOption.AllTaxDeductibleAccounts; } else if (cbIncludeChildAccountsCustom.Checked) { transactionSetting.AccountSelectionOption = FinancialStatementTemplateTransactionSettingAccountSelectionOption.SelectedAccountsIncludeChildren; } else { transactionSetting.AccountSelectionOption = FinancialStatementTemplateTransactionSettingAccountSelectionOption.SelectedAccounts; } transactionSetting.SelectedAccountIds = apTransactionAccountsCustom.SelectedIds.ToList(); financialStatementTemplate.ReportSettings.TransactionSettings = transactionSetting; var pledgeSetting = new FinancialStatementTemplatePledgeSettings(); pledgeSetting.IncludeGiftsToChildAccounts = cbIncludeGiftsToChildAccounts.Checked; pledgeSetting.IncludeNonCashGifts = cbIncludeNonCashGifts.Checked; pledgeSetting.AccountIds = apPledgeAccounts.SelectedIds.ToList(); financialStatementTemplate.ReportSettings.PledgeSettings = pledgeSetting; int?existingLogoId = null; if (financialStatementTemplate.LogoBinaryFileId != imgTemplateLogo.BinaryFileId) { existingLogoId = financialStatementTemplate.LogoBinaryFileId; financialStatementTemplate.LogoBinaryFileId = imgTemplateLogo.BinaryFileId; } rockContext.SaveChanges(); var queryParams = new Dictionary <string, string>(); queryParams.Add(PageParameterKey.StatementTemplateId, financialStatementTemplate.Id.ToStringSafe()); NavigateToCurrentPage(queryParams); }
/// <summary> /// Copies the base properties from a source FinancialStatementTemplatePledgeSettings object /// </summary> /// <param name="source">The source.</param> public void CopyPropertiesFrom(FinancialStatementTemplatePledgeSettings source) { this.AccountIds = source.AccountIds; this.IncludeGiftsToChildAccounts = source.IncludeGiftsToChildAccounts; this.IncludeNonCashGifts = source.IncludeNonCashGifts; }