/// <summary> /// If some options that has inferir options has been selected, /// proper inferior optios are loaded to proper combobox /// </summary> /// <param name="superiorOption">Superior option that has been selected</param> public void BindInferiorOptionsToComboBoxes(ModuleOption superiorOption) { // Nothing to bind if (this.optionComboBoxes == null || superiorOption == null) return; Hashtable comboBoxesToClear = new Hashtable(); foreach (ModuleOption option in this.Options) { // Add option to proper combobox if (!string.IsNullOrEmpty(option.SuperiorOption) && superiorOption.ID.Equals(option.SuperiorOption)) { string id = option.OptionNumber.ToString(); // Clear previous options if (!comboBoxesToClear.Contains(id)) { comboBoxesToClear.Add(id, null); if (this.optionComboBoxes.ContainsKey(id)) ((ComboBox)this.optionComboBoxes[id]).Items.Clear(); } if (this.optionComboBoxes.ContainsKey(id)) ((ComboBox)this.optionComboBoxes[id]).Items.Add(option); } } }
/// <summary> /// Loads options from database related to this module /// </summary> /// <param name="connection">KaRaFa Database connection</param> private void LoadOptions(DatabaseConnection connection) { try { // Get Options query string query = connection.CreateSelectCommandText( Properties.Resources.VIEW_ATC_OPTIONS, null, string.Format("ModulID = {0}", this.ID), "ID ASC" ); // Get results DataSet dataSet = connection.ExecuteSelectQuery(query); if (dataSet == null || dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0) return; // Save options foreach (DataRow definition in dataSet.Tables[0].Rows) { ModuleOption option = new ModuleOption(definition); this.Options.Add(option); } } catch (Exception ex) { Karafa.Errors.KarafaLogger.LogError(ex); } }