private void ValidateDataDetailsManual(AFeesReceivableRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedFinanceValidation_GLSetup.ValidateAdminGrantReceivable(this, ARow, ref VerificationResultCollection, FPetraUtilsObject.ValidationControlsDict); // Need to check the Fee Code has not been used in FeesPayable ValidateFeeCode(ARow.FeeCode, VerificationResultCollection); }
/// <summary> /// /// </summary> /// <param name="AContext"></param> /// <param name="ARow"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="AValidationControlsDict"></param> public static void ValidateAdminGrantReceivable(object AContext, AFeesReceivableRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { // ChargeOption = { "Minimum", "Maximum", "Fixed", "Percentage" } // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } if (ARow.ChargeOption == "Percentage") { DataColumn ValidationColumn = ARow.Table.Columns[AFeesReceivableTable.ColumnChargePercentageId]; TValidationControlsData ValidationControlsData; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { decimal enteredValue = (ARow.IsChargePercentageNull() ? -1 : ARow.ChargePercentage); // If the user has cleared the value in the control, I'll treat it as -1. TVerificationResult VerificationResult = TNumericalChecks.IsPositiveDecimal(enteredValue, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } else // the ChargeOption relates to an amount { DataColumn ValidationColumn = ARow.Table.Columns[AFeesReceivableTable.ColumnChargeAmountId]; TValidationControlsData ValidationControlsData; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { decimal enteredValue = (ARow.IsChargeAmountNull() ? -1 : ARow.ChargeAmount); // If the user has cleared the value in the control, I'll treat it as -1. TVerificationResult VerificationResult = TNumericalChecks.IsPositiveDecimal(enteredValue, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } }
partial void ValidateFeesPayableListManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { Type DataTableType; AFeesReceivableTable otherTable = (AFeesReceivableTable)TCacheableTablesManager.GCacheableTablesManager.GetCachedDataTable( "FeesReceivableList", out DataTableType); otherTable.DefaultView.Sort = String.Format("{0}, {1} ASC", AFeesReceivableTable.GetLedgerNumberDBName(), AFeesReceivableTable.GetFeeCodeDBName()); for (int i = 0; i < ASubmitTable.Rows.Count; i++) { DataRow row = ASubmitTable.Rows[i]; if ((row.RowState == DataRowState.Added) || (row.RowState == DataRowState.Modified)) { string feeCode = row[AFeesPayableTable.ColumnFeeCodeId].ToString(); int ledgerNumber = Convert.ToInt32(row[AFeesPayableTable.ColumnLedgerNumberId]); int otherRowNum = otherTable.DefaultView.Find(new object[] { ledgerNumber, feeCode }); if (otherRowNum >= 0) { AFeesReceivableRow otherRow = (AFeesReceivableRow)(otherTable.DefaultView[otherRowNum].Row); string otherUser = otherRow.CreatedBy; if (!String.IsNullOrEmpty(otherRow.ModifiedBy)) { otherUser = otherRow.ModifiedBy; } // The message text doesn't get back to the user - but maybe one day it will throw new EDBConcurrencyException(String.Format(Catalog.GetString( "While you were editing this screen another user created a fee code '{0}' for the Grants Receivable screen. You will have to close and re-open the Grants Payable screen and make your changes again."), feeCode), "write", otherTable.TableName, otherUser, otherRow.ModificationId); } } } }
private void NewRowManual(ref AFeesReceivableRow ARow) { ARow.LedgerNumber = FLedgerNumber; string newName = Ict.Common.Catalog.GetString("NEWCODE"); Int32 countNewDetail = 0; if (FMainDS.AFeesReceivable.Rows.Find(new object[] { FLedgerNumber, newName }) != null) { while (FMainDS.AFeesReceivable.Rows.Find(new object[] { FLedgerNumber, newName + countNewDetail.ToString() }) != null) { countNewDetail++; } newName += countNewDetail.ToString(); } ARow.FeeCode = newName; ARow.AccountCode = MFinanceConstants.ADMIN_FEE_INCOME_ACCT.ToString(); ARow.DrAccountCode = MFinanceConstants.ADMIN_FEE_EXPENSE_ACCT.ToString(); }
/// <summary> /// /// </summary> /// <param name="AParameters"></param> public void SetControls(TParameterList AParameters) { // // If LedgerNumber hasn't been set yet, do nothing: if (FLedgerNumber < 0) { return; } AFeesReceivableTable FeesReceivable = new AFeesReceivableTable(); Type DataTableType; DataTable CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("FeesReceivableList", "Ledger", FLedgerNumber, out DataTableType); FeesReceivable.Merge(CacheDT); Array.Resize(ref FUnselectedFees, FeesReceivable.Rows.Count); for (Int32 Idx = 0; Idx < FeesReceivable.Rows.Count; Idx++) { AFeesReceivableRow Row = FeesReceivable[Idx]; FUnselectedFees[Idx] = Row.FeeCode; } AFeesPayableTable FeesPayable = new AFeesPayableTable(); CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("FeesPayableList", "Ledger", FLedgerNumber, out DataTableType); FeesPayable.Merge(CacheDT); Array.Resize(ref FUnselectedFees, FUnselectedFees.Length + FeesPayable.Rows.Count); for (Int32 Idx = 0; Idx < FeesPayable.Rows.Count; Idx++) { AFeesPayableRow Row = FeesPayable[Idx]; FUnselectedFees[FeesReceivable.Rows.Count + Idx] = Row.FeeCode; } String FeeStr = AParameters.Get("param_fee_codes").ToString(); // // If there's no fees selected, it's perhaps because the installation is new. // Add all the fees from the "Don't Print" box, up to the maximum number allowed. if (FeeStr == "") { Array.Resize(ref FSelectedFees, lstDontPrint.Items.Count); lstDontPrint.Items.CopyTo(FSelectedFees, 0); if (lstDontPrint.Items.Count > MAX_FEE_COUNT) { Array.Resize(ref FSelectedFees, MAX_FEE_COUNT); } } else { FSelectedFees = FeeStr.Split(','); } // Now I want to remove the selected items from the FSelectedFees list: for (Int32 Idx = 0; Idx < FSelectedFees.Length; Idx++) { Int32 pos = ((IList)FUnselectedFees).IndexOf(FSelectedFees[Idx]); if (pos >= 0) { Int32 NewLength = FUnselectedFees.Length - 1; for (Int32 i = pos; i < NewLength; i++) { FUnselectedFees[i] = FUnselectedFees[i + 1]; } Array.Resize(ref FUnselectedFees, NewLength); } } RefreshLists(); }