| | |
| | | using DevExpress.DataAccess.Wizard.Model; |
| | | using DevExpress.CodeParser; |
| | | using DevExpress.DataAccess.Wizard.Model; |
| | | using DevExpress.XtraEditors; |
| | | using System; |
| | | using Yw.Dto; |
| | | |
| | | namespace HStation.WinFrmUI.Basic |
| | |
| | | public SetSysPropForCatalogDlg() |
| | | { |
| | | InitializeComponent(); |
| | | this.gridView1.Columns["GroupName"].Group(); |
| | | // this.treeList1.Columns["GroupName"].; |
| | | /* this.gridView1.Columns["GroupName"].Group(); |
| | | |
| | | */ |
| | | repositoryItemCheckedComboBoxEdit1.DisplayMember = "Name"; |
| | | repositoryItemCheckedComboBoxEdit1.ValueMember = "ID"; |
| | | } |
| | |
| | | foreach (var item in PropTreeList) |
| | | { |
| | | repositoryItemCheckedComboBoxEdit1.Items.Clear(); |
| | | |
| | | var parent = new SysPropMappingViewModel(); |
| | | parent.ID = item.ID; |
| | | parent.IsGroup = true; |
| | | parent.Name = item.Name; |
| | | _allBindingList.Add(parent); |
| | | if (item.PropList.Count > 0) |
| | | { |
| | | foreach (var child in item.PropList) |
| | |
| | | var model = new SysPropMappingViewModel(); |
| | | model.GroupName = item.Name; |
| | | model.ID = child.ID; |
| | | model.ParentID = item.ID; |
| | | model.Name = child.Name; |
| | | model.IsHave = child.Have; |
| | | model.IsNull = child.IsNull; |
| | |
| | | model.UnitName = child.UnitName; |
| | | model.Inherit = child.Inherit; |
| | | model.ChoiceList = child.ChoiceList; |
| | | model.ChoiceIds = child.ChoiceList.Where(x => x.Have).Select(x => x.ID).ToList(); |
| | | var stringList = child.ChoiceList.Where(x => x.Have == true).ToList().Select(x => x.ID.ToString()).ToList(); |
| | | string result = string.Join(", ", stringList); |
| | | model.DisplayChoice = result; |
| | |
| | | } |
| | | } |
| | | this.sysCatalogPropViewModelBindingSource.DataSource = _allBindingList; |
| | | this.gridView1.ExpandAllGroups(); |
| | | this.treeList1.ExpandAll(); |
| | | } |
| | | |
| | | // 完成 |
| | |
| | | this.Close(); |
| | | } |
| | | |
| | | private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) |
| | | private void repositoryItemCheckedComboBoxEdit1_EditValueChanged(object sender, EventArgs e) |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | try |
| | | { |
| | | var vm = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | var allselectList = repositoryItemCheckedComboBoxEdit1.GetCheckedItems(); |
| | | var strList = Convert.ToString(allselectList); |
| | | if (strList != null && strList != string.Empty) |
| | | { |
| | | if (strList.Contains(',')) |
| | | { |
| | | string[] parts = strList.Split(','); |
| | | List<long> longs = parts.Select(part => long.Parse(part.Trim())).ToList(); |
| | | |
| | | vm.ChoiceIds = longs; |
| | | } |
| | | else |
| | | { |
| | | if (long.TryParse(strList, out long Id)) |
| | | { |
| | | List<long> choiceId = new List<long>(); |
| | | choiceId.Add(Id); |
| | | vm.ChoiceIds = choiceId; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | vm.ChoiceIds = new List<long>(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | } |
| | | |
| | | private void treeList1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) |
| | | { |
| | | var vm = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | |
| | | { |
| | | e.Cancel = true; |
| | | } |
| | | if (gridView1.FocusedColumn.Name == "colPropChoice") |
| | | if (vm.IsGroup) |
| | | { |
| | | e.Cancel = true; |
| | | } |
| | | if (treeList1.FocusedColumn.Name == "colPropChoice") |
| | | { |
| | | repositoryItemCheckedComboBoxEdit1.Items.Clear(); |
| | | repositoryItemCheckedComboBoxEdit1.DataSource = vm.ChoiceList; |
| | | } |
| | | } |
| | | |
| | | private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) |
| | | private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e) |
| | | { |
| | | var gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView; |
| | | if (gridView != null) |
| | | if (e.Node != null) |
| | | { |
| | | foreach (var item in _allBindingList) |
| | | string Inherit = e.Node.GetValue("Inherit").ToString(); |
| | | string isGroup = e.Node.GetValue("IsGroup").ToString(); |
| | | if (Inherit == "True") |
| | | { |
| | | int index = _allBindingList.IndexOf(item); |
| | | if (gridView.GetRowHandle(index) == e.RowHandle) |
| | | { |
| | | if (item.Inherit) |
| | | { |
| | | e.Appearance.BackColor = Color.Gray; |
| | | } |
| | | break; |
| | | } |
| | | e.Appearance.BackColor = Color.DarkGray; |
| | | } |
| | | if (isGroup == "True") |
| | | { |
| | | e.Appearance.BackColor = Color.Gainsboro; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void repositoryItemCheckedComboBoxEdit1_EditValueChanged(object sender, EventArgs e) |
| | | private void treeList1_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e) |
| | | { |
| | | try |
| | | string isGroup = e.Node.GetValue("Inherit").ToString(); |
| | | if (isGroup == "True") |
| | | { |
| | | var allselectList = repositoryItemCheckedComboBoxEdit1.GetCheckedItems(); |
| | | string[] parts = Convert.ToString(allselectList).Split(','); |
| | | List<long> longs = parts.Select(part => long.Parse(part.Trim())).ToList(); |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm != null) |
| | | e.State = CheckState.Unchecked; |
| | | } |
| | | else |
| | | { |
| | | if (e.PrevState == CheckState.Checked) |
| | | { |
| | | vm.ChoiceIds = longs; |
| | | e.State = CheckState.Unchecked; |
| | | } |
| | | else |
| | | { |
| | | e.State = CheckState.Checked; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | } |
| | | |
| | | private void treeList1_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e) |
| | | { |
| | | SetCheckedChildNodes(e.Node, e.Node.CheckState, e); |
| | | } |
| | | |
| | | #region 设置子节点状态 |
| | | |
| | | private void SetCheckedChildNodes(DevExpress.XtraTreeList.Nodes.TreeListNode node, CheckState check, DevExpress.XtraTreeList.NodeEventArgs e) |
| | | { |
| | | for (int i = 0; i < node.Nodes.Count; i++) |
| | | { |
| | | string Inherit = node.Nodes[i].GetValue("Inherit").ToString(); |
| | | if (Inherit == "False") |
| | | { |
| | | node.Nodes[i].CheckState = check; |
| | | SetCheckedChildNodes(node.Nodes[i], check, e); |
| | | } |
| | | else if (Inherit == "True") |
| | | { |
| | | node.Nodes[i].CheckState = CheckState.Checked; |
| | | SetCheckedChildNodes(node.Nodes[i], check, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion 设置子节点状态 |
| | | } |
| | | } |