public List <ConfigParaGroup> GetAllConfigParaGroup() { var groups = this._dbAccess.QueryT <ConfigParaGroup>(); if (groups.Count == 0) { var defaultGroup = new ConfigParaGroup(); defaultGroup.Name = "默认组"; defaultGroup.Des = "默认组"; this._dbAccess.InsertT <ConfigParaGroup>(defaultGroup); groups = this._dbAccess.QueryT <ConfigParaGroup>(); } return(groups); }
/// <summary> /// 刷新数据 /// </summary> public override void RefreshData() { try { List <ConfigParaGroup> groups = this._configLogic.GetAllConfigParaGroup(); groups.Insert(0, this._allGroup); ConfigParaGroup selectedItem = null; if (comGroup.Items.Count > 0) { var oldSelectedItem = DropdownBoxHelper.GetGenericFromComboBox <ConfigParaGroup>(comGroup); if (oldSelectedItem != null) { var ret = (from tmpItem in groups where oldSelectedItem.ID == tmpItem.ID select tmpItem).ToList(); if (ret.Count > 0) { selectedItem = ret[0]; } } } if (selectedItem == null && groups.Count > 0) { selectedItem = groups[0]; } this.comGroup.SelectedIndexChanged -= this.comGroup_SelectedIndexChanged; try { DropdownBoxHelper.BindingIEnumerableGenericToComboBox <ConfigParaGroup>(comGroup, groups, nameof(ConfigParaGroup.Name), null); } finally { this.comGroup.SelectedIndex = -1; this.comGroup.SelectedIndexChanged += this.comGroup_SelectedIndexChanged; DropdownBoxHelper.SetGenericToComboBox(comGroup, selectedItem); } } catch (Exception ex) { Loger.Error(ex); } }
public List <ConfigParaKeyValue> GetGroupConfigParaKeyValue(ConfigParaGroup selectedItem) { List <ConfigParaKeyValue> configParas; if (selectedItem != null) { var query = new ConfigParaKeyValue(); query.GID = selectedItem.ID; var conditionProperties = new List <string>(); conditionProperties.Add(nameof(ConfigParaKeyValue.GID)); configParas = this._dbAccess.QueryT <ConfigParaKeyValue>(query, conditionProperties); foreach (var item in configParas) { item.Group = selectedItem; } } else { configParas = this._dbAccess.QueryT <ConfigParaKeyValue>(); this.UpdateConfigParaGroup(configParas); } return(configParas); }