/// <summary> /// Populates the Cost Centre, Account Code and DR Account Code ComboBoxes. /// </summary> /// <param name="ACostCentreComboBox">Cost Centre ComboBox Control</param> /// <param name="AAccountCodeComboBox">Account Code ComboBox Control</param> /// <param name="ADrAccountCodeComboBox">DR Account Code ComboBox Control</param> /// <param name="ALedgerNumber">Ledger Number</param> /// <param name="ACalledByReceivableScreen">Set this to true if the 'Admin Grants Receivable' screen is calling this Method.</param> public static void PopulateComboBoxes(TCmbAutoPopulated ACostCentreComboBox, TCmbAutoPopulated AAccountCodeComboBox, TCmbAutoPopulated ADrAccountCodeComboBox, Int32 ALedgerNumber, bool ACalledByReceivableScreen) { string filter = String.Empty; DataTable CostCentreListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, ALedgerNumber); CostCentreListTable.DefaultView.Sort = ACostCentreTable.GetCostCentreNameDBName() + " ASC"; if (ACalledByReceivableScreen) { filter = ACostCentreTable.GetPostingCostCentreFlagDBName() + " = true AND " + ACostCentreTable.GetCostCentreTypeDBName() + " = 'Local'"; } else { filter = ACostCentreTable.GetPostingCostCentreFlagDBName() + " = true"; } ACostCentreComboBox.InitialiseUserControl(CostCentreListTable, ACostCentreTable.GetCostCentreCodeDBName(), ACostCentreTable.GetCostCentreNameDBName(), null); ACostCentreComboBox.AppearanceSetup(new int[] { -1, 300 }, 20); ACostCentreComboBox.Filter = filter; DataTable AccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber); AccountListTable.DefaultView.Sort = AAccountTable.GetAccountCodeDBName() + " ASC"; filter = AAccountTable.GetPostingStatusDBName() + " = true AND " + AAccountTable.GetAccountTypeDBName().ToUpper() + " = 'INCOME'"; AAccountCodeComboBox.InitialiseUserControl(AccountListTable, AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null); AAccountCodeComboBox.AppearanceSetup(new int[] { -1, 300 }, 20); AAccountCodeComboBox.Filter = filter; DataTable DrAccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber); DrAccountListTable.DefaultView.Sort = AAccountTable.GetAccountCodeDBName() + " ASC"; filter = AAccountTable.GetPostingStatusDBName() + " = true AND " + AAccountTable.GetAccountTypeDBName().ToUpper() + " = 'EXPENSE'"; ADrAccountCodeComboBox.InitialiseUserControl(DrAccountListTable, AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null); ADrAccountCodeComboBox.AppearanceSetup(new int[] { -1, 300 }, 20); ADrAccountCodeComboBox.Filter = filter; }
/// <summary> /// Equity accounts are any and all posting accounts that have a_account_type_c == 'Equity' /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> public static void InitialiseRetEarningsAccountAccountList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber) { AAccountTable Account = (AAccountTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber); Account.DefaultView.RowFilter = "a_posting_status_l=TRUE AND a_account_type_c='Equity'"; Account.DefaultView.Sort = "a_account_code_c"; DataTable Options = Account.DefaultView.ToTable(); AControl.InitialiseUserControl(Options, "a_account_code_c", "a_account_code_short_desc_c", null); }
/// <summary> /// Clearing accounts are any and all posting accounts that are descendants of 8500S /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AAccountHierarchyCode"></param> public static void InitialiseClearingAccountList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, String AAccountHierarchyCode) { GLSetupTDS DS = TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(ALedgerNumber); DS.AAccount.DefaultView.Sort = "a_account_code_c"; DS.AAccountHierarchyDetail.DefaultView.RowFilter = "a_ledger_number_i=" + ALedgerNumber + " AND a_account_hierarchy_code_c='" + AAccountHierarchyCode + "'"; DS.AAccountHierarchyDetail.DefaultView.Sort = "a_reporting_account_code_c"; DataTable Options = new DataTable(); Options.Columns.Add("AccountCode", typeof(String)); Options.Columns.Add("AccountDescr", typeof(String)); foreach (DataRowView rv in DS.AAccountHierarchyDetail.DefaultView) { AAccountHierarchyDetailRow Row = (AAccountHierarchyDetailRow)rv.Row; if (AccountIsDescendantOf(DS.AAccountHierarchyDetail.DefaultView, "8500S", Row)) { // // This account is a descendant of 8500S. I also require it to be a Posting Account. Int32 Idx = DS.AAccount.DefaultView.Find(Row.ReportingAccountCode); if (Idx >= 0) { AAccountRow Account = (AAccountRow)DS.AAccount.DefaultView[Idx].Row; if (Account.PostingStatus == true) { DataRow NewRow = Options.NewRow(); NewRow["AccountCode"] = Account.AccountCode; NewRow["AccountDescr"] = Account.AccountCodeShortDesc; Options.Rows.Add(NewRow); } } } } AControl.InitialiseUserControl(Options, "AccountCode", "AccountDescr", null); }
/// <summary> /// Fill combobox values with account codes /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="APostingOnly"></param> /// <param name="AExcludePosting"></param> /// <param name="AActiveOnly"></param> /// <param name="ABankAccountOnly"></param> /// <param name="AForeignCurrencyName">If a value is defined, only base curreny or the defined currency are filtered</param> /// <param name="AIndicateInactive">Determines wether or not to indicate an account code as inactive</param> /// <param name="AAAccountListDataSource">If a reference to the AAccountList is available, pass it here. Otherwise the method /// will get it from the data cache.</param> public static void InitialiseAccountList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, bool APostingOnly, bool AExcludePosting, bool AActiveOnly, bool ABankAccountOnly, string AForeignCurrencyName, bool AIndicateInactive = false, DataTable AAAccountListDataSource = null) { DataTable Table; if (AAAccountListDataSource == null) { Table = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber); } else { Table = AAAccountListDataSource.Copy(); } //Highlight inactive Accounts if (!AActiveOnly && AIndicateInactive) { foreach (DataRow rw in Table.Rows) { if ((rw[AAccountTable.ColumnAccountActiveFlagId] != null) && (rw[AAccountTable.ColumnAccountActiveFlagId].ToString() == "False")) { rw[AAccountTable.ColumnAccountCodeShortDescId] = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + rw[AAccountTable.ColumnAccountCodeShortDescId]; } } } AControl.InitialiseUserControl(Table, AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); AControl.Filter = PrepareAccountFilter(APostingOnly, AExcludePosting, AActiveOnly, ABankAccountOnly, AForeignCurrencyName); // We set the initial index to -1 because we always want to force the user to make a positive choice AControl.SelectedIndex = -1; }
/// <summary> /// fill combobox values with list of transaction types /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="ASubSystemCode"></param> public static void InitialiseTransactionTypeList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, string ASubSystemCode) { // TODO: use cached table for transaction types? use filter to get only appropriate types for subsystem? TTypedDataTable Table; TRemote.MCommon.DataReader.WebConnectors.GetData(TTypedDataTable.GetTableNameSQL(ATransactionTypeTable.TableId), new TSearchCriteria[] { new TSearchCriteria(TTypedDataTable.GetColumnNameSQL(ATransactionTypeTable.TableId, ATransactionTypeTable.ColumnLedgerNumberId), ALedgerNumber), new TSearchCriteria(TTypedDataTable.GetColumnNameSQL(ATransactionTypeTable.TableId, ATransactionTypeTable.ColumnSubSystemCodeId), ASubSystemCode) }, out Table); AControl.InitialiseUserControl( Table, ATransactionTypeTable.GetTransactionTypeCodeDBName(), ATransactionTypeTable.GetTransactionTypeDescriptionDBName(), null); AControl.AppearanceSetup(new int[] { -1, 150 }, -1); }
/// <summary> /// Sets up the value cell(s) for a specific data label /// /// </summary> /// <returns>void</returns> private void SetupGridValueCell(Int32 ARowIndex, PDataLabelRow ADataLabelRow) { Control cellControl; System.Windows.Forms.TextBox TextBoxEditor; TtxtPetraDate DateEditor; System.Windows.Forms.CheckBox CheckBoxEditor; TTxtNumericTextBox TextBoxNumericEditor; TTxtCurrencyTextBox TextBoxCurrencyEditor; TCmbAutoPopulated LookupValueEditor; TtxtAutoPopulatedButtonLabel PartnerKeyEditor; SourceGrid.Cells.Views.Cell ValueModel; SourceGrid.Cells.Views.Cell SuffixModel; PDataLabelValuePartnerRow DataLabelValuePartnerRow; PDataLabelValueApplicationRow DataLabelValueApplicationRow; // prepare model for the value cells ValueModel = new SourceGrid.Cells.Views.Cell(); ValueModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; ValueModel.Font = new Font(FLocalDataLabelValuesGrid.Font.FontFamily.Name, FLocalDataLabelValuesGrid.Font.Size, FontStyle.Bold); // prepare model for suffix cells (e.g. for currency) SuffixModel = new SourceGrid.Cells.Views.Cell(); SuffixModel.BackColor = FLocalDataLabelValuesGrid.BackColor; SuffixModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; // In this case the data value rows will only be created once a value is entered GetOrCreateDataLabelValueRow(false, ADataLabelRow, out DataLabelValuePartnerRow, out DataLabelValueApplicationRow); // initialize cell control cellControl = null; // Create field, according to specified data type // Create character field if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CHAR) { TextBoxEditor = new System.Windows.Forms.TextBox(); cellControl = TextBoxEditor; if (DataLabelValuePartnerRow != null) { TextBoxEditor.Text = DataLabelValuePartnerRow.ValueChar; } else if (DataLabelValueApplicationRow != null) { TextBoxEditor.Text = DataLabelValueApplicationRow.ValueChar; } else { // Default value if no Label data exists for the Partner TextBoxEditor.Text = ""; } // enable save button in editor when cell contents have changed TextBoxEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxEditor; } // Create float field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_FLOAT) { TextBoxNumericEditor = new TTxtNumericTextBox(); if (ADataLabelRow.NumDecimalPlaces == 0) { TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.LongInteger; TextBoxNumericEditor.MaxLength = 14; } else { TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Decimal; TextBoxNumericEditor.DecimalPlaces = ADataLabelRow.NumDecimalPlaces; // limit text length. 14 for number of digits, 5 for decimal and thousands separators TextBoxNumericEditor.MaxLength = 14 + 5 + ADataLabelRow.NumDecimalPlaces; } TextBoxNumericEditor.NullValueAllowed = true; cellControl = TextBoxNumericEditor; if (ADataLabelRow.NumDecimalPlaces == 0) { if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValuePartnerRow.ValueNum; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValueApplicationRow.ValueNum; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueLongInt = null; } } else { if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueNum; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueNum; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueDecimal = null; } } // enable save button in editor when cell contents have changed TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor; } // Create data field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_DATE) { DateEditor = new TtxtPetraDate(); DateEditor.Date = null; cellControl = DateEditor; if (DataLabelValuePartnerRow != null) { if (!DataLabelValuePartnerRow.IsValueDateNull()) { DateEditor.Date = DataLabelValuePartnerRow.ValueDate; } } else if (DataLabelValueApplicationRow != null) { if (!DataLabelValueApplicationRow.IsValueDateNull()) { DateEditor.Date = DataLabelValueApplicationRow.ValueDate; } } // enable save button in editor when cell contents have changed DateEditor.DateChanged += new TPetraDateChangedEventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)DateEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = DateEditor; } // Create integer field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_INTEGER) { TextBoxNumericEditor = new TTxtNumericTextBox(); TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Integer; TextBoxNumericEditor.NullValueAllowed = true; cellControl = TextBoxNumericEditor; if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueInt = DataLabelValuePartnerRow.ValueInt; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueInt = DataLabelValueApplicationRow.ValueInt; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueInt = null; } // enable save button in editor when cell contents have changed TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor; } // Create currency field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CURRENCY) { TextBoxCurrencyEditor = new TTxtCurrencyTextBox(); TextBoxCurrencyEditor.DecimalPlaces = 2; TextBoxCurrencyEditor.CurrencyCode = ADataLabelRow.CurrencyCode; TextBoxCurrencyEditor.NullValueAllowed = true; cellControl = TextBoxCurrencyEditor; if (DataLabelValuePartnerRow != null) { TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueCurrency; } else if (DataLabelValueApplicationRow != null) { TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueCurrency; } else { // Default value if no Label data exists for the Partner TextBoxCurrencyEditor.NumberValueDecimal = null; } // enable save button in editor when cell contents have changed TextBoxCurrencyEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxCurrencyEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxCurrencyEditor; } // Create boolean field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_BOOLEAN) { CheckBoxEditor = new System.Windows.Forms.CheckBox(); cellControl = CheckBoxEditor; if (DataLabelValuePartnerRow != null) { CheckBoxEditor.Checked = DataLabelValuePartnerRow.ValueBool; } else if (DataLabelValueApplicationRow != null) { CheckBoxEditor.Checked = DataLabelValueApplicationRow.ValueBool; } else { // Default value if no Label data exists for the Partner CheckBoxEditor.Checked = false; } // enable save button in editor when cell contents have changed CheckBoxEditor.CheckedChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)CheckBoxEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = CheckBoxEditor; } // Create partner key field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_PARTNERKEY) { PartnerKeyEditor = new TtxtAutoPopulatedButtonLabel(); PartnerKeyEditor.ASpecialSetting = true; PartnerKeyEditor.ButtonText = ADataLabelRow.Text + ':'; PartnerKeyEditor.ButtonTextAlign = System.Drawing.ContentAlignment.MiddleRight; PartnerKeyEditor.ListTable = TtxtAutoPopulatedButtonLabel.TListTableEnum.PartnerKey; PartnerKeyEditor.TabStop = false; cellControl = PartnerKeyEditor; // AutomaticallyUpdateDataSource: very rare, but needed here PartnerKeyEditor.AutomaticallyUpdateDataSource = true; if (DataLabelValuePartnerRow != null) { PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValuePartnerRow.ValuePartnerKey); } else if (DataLabelValueApplicationRow != null) { PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValueApplicationRow.ValuePartnerKey); } else { // Default value if no Label data exists for the Partner PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(0); } // display partner name linked to partner key PartnerKeyEditor.ResetLabelText(); // enable save button in editor when cell contents have changed PartnerKeyEditor.ValueChanged += new TDelegatePartnerChanged(this.PartnerKeyControlValueHasChanged); PartnerKeyEditor.TextChanged += new System.EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 0] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue(PartnerKeyEditor, new Position(ARowIndex, 0))); FLocalDataLabelValuesGrid[ARowIndex, 0].Tag = PartnerKeyEditor; FLocalDataLabelValuesGrid[ARowIndex, 0].ColumnSpan = 3; } // Create lookup field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_LOOKUP) { // Get the instance of the combobox (created in the actual user interface class) LookupValueEditor = new TCmbAutoPopulated(); LookupValueEditor.Filter = PDataLabelLookupTable.GetCategoryCodeDBName() + " = '" + ADataLabelRow.LookupCategoryCode + "'"; LookupValueEditor.ListTable = TCmbAutoPopulated.TListTableEnum.DataLabelLookupList; LookupValueEditor.InitialiseUserControl(); cellControl = LookupValueEditor; if (DataLabelValuePartnerRow != null) { LookupValueEditor.SetSelectedString(DataLabelValuePartnerRow.ValueLookup); } else if (DataLabelValueApplicationRow != null) { LookupValueEditor.SetSelectedString(DataLabelValueApplicationRow.ValueLookup); } else { // Default value if no Label data exists for the Partner LookupValueEditor.Text = ""; } // enable save button in editor when cell contents have changed LookupValueEditor.SelectedValueChanged += new EventHandler(this.ControlValueHasChanged); LookupValueEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)LookupValueEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = LookupValueEditor; FLocalDataLabelValuesGrid[ARowIndex, 1].ColumnSpan = 2; } // perform actions that need to be done for each control if (cellControl != null) { // remember the added control to get the value back lateron FGridRowInfo.SetControl(ARowIndex, cellControl); // handle focus change when field is entered cellControl.Enter += new EventHandler(this.UpdateGridFocusFromExternalControl); // set help text for control PetraUtilsObject.SetStatusBarText(cellControl, ADataLabelRow.Description); } // check if value is editable if (!ADataLabelRow.Editable) { FLocalDataLabelValuesGrid[ARowIndex, 1].Editor.EnableEdit = false; } }
/// <summary> /// fill combobox values with the mailing codes /// </summary> /// <param name="AControl"></param> /// <param name="AActiveOnly"></param> public static void InitialisePMailingList(ref TCmbAutoPopulated AControl, bool AActiveOnly) { DataTable Table = TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.MailingList); // We need to add a row to the table that has a NULL value // We don't want to change the 'real' data table so we make a copy first Table = Table.Copy(); // Allow NULL for the code in this table Table.Columns[PMailingTable.ColumnMailingCodeId].AllowDBNull = true; // Now add the row DataRow Dr = Table.NewRow(); Dr[PMailingTable.GetMailingCodeDBName()] = DBNull.Value; Dr[PMailingTable.GetMailingDescriptionDBName()] = String.Empty; Table.Rows.InsertAt(Dr, 0); // Now use this table for the ComboBox data source AControl.InitialiseUserControl(Table, PMailingTable.GetMailingCodeDBName(), PMailingTable.GetMailingDescriptionDBName(), null); AControl.AppearanceSetup(new int[] { -1, 150 }, -1); if (AActiveOnly) { AControl.Filter = String.Format("({0}=true) OR ({1} IS NULL)", PMailingTable.GetViewableDBName(), PMailingTable.GetMailingCodeDBName()); //TODO Add viewable until and date comparison } else { AControl.Filter = ""; } }
/// <summary> /// fill combobox values with motivation detail list /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AActiveOnly"></param> public static void InitialiseMotivationDetailList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, bool AActiveOnly) { DataTable detailTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationList, ALedgerNumber); AControl.InitialiseUserControl(detailTable, AMotivationDetailTable.GetMotivationDetailCodeDBName(), AMotivationDetailTable.GetMotivationDetailDescDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); if (AActiveOnly) { AControl.Filter = AMotivationDetailTable.GetMotivationStatusDBName() + " = true"; } else { AControl.Filter = string.Empty; } }
/// <summary> /// This function fills the available financial years of a given ledger into a TCmbAutoPopulated combobox /// </summary> public static void InitialiseAvailableFinancialYearsListHOSA(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, Boolean AIncludeNextYear = false) { string DisplayMember; string ValueMember; string DescriptionMember; DataTable Table = TRemote.MFinance.GL.WebConnectors.GetAvailableGLYearsHOSA(ALedgerNumber, out DisplayMember, out ValueMember, out DescriptionMember); Table.DefaultView.Sort = ValueMember + " DESC"; AControl.InitialiseUserControl(Table, ValueMember, DisplayMember, DescriptionMember, null); AControl.AppearanceSetup(new int[] { 100, 150 }, -1); if (Table.DefaultView.Count > 0) { AControl.SelectedIndex = 0; } }
/// <summary> /// This function fills the available financial years of a given ledger into a TCmbAutoPopulated combobox /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AIncludeNextYear"></param> /// <param name="AShowYearEnds"></param> public static void InitialiseAvailableFinancialYearsList(ref TCmbAutoPopulated AControl, System.Int32 ALedgerNumber, bool AIncludeNextYear = false, bool AShowYearEnds = false) { string DisplayMember; string ValueMember; DataTable Table = null; if (AShowYearEnds) { Table = TRemote.MFinance.GL.WebConnectors.GetAvailableGLYearEnds(ALedgerNumber, 0, AIncludeNextYear, out DisplayMember, out ValueMember); } else { Table = TRemote.MFinance.GL.WebConnectors.GetAvailableGLYears(ALedgerNumber, 0, AIncludeNextYear, out DisplayMember, out ValueMember); } Table.DefaultView.Sort = ValueMember + " DESC"; AControl.InitialiseUserControl(Table, ValueMember, DisplayMember, null, null); AControl.SelectedIndex = 0; AControl.AppearanceSetup(new int[] { -1 }, -1); }
/// <summary> /// This function fills the available financial years of a given ledger into a TCmbAutoPopulated combobox /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNr"></param> public static void InitialiseAvailableGiftYearsList(ref TCmbAutoPopulated AControl, System.Int32 ALedgerNr) { string DisplayMember; string ValueMember; DataTable Table = TRemote.MFinance.Gift.WebConnectors.GetAvailableGiftYears(ALedgerNr, out DisplayMember, out ValueMember); Table.DefaultView.Sort = ValueMember + " DESC"; AControl.InitialiseUserControl(Table, ValueMember, DisplayMember, null, null); AControl.SelectedIndex = 0; AControl.AppearanceSetup(new int[] { -1 }, -1); }
/// <summary> /// This function fills the combobox for the key ministry depending on the partnerkey /// </summary> /// <param name="ACmbKeyMinistry"></param> /// <param name="APartnerKey"></param> /// <param name="AFieldNumber"></param> /// <param name="ARefreshData"></param> private static void GetRecipientData(ref TCmbAutoPopulated ACmbKeyMinistry, Int64 APartnerKey, out Int64 AFieldNumber, Boolean ARefreshData = false) { string CurrentRowFilter = string.Empty; AFieldNumber = 0; if ((FKeyMinTable != null) && !ARefreshData) { if (FindAndSelect(ref ACmbKeyMinistry, APartnerKey)) { return; } } else if ((FKeyMinTable != null) && ARefreshData) { FKeyMinTable.Clear(); FKeyMinTable = null; } string DisplayMember = PUnitTable.GetUnitNameDBName(); string ValueMember = PUnitTable.GetPartnerKeyDBName(); try { FKeyMinTable = TRemote.MFinance.Gift.WebConnectors.LoadKeyMinistry(APartnerKey, out FFieldNumber); AFieldNumber = FFieldNumber; CurrentRowFilter = FKeyMinTable.DefaultView.RowFilter; FKeyMinTable.DefaultView.RowFilter = String.Format("{0}='{1}'", PUnitTable.GetUnitTypeCodeDBName(), MPartnerConstants.UNIT_TYPE_KEYMIN); FKeyMinTable.DefaultView.Sort = DisplayMember + " Desc"; DataTable dt = FKeyMinTable.DefaultView.ToTable(); ACmbKeyMinistry.InitialiseUserControl(dt, ValueMember, DisplayMember, DisplayMember, null); ACmbKeyMinistry.AppearanceSetup(new int[] { 500 }, -1); if (!FindAndSelect(ref ACmbKeyMinistry, APartnerKey)) { //Clear the combobox ACmbKeyMinistry.SelectedIndex = -1; } } finally { FKeyMinTable.DefaultView.RowFilter = CurrentRowFilter; } }
/// <summary> /// fill combobox values with motivation group list /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AActiveOnly"></param> public static void InitialiseMotivationGroupList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, bool AActiveOnly) { DataTable groupTable = (AMotivationGroupTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationGroupList, ALedgerNumber); AControl.InitialiseUserControl(groupTable, AMotivationGroupTable.GetMotivationGroupCodeDBName(), AMotivationGroupTable.GetMotivationGroupDescriptionDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); }
/// <summary> /// fill combobox values with list of transaction types /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="ASubSystemCode"></param> public static void InitialiseTransactionTypeList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, string ASubSystemCode) { TTypedDataTable Table; TRemote.MCommon.DataReader.WebConnectors.GetData(TTypedDataTable.GetTableNameSQL(ATransactionTypeTable.TableId), new TSearchCriteria[] { new TSearchCriteria(TTypedDataTable.GetColumnNameSQL(ATransactionTypeTable.TableId, ATransactionTypeTable.ColumnLedgerNumberId), ALedgerNumber), new TSearchCriteria(TTypedDataTable.GetColumnNameSQL(ATransactionTypeTable.TableId, ATransactionTypeTable.ColumnSubSystemCodeId), ASubSystemCode) }, out Table); // // REVAL is not to be offered to the user as an option: Table.DefaultView.RowFilter = "a_transaction_type_code_c <> 'REVAL'"; AControl.InitialiseUserControl( Table.DefaultView.ToTable(), ATransactionTypeTable.GetTransactionTypeCodeDBName(), ATransactionTypeTable.GetTransactionTypeDescriptionDBName(), null); AControl.AppearanceSetup(new int[] { -1, 150 }, -1); }
/// <summary> /// This function fills the available financial periods of a given ledger and financial year into a TCmbAutoPopulated combobox /// </summary> public static void InitialiseAvailableFinancialPeriodsList( ref TCmbAutoPopulated AControl, System.Int32 ALedgerNr, System.Int32 AYear, System.Int32 AInitialSelectedIndex, Boolean AShowCurrentAndForwarding, Boolean AShowZero = true) { DataTable periods = InitialiseAvailableFinancialPeriodsList(ALedgerNr, AYear, AShowCurrentAndForwarding, AShowZero); AControl.InitialiseUserControl(periods, "value", "display", "descr", null, null); if (AShowCurrentAndForwarding) { AControl.AppearanceSetup(new int[] { AControl.ComboBoxWidth }, -1); } else { AControl.AppearanceSetup(new int[] { -1, 200 }, -1); } if (AInitialSelectedIndex >= 0) { AControl.SelectedIndex = AInitialSelectedIndex; } }
/// <summary> /// fill combobox values with motivation group list /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AActiveOnly"></param> public static void InitialiseMotivationGroupList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, bool AActiveOnly) { DataTable groupTable = (AMotivationGroupTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationGroupList, ALedgerNumber); groupTable.Columns.Add("Active", typeof(Boolean)); AControl.InitialiseUserControl(groupTable, AMotivationGroupTable.GetMotivationGroupCodeDBName(), AMotivationGroupTable.GetMotivationGroupDescriptionDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); if (AActiveOnly) { DataTable detailTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationList, ALedgerNumber); // motivation group is deemed active if it contains at least one active motivation detail foreach (DataRow groupRow in groupTable.Rows) { bool ContainsActive = false; foreach (DataRow detailRow in detailTable.Rows) { if ((detailRow[AMotivationDetailTable.GetMotivationGroupCodeDBName()].ToString() == groupRow[AMotivationGroupTable.GetMotivationGroupCodeDBName()].ToString()) && (Convert.ToBoolean(detailRow[AMotivationDetailTable.GetMotivationStatusDBName()]) == true)) { ContainsActive = true; break; } } groupRow["Active"] = ContainsActive; } AControl.Filter = "Active = true"; } else { AControl.Filter = string.Empty; } }
/// <summary> /// This function puts the ICH numbers used of a given ledger into a combobox /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="APeriodNumber"></param> /// <param name="AYearStart"></param> /// <param name="AYearEnding"></param> public static void InitialiseICHStewardshipList( ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, Int32 APeriodNumber, String AYearStart, String AYearEnding) { DataTable ICHNumbers = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.ICHStewardshipList, ALedgerNumber); if (AYearStart != null) { //Filter for current period and date range ICHNumbers.DefaultView.RowFilter = String.Format("{0}={1} And {2}>'{3}' And {2}<='{4}'", AIchStewardshipTable.GetPeriodNumberDBName(), APeriodNumber, AIchStewardshipTable.GetDateProcessedDBName(), AYearStart, AYearEnding); } else { //Filter for current period ICHNumbers.DefaultView.RowFilter = String.Format("{0}={1}", AIchStewardshipTable.GetPeriodNumberDBName(), APeriodNumber); } ICHNumbers.DefaultView.Sort = AIchStewardshipTable.GetIchNumberDBName(); //Get the distinct ICH numbers for the specified period DataTable newDataTable = ICHNumbers.DefaultView.ToTable(true, AIchStewardshipTable.GetIchNumberDBName(), AIchStewardshipTable.GetDateProcessedDBName()); // New column with date as a string. (We do not want time part of date.) newDataTable.Columns.Add("DateOnly"); foreach (DataRow Row in newDataTable.Rows) { Row["DateOnly"] = Convert.ToDateTime(Row[AIchStewardshipTable.GetDateProcessedDBName()]).ToShortDateString(); } // add empty row so that SetSelectedString for invalid string will not result in undefined behaviour DataRow emptyRow = newDataTable.NewRow(); emptyRow[0] = 0; //selecting 0 will mean full HOSA reports for all cost centres newDataTable.Rows.Add(emptyRow); AControl.InitialiseUserControl(newDataTable, AIchStewardshipTable.GetIchNumberDBName(), "DateOnly", null); AControl.AppearanceSetup(new int[] { -1, 80 }, -1); //Alternative way to filter the contents of the combo //AControl.Filter = AIchStewardshipTable.GetPeriodNumberDBName() + " = " + APeriodNumber.ToString(); }
/// <summary> /// fill combobox values with method of payment list /// </summary> /// <param name="AControl"></param> /// <param name="AActiveOnly"></param> public static void InitialiseMethodOfPaymentCodeList(ref TCmbAutoPopulated AControl, bool AActiveOnly) { DataTable Table = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MethodOfPaymentList); AControl.InitialiseUserControl(Table, AMethodOfPaymentTable.GetMethodOfPaymentCodeDBName(), AMethodOfPaymentTable.GetMethodOfPaymentCodeDBName(), AMethodOfPaymentTable.GetMethodOfPaymentDescDBName(), null, AMethodOfPaymentTable.GetActiveDBName() ); AControl.AppearanceSetup(new int[] { -1, 150 }, -1); if (AActiveOnly) { AControl.Filter = AMethodOfPaymentTable.GetActiveDBName() + " = true"; } else { AControl.Filter = ""; } }
/// <summary> /// This function fills the open financial periods of a given ledger into a combobox /// </summary> public static void InitialiseOpenFinancialPeriodsList( ref TCmbAutoPopulated AControl, System.Int32 ALedgerNumber) { DataTable AccountingPeriods = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountingPeriodList, ALedgerNumber); ALedgerRow Ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; int CurrentPeriod = Ledger.CurrentPeriod; int EndPeriod = CurrentPeriod + Ledger.NumberFwdPostingPeriods; AControl.InitialiseUserControl(AccountingPeriods, AAccountingPeriodTable.GetAccountingPeriodNumberDBName(), AAccountingPeriodTable.GetAccountingPeriodDescDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); AControl.Filter = String.Format("{0} >= {1} And {0} <= {2}", AAccountingPeriodTable.GetAccountingPeriodNumberDBName(), CurrentPeriod, EndPeriod); }
/// <summary> /// This function fills the available account hierarchies of a given ledger into a combobox /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNr"></param> public static void InitialiseAccountHierarchyList(ref TCmbAutoPopulated AControl, System.Int32 ALedgerNr) { DataTable Table = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountHierarchyList, ALedgerNr); AControl.InitialiseUserControl(Table, AAccountHierarchyTable.GetAccountHierarchyCodeDBName(), null, null); AControl.AppearanceSetup(new int[] { 150 }, -1); AControl.Filter = AAccountHierarchyTable.GetLedgerNumberDBName() + " = " + ALedgerNr.ToString(); }
/// <summary> /// fill combobox values with cost centre list /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="AReportsTo"></param> /// <param name="AACostCentreListDataSource">If a reference to the ACostCentreList is available, pass it here. Otherwise the method /// will get it from the data cache.</param> public static void InitialiseLocalCostCentreList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, Boolean AReportsTo = false, DataTable AACostCentreListDataSource = null) { DataTable Table; if (AACostCentreListDataSource == null) { Table = TRemote.MFinance.Setup.WebConnectors.LoadLocalCostCentres(ALedgerNumber); } else { Table = AACostCentreListDataSource.Copy(); } AControl.InitialiseUserControl(Table, "CostCentreCode", "CostCentreName", null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); if (AReportsTo) { AControl.Filter = "Posting = false"; } // We set the initial index to -1 because we always want to force the user to make a positive choice AControl.SelectedIndex = -1; }
public void TestComboboxEmptyDescriptionBug() { TCmbAutoPopulated cmb = new TCmbAutoPopulated(); DataTable detailTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationList, FLedgerNumber); Assert.AreNotEqual(0, detailTable.Rows.Count, "There should be a motivation detail in the cached table"); cmb.Name = "TestCombobox"; cmb.InitialiseUserControl(detailTable, AMotivationDetailTable.GetMotivationDetailCodeDBName(), AMotivationDetailTable.GetMotivationDetailDescDBName(), null); cmb.AppearanceSetup(new int[] { -1, 150 }, -1); Form TestForm = new Form(); TestForm.Controls.Add(cmb); TestForm.Show(); cmb.SelectedIndex = 1; Assert.AreEqual(cmb.GetSelectedString(), "KEYMIN"); Assert.AreEqual(cmb.GetSelectedDescription(), "Key Ministry Gift"); cmb.SelectedIndex = 0; Assert.AreEqual(cmb.GetSelectedString(), "FIELD"); Assert.AreEqual(cmb.GetSelectedDescription(), "Field Gift"); }
/// <summary> /// Fill combobox values with account codes /// </summary> /// <param name="AControl"></param> /// <param name="ALedgerNumber"></param> /// <param name="APostingOnly"></param> /// <param name="AExcludePosting"></param> /// <param name="AActiveOnly"></param> /// <param name="ABankAccountOnly"></param> /// <param name="AForeignCurrencyName">If a value is defined, only base curreny or the defined currency are filtered</param> /// <param name="AIndicateInactive">Determines wether or not to indicate an account code as inactive</param> /// <param name="AAAccountListDataSource">If a reference to the AAccountList is available, pass it here. Otherwise the method /// will get it from the data cache.</param> public static void InitialiseAccountList(ref TCmbAutoPopulated AControl, Int32 ALedgerNumber, bool APostingOnly, bool AExcludePosting, bool AActiveOnly, bool ABankAccountOnly, string AForeignCurrencyName, bool AIndicateInactive = false, DataTable AAAccountListDataSource = null) { DataTable Table; if (AAAccountListDataSource == null) { Table = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber); } else { Table = AAAccountListDataSource.Copy(); } // add empty row so that SetSelectedString for invalid string will not result in undefined behaviour (selecting the first account etc) DataRow emptyRow = Table.NewRow(); emptyRow[AAccountTable.ColumnLedgerNumberId] = ALedgerNumber; emptyRow[AAccountTable.ColumnAccountCodeId] = string.Empty; emptyRow[AAccountTable.ColumnAccountCodeShortDescId] = Catalog.GetString("Select a valid account"); Table.Rows.Add(emptyRow); //Highlight inactive Accounts if (!AActiveOnly && AIndicateInactive) { foreach (DataRow rw in Table.Rows) { if ((rw[AAccountTable.ColumnAccountActiveFlagId] != null) && (rw[AAccountTable.ColumnAccountActiveFlagId].ToString() == "False")) { rw[AAccountTable.ColumnAccountCodeShortDescId] = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + rw[AAccountTable.ColumnAccountCodeShortDescId]; } } } AControl.InitialiseUserControl(Table, AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null); AControl.AppearanceSetup(new int[] { -1, 200 }, -1); AControl.Filter = PrepareAccountFilter(APostingOnly, AExcludePosting, AActiveOnly, ABankAccountOnly, AForeignCurrencyName); }