/// <summary> /// Handles the RowDataBound event of the gAccountsView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param> protected void gAccountsView_RowDataBound(object sender, GridViewRowEventArgs e) { var financialTransactionDetail = ( FinancialScheduledTransactionDetail )e.Row.DataItem; if (financialTransactionDetail == null) { return; } var lAccountsViewAccountName = e.Row.FindControl("lAccountsViewAccountName") as Literal; lAccountsViewAccountName.Text = FinancialAccountNameLookup.GetValueOrNull(financialTransactionDetail.AccountId); var lAccountsViewAmountMinusFeeCoverageAmount = e.Row.FindControl("lAccountsViewAmountMinusFeeCoverageAmount") as Literal; decimal amountMinusFeeCoverageAmount; if (financialTransactionDetail.FeeCoverageAmount.HasValue) { amountMinusFeeCoverageAmount = financialTransactionDetail.Amount - financialTransactionDetail.FeeCoverageAmount.Value; } else { amountMinusFeeCoverageAmount = financialTransactionDetail.Amount; } lAccountsViewAmountMinusFeeCoverageAmount.Text = amountMinusFeeCoverageAmount.FormatAsCurrency(ForeignCurrencyDefinedValueId); }
/// <summary> /// Handles the RowDataBound event of the gAccountsEdit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param> protected void gAccountsEdit_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } var financialTransactionDetail = ( FinancialScheduledTransactionDetail )e.Row.DataItem; // If this is the total row if (financialTransactionDetail.AccountId == TotalRowAccountId) { // disable the row select on each column foreach (TableCell cell in e.Row.Cells) { cell.RemoveCssClass("grid-select-cell"); } } var lAccountsEditAccountName = e.Row.FindControl("lAccountsEditAccountName") as Literal; lAccountsEditAccountName.Text = FinancialAccountNameLookup.GetValueOrNull(financialTransactionDetail.AccountId); var lAccountsEditAmountMinusFeeCoverageAmount = e.Row.FindControl("lAccountsEditAmountMinusFeeCoverageAmount") as Literal; decimal amountMinusFeeCoverageAmount; if (financialTransactionDetail.FeeCoverageAmount.HasValue) { amountMinusFeeCoverageAmount = financialTransactionDetail.Amount - financialTransactionDetail.FeeCoverageAmount.Value; } else { amountMinusFeeCoverageAmount = financialTransactionDetail.Amount; } lAccountsEditAmountMinusFeeCoverageAmount.Text = amountMinusFeeCoverageAmount.FormatAsCurrency(ForeignCurrencyDefinedValueId); // If account is associated with an entity (i.e. registration), or this is the total row do not allow it to be deleted if (financialTransactionDetail.EntityTypeId.HasValue || financialTransactionDetail.AccountId == TotalRowAccountId) { // Hide the edit button if this is the total row if (financialTransactionDetail.AccountId == TotalRowAccountId) { var editBtn = e.Row.Cells[3].ControlsOfTypeRecursive <LinkButton>().FirstOrDefault(); if (editBtn != null) { editBtn.Visible = false; } } // Hide the delete button var deleteBtn = e.Row.Cells[4].ControlsOfTypeRecursive <LinkButton>().FirstOrDefault(); if (deleteBtn != null) { deleteBtn.Visible = false; } } }