using DevExpress.XtraEditors.Controls; using Yw.Dto; namespace HStation.WinFrmUI.Basic { public partial class SetSysPropForCatalogDlg : Form { public SetSysPropForCatalogDlg() { InitializeComponent(); } public class CurrentViewModel { public CurrentViewModel(SysPropHaveLogicalTreeDto rhs) { if (rhs.LogicalType == "sys-prop") { Name = rhs.LogicalName; ID = rhs.LogicalID; IsHave = rhs.Have; } else { Name = rhs.LogicalName; ID = rhs.LogicalID; IsHave = rhs.Have; } } public string Name { get; set; } public long ID { get; set; } public long ParentID { get; set; } public bool IsHave { get; set; } } private List _allBindingList = new List(); private Yw.BLL.SysPropMapping _bll = null; private long _CatlogID; public async void SetBindingData(long ID) { _CatlogID = ID; _bll = new Yw.BLL.SysPropMapping(); var PropTreeList = await _bll.GetHaveLogicalTreeList(ID); foreach (var item in PropTreeList) { if (item.Children.Count > 0) { foreach (var child in item.Children) { CheckedListBoxItem childitem = new CheckedListBoxItem(); childitem.Value = child.LogicalID; childitem.Description = child.LogicalName; checkedListBoxControl1.Items.Add(childitem); if (child.Have) { childitem.CheckState = CheckState.Checked; } } } } } // 完成 private async void BtnOk_Click(object sender, EventArgs e) { List IdList = new List(); foreach (var item in checkedListBoxControl1.CheckedItems) { if (item is CheckedListBoxItem checkedListBoxItem) { var model = item as CheckedListBoxItem; if (model != null) { var value = model.Value; IdList.Add(Convert.ToInt64(model.Value)); } } } if (await _bll.Set(_CatlogID, IdList)) { MessageBoxHelper.ShowSuccess("修改成功!"); } else { MessageBoxHelper.ShowError("修改失败"!); return; } this.Close(); } } }