/// <summary> /// I need to find out whether the specified AccountCode can be allowed. /// </summary> private void GetDetailsFromControlsManual(GLSetupTDSAAccountRow ARow) { // // If changing the PrimaryKey to that specified causes a contraints error, // I'll catch it here, issue a warning, and return the control to the "safe" value. ProtectedChangeOfPrimaryKey(FCurrentAccount); }
private void AddNewAccount(Object sender, EventArgs e) { if (FCurrentAccount == null) { MessageBox.Show(Catalog.GetString("You can only add a new account after selecting a parent account")); return; } ValidateAllData(true, false); string newName = FNameForNewAccounts; Int32 countNewAccount = 0; if (FMainDS.AAccount.Rows.Find(new object[] { FLedgerNumber, newName }) != null) { while (FMainDS.AAccount.Rows.Find(new object[] { FLedgerNumber, newName + countNewAccount.ToString() }) != null) { countNewAccount++; } newName += countNewAccount.ToString(); } // ChangeAccountCodeValue() needs this value! strOldDetailAccountCode = newName; AAccountRow parentAccount = FCurrentAccount.AccountRow; GLSetupTDSAAccountRow newAccountRow = FMainDS.AAccount.NewRowTyped(); newAccountRow.AccountCode = newName; newAccountRow.LedgerNumber = FLedgerNumber; newAccountRow.AccountActiveFlag = true; newAccountRow.DebitCreditIndicator = parentAccount.DebitCreditIndicator; newAccountRow.AccountType = parentAccount.AccountType; newAccountRow.ValidCcCombo = parentAccount.ValidCcCombo; newAccountRow.PostingStatus = true; FMainDS.AAccount.Rows.Add(newAccountRow); AAccountHierarchyDetailRow hierarchyDetailRow = FMainDS.AAccountHierarchyDetail.NewRowTyped(); hierarchyDetailRow.LedgerNumber = FLedgerNumber; hierarchyDetailRow.AccountHierarchyCode = FSelectedHierarchy; hierarchyDetailRow.AccountCodeToReportTo = parentAccount.AccountCode; hierarchyDetailRow.ReportingAccountCode = newName; // change posting/summary flag of parent account if it was previously a leaf parentAccount.PostingStatus = false; // The parent is now a summary account! hierarchyDetailRow.ReportOrder = ucoAccountsTree.GetLastChildReportingOrder() + 1; FMainDS.AAccountHierarchyDetail.Rows.Add(hierarchyDetailRow); FIAmUpdating++; ShowDetails(newAccountRow); FIAmUpdating--; ucoAccountsTree.AddNewAccount(newAccountRow, hierarchyDetailRow); txtDetailAccountCode.Focus(); FPetraUtilsObject.SetChangedFlag(); }
/// <summary> /// Add this new account as child of the currently selected node /// </summary> public void AddNewAccount(GLSetupTDSAAccountRow AccountRow, AAccountHierarchyDetailRow HierarchyDetailRow) { trvAccounts.BeginUpdate(); TreeNode newNode = trvAccounts.SelectedNode.Nodes.Add(AccountRow.AccountCode); AccountNodeDetails NewAccount = AccountNodeDetails.AddNewAccount(newNode, AccountRow, HierarchyDetailRow); trvAccounts.EndUpdate(); FParentForm.SetSelectedAccount(NewAccount); }
/// <summary> /// Check that Foreign Currency Accounts are using a valid currency /// </summary> /// <param name="AContext">Context that describes what I'm validating.</param> /// <param name="ARow">DataRow with the the data I'm validating</param> /// <param name="AVerificationResultCollection">Will be filled with TVerificationResult items if data validation errors occur.</param> public static void ValidateAccountDetailManual(object AContext, GLSetupTDSAAccountRow ARow, ref TVerificationResultCollection AVerificationResultCollection) { // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } if (ARow.ForeignCurrencyFlag) { if ((ARow.AccountType != MFinanceConstants.ACCOUNT_TYPE_ASSET) && (ARow.AccountType != MFinanceConstants.ACCOUNT_TYPE_LIABILITY)) { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnAccountTypeId]; TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, string.Format(Catalog.GetString("A foreign currency account's Account Type must be either '{0}' or '{1}'."), MFinanceConstants.ACCOUNT_TYPE_ASSET, MFinanceConstants.ACCOUNT_TYPE_LIABILITY), TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } if (!ARow.PostingStatus) { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnPostingStatusId]; TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, Catalog.GetString("A foreign currency account must be a posting account; it cannot be a summary account."), TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } // If this account is foreign, its currency must be assigned! if (ARow.ForeignCurrencyCode == "") { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]; TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, Catalog.GetString("Currency Code must be specified for foreign accounts."), TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } } else // If the Account is not foreign, I have nothing at all to say about the contents of the currency field. { AVerificationResultCollection.AddOrRemove(null, ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]); } }
private void ValidateDataDetailsManual(GLSetupTDSAAccountRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedFinanceValidation_Setup.ValidateAccountDetailManual( this, ARow, ref VerificationResultCollection, FPetraUtilsObject.ValidationControlsDict); }
private DataTable GetAccountListTable(TDBTransaction AReadTransaction, System.Int32 ALedgerNumber, string ATableName) { StringCollection FieldList = new StringCollection(); FieldList.Add(AAccountTable.GetLedgerNumberDBName()); FieldList.Add(AAccountTable.GetAccountCodeDBName()); FieldList.Add(AAccountTable.GetAccountTypeDBName()); FieldList.Add(AAccountTable.GetAccountCodeShortDescDBName()); FieldList.Add(AAccountTable.GetAccountActiveFlagDBName()); FieldList.Add(AAccountTable.GetPostingStatusDBName()); FieldList.Add(AAccountTable.GetForeignCurrencyFlagDBName()); FieldList.Add(AAccountTable.GetForeignCurrencyCodeDBName()); GLSetupTDS TempDS = new GLSetupTDS(); AAccountAccess.LoadViaALedger(TempDS, ALedgerNumber, FieldList, AReadTransaction); // load AAccountProperty and set the BankAccountFlag AAccountPropertyAccess.LoadViaALedger(TempDS, ALedgerNumber, AReadTransaction); foreach (AAccountPropertyRow accProp in TempDS.AAccountProperty.Rows) { if ((accProp.PropertyCode == MFinanceConstants.ACCOUNT_PROPERTY_BANK_ACCOUNT) && (accProp.PropertyValue == "true")) { TempDS.AAccount.DefaultView.RowFilter = String.Format("{0}='{1}'", AAccountTable.GetAccountCodeDBName(), accProp.AccountCode); GLSetupTDSAAccountRow acc = (GLSetupTDSAAccountRow)TempDS.AAccount.DefaultView[0].Row; acc.BankAccountFlag = true; TempDS.AAccount.DefaultView.RowFilter = ""; } } // not currently needed as an Account is only a Bank Account if it has a 'Bank Account' Account Property // load AAccountHierarchyDetails and check if this account reports to the CASH account /*AAccountHierarchyDetailAccess.LoadViaAAccountHierarchy(TempDS, * ALedgerNumber, * MFinanceConstants.ACCOUNT_HIERARCHY_STANDARD, * AReadTransaction); * * TLedgerInfo ledgerInfo = new TLedgerInfo(ALedgerNumber); * TGetAccountHierarchyDetailInfo accountHierarchyTools = new TGetAccountHierarchyDetailInfo(ledgerInfo); * List <string>children = accountHierarchyTools.GetChildren(MFinanceConstants.CASH_ACCT); * * foreach (GLSetupTDSAAccountRow account in TempDS.AAccount.Rows) * { * if (children.Contains(account.AccountCode)) * { * account.CashAccountFlag = true; * } * }*/ return(TempDS.AAccount); }
private void ShowDetailsManual(GLSetupTDSAAccountRow ARow) { if (ARow != null) { strOldDetailAccountCode = txtDetailAccountCode.Text; ucoAccountAnalysisAttributes.Enabled = ARow.PostingStatus; // This call to an external user control resets change detection suppression so we need to re-enable it ucoAccountAnalysisAttributes.AccountCode = ARow.AccountCode; FPetraUtilsObject.DisableDataChangedEvent(); chkDetailForeignCurrencyFlag.Enabled = (ARow.PostingStatus && !ARow.SystemAccountFlag); chkDetailBankAccountFlag.Enabled = !ARow.SystemAccountFlag; chkDetailBudgetControlFlag.Enabled = !ARow.SystemAccountFlag && FMainDS.ALedger[0].BudgetControlFlag; lblDetailBudgetControlFlag.Enabled = FMainDS.ALedger[0].BudgetControlFlag; cmbDetailForeignCurrencyCode.Enabled = (ARow.PostingStatus && !ARow.SystemAccountFlag && ARow.ForeignCurrencyFlag); chkDetailIsSummary.Checked = !ARow.PostingStatus; chkDetailIsSummary.Enabled = !ARow.SystemAccountFlag; // // Reporting Order is in AAccountHierarchyDetail FMainDS.AAccountHierarchyDetail.DefaultView.RowFilter = String.Format("{0}='{1}'", AAccountHierarchyDetailTable.GetReportingAccountCodeDBName(), ARow.AccountCode); String txtReportingOrder = ""; if (FMainDS.AAccountHierarchyDetail.DefaultView.Count > 0) { txtReportingOrder = ((AAccountHierarchyDetailRow)FMainDS.AAccountHierarchyDetail.DefaultView[0].Row).ReportOrder.ToString(); } txtRptOrder.Text = txtReportingOrder; // txtRptOrder.Enabled = !ARow.SystemAccountFlag; if (!ARow.ForeignCurrencyFlag) { cmbDetailForeignCurrencyCode.SelectedIndex = -1; ARow.ForeignCurrencyCode = ""; } chkDetailAccountActiveFlag.Enabled = !ARow.SystemAccountFlag; // I allow the user to attempt to change the primary key, // but if the selected record is not new, AND they have made any other changes, // the txtDetailAccountCode _TextChanged method will disallow any change. SetPrimaryKeyReadOnly(false); btnRename.Visible = false; } }
private void InsertNodeIntoTreeView(GLSetupTDS MainDS, Int32 LedgerNumber, TreeNode AParent, DataView view, AAccountHierarchyDetailRow ADetailRow) { GLSetupTDSAAccountRow AccountRow = (GLSetupTDSAAccountRow)MainDS.AAccount.Rows.Find( new object[] { LedgerNumber, ADetailRow.ReportingAccountCode }); TreeNode Child = new TreeNode(); AccountNodeDetails NodeTag = AccountNodeDetails.AddNewAccount(Child, AccountRow, ADetailRow); NodeTag.IsNew = (ADetailRow.RowState == DataRowState.Added); SetNodeLabel(AccountRow, Child); if (AParent == null) { trvAccounts.Nodes.Add(Child); } else { InsertInOrder(AParent, Child); } // Now add the children of this node: view.RowFilter = AAccountHierarchyDetailTable.GetAccountHierarchyCodeDBName() + " = '" + ADetailRow.AccountHierarchyCode + "' AND " + AAccountHierarchyDetailTable.GetAccountCodeToReportToDBName() + " = '" + ADetailRow.ReportingAccountCode + "'"; if (view.Count > 0) { // An account cannot be deleted if it has children. NodeTag.CanDelete = false; NodeTag.Msg = Catalog.GetString("Child accounts must be deleted first."); NodeTag.CanHaveChildren = true; foreach (DataRowView rowView in view) { AAccountHierarchyDetailRow accountDetail = (AAccountHierarchyDetailRow)rowView.Row; InsertNodeIntoTreeView(MainDS, LedgerNumber, Child, view, accountDetail); } } }
/// <summary> /// Check that Foreign Currency Accounts are using a valid currency /// </summary> /// <param name="AContext">Context that describes what I'm validating.</param> /// <param name="ARow">DataRow with the the data I'm validating</param> /// <param name="AVerificationResultCollection">Will be filled with TVerificationResult items if data validation errors occur.</param> /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that /// display data that is about to be validated.</param> public static void ValidateAccountDetailManual(object AContext, GLSetupTDSAAccountRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } TValidationControlsData ValidationControlsData; // If this account is foreign, its currency must be assigned! if (ARow.ForeignCurrencyFlag) { if (ARow.ForeignCurrencyCode == "") { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]; Control targetControl = null; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { targetControl = ValidationControlsData.ValidationControl; } TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, Catalog.GetString("Currency Code must be specified for foreign accounts."), targetControl, TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } else // If the Account is not foreign, I have nothing at all to say about the contents of the currency field. { AVerificationResultCollection.AddOrRemove(null, ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]); } }
/// <summary> /// Check that Foreign Currency Accounts are using a valid currency /// </summary> /// <param name="AContext">Context that describes what I'm validating.</param> /// <param name="ARow">DataRow with the the data I'm validating</param> /// <param name="AVerificationResultCollection">Will be filled with TVerificationResult items if data validation errors occur.</param> /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that /// display data that is about to be validated.</param> public static void ValidateAccountDetailManual(object AContext, GLSetupTDSAAccountRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } TValidationControlsData ValidationControlsData; if (ARow.ForeignCurrencyFlag) { if ((ARow.AccountType != MFinanceConstants.ACCOUNT_TYPE_ASSET) && (ARow.AccountType != MFinanceConstants.ACCOUNT_TYPE_LIABILITY)) { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnAccountTypeId]; Control targetControl = null; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { targetControl = ValidationControlsData.ValidationControl; } TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, string.Format(Catalog.GetString("A foreign currency account's Account Type must be either '{0}' or '{1}'."), MFinanceConstants.ACCOUNT_TYPE_ASSET, MFinanceConstants.ACCOUNT_TYPE_LIABILITY), targetControl, TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } if (!ARow.PostingStatus) { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnPostingStatusId]; Control targetControl = null; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { targetControl = ValidationControlsData.ValidationControl; } TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, Catalog.GetString("A foreign currency account must be a posting account; it cannot be a summary account."), targetControl, TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // If this account is foreign, its currency must be assigned! if (ARow.ForeignCurrencyCode == "") { DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]; Control targetControl = null; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { targetControl = ValidationControlsData.ValidationControl; } TScreenVerificationResult VerificationResult = new TScreenVerificationResult( AContext, ValidationColumn, Catalog.GetString("Currency Code must be specified for foreign accounts."), targetControl, TResultSeverity.Resv_Critical); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } else // If the Account is not foreign, I have nothing at all to say about the contents of the currency field. { AVerificationResultCollection.AddOrRemove(null, ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]); } }
/// <summary> /// Create an AccountNodeDetails object for this account /// </summary> public static AccountNodeDetails AddNewAccount(TreeNode NewTreeNode, GLSetupTDSAAccountRow AccountRow, AAccountHierarchyDetailRow HierarchyDetailRow) { AccountNodeDetails NodeDetails = new AccountNodeDetails(); NodeDetails.CanHaveChildren = true; if (AccountRow.PostingStatus) // A "Posting account" that's not been used may yet be promoted to a "Summary account". { NodeDetails.CanHaveChildren = null; } else // A "Summary account" can have children. { NodeDetails.CanHaveChildren = true; } NodeDetails.IsNew = true; NodeDetails.DetailRow = HierarchyDetailRow; NodeDetails.AccountRow = AccountRow; NewTreeNode.Tag = NodeDetails; NodeDetails.linkedTreeNode = NewTreeNode; return NodeDetails; }
/// <summary> /// The implementation of the logic for testing for a matching row /// </summary> /// <param name="ARow">The Row to test</param> /// <returns>True for a match</returns> public bool IsMatchingRowManual(DataRow ARow) { string strAccountCode = FFindTxtAccountCode.Text.ToLower(); string strAccountType = FFindCmbAccountType.Text.ToLower(); string strAccountDescrEnglish = FFindTxtDescrEnglish.Text.ToLower(); string strAccountDescrLocal = FFindTxtDescrLocal.Text.ToLower(); bool isBankAccount = FFindChkBankAccount.Checked; bool isActive = FFindChkActive.Checked; bool isSummary = FFindChkSummary.Checked; bool isForeign = FFindChkForeign.Checked; GLSetupTDSAAccountRow accountRow = (GLSetupTDSAAccountRow)ARow; if (strAccountCode != String.Empty) { if (!accountRow.AccountCode.ToLower().Contains(strAccountCode)) { return(false); } } if (strAccountType != String.Empty) { if (!accountRow.AccountType.ToLower().Contains(strAccountType)) { return(false); } } if (strAccountDescrEnglish != String.Empty) { if (!accountRow.EngAccountCodeLongDesc.ToLower().Contains(strAccountDescrEnglish)) { return(false); } } if (strAccountDescrLocal != String.Empty) { if (!accountRow.AccountCodeLongDesc.ToLower().Contains(strAccountDescrLocal)) { return(false); } } if (FFindChkBankAccount.CheckState != CheckState.Indeterminate) { if (accountRow.BankAccountFlag != isBankAccount) { return(false); } } if (FFindChkActive.CheckState != CheckState.Indeterminate) { if (accountRow.AccountActiveFlag != isActive) { return(false); } } if (FFindChkSummary.CheckState != CheckState.Indeterminate) { if (accountRow.PostingStatus == isSummary) { return(false); } } if (FFindChkForeign.CheckState != CheckState.Indeterminate) { if (accountRow.ForeignCurrencyFlag != isActive) { return(false); } } return(true); }