public EditBusinessRuleComponent(BusinessRuleComponentVO component, bool isReadOnly) { InitializeComponent(); _component = component; _isReadOnly = isReadOnly; //Add new component. if (_component == null) { _isAdd = true; _component = new BusinessRuleComponentVO(Guid.NewGuid(), "", BusinessRuleComponentVO.RuleValueType.PARAM, true); _component.FromDate = DateTime.Parse("1/1/1950"); _component.ToDate = DateTime.Parse("1/1/2050"); //Go ahead and create an empty list of children so that //the tree view nodes get the notify property changed event when a child is added. _component.Children = new System.Collections.ObjectModel.ObservableCollection <BusinessRuleComponentVO>(); } if (!_component.IsEditable) { _isReadOnly = false; } this.DataContext = _component; InitControls(); }
public void AddExistingComponent(BusinessRuleComponentVO comp) { if (_selectedNode is BusinessRuleNodeVO) { BusinessRuleNodeVO parentNode = (BusinessRuleNodeVO)_selectedNode; if (parentNode.ComponentList == null) { parentNode.ComponentList = new ObservableCollection <BusinessRuleComponentVO>(); } //If the comp has no children then add them so the tree can update. if (comp.Children == null) { comp.Children = new ObservableCollection <BusinessRuleComponentVO>(); } RulesHelper.PopulateComponentHeirarchy(comp); parentNode.ComponentList.Add(comp); _tracker.ChangedRules.Add(parentNode); _tracker.SaveChangesToWorkingFile(); ControlHelper.TreeViewHelper.ExpandAndSelectTreeItem(this.treeRules, comp); } }
private void EditComponent(BusinessRuleComponentVO c) { EditBusinessRuleCompWindow w = new EditBusinessRuleCompWindow(Utilities.DeepCopy(c), false); w.ShowDialog(); Refresh(); }
public EditBusinessRuleComponent(BusinessRuleComponentVO component, BusinessRuleComponentVO parent, bool isReadOnly) : this(component, isReadOnly) { _parentComponent = parent; if (_parentComponent != null) { _component.ParentId = _parentComponent.Id; } }
private void cmdDelete_Click(object sender, RoutedEventArgs e) { MessageBoxResult r = MessageBox.Show("Are you sure you want to permanently delete this component?", "Are you sure?", MessageBoxButton.YesNo); if (r == MessageBoxResult.Yes) { BusinessRuleComponentVO c = (BusinessRuleComponentVO)lvComponents.SelectedItem; c.Deleted = true; App.RulesTreeView.UpdateBusinessComponent(c, null, true); } Refresh(); }
private void cmdView_Click(object sender, RoutedEventArgs e) { BusinessRuleComponentVO c = (BusinessRuleComponentVO)lvComponents.SelectedItem; if (c == null) { MessageBox.Show("Please select a component to view."); } else { ViewComponent(c); } }
protected void HandleDoubleClick(object sender, MouseButtonEventArgs e) { BusinessRuleComponentVO comp = ((ListViewItem)sender).Content as BusinessRuleComponentVO; //Casting back to the binded Track if (_isSelection) { SelectComponent(comp); } else { EditComponent(comp); } }
private void ReplaceComponentNodes(BusinessRuleComponentVO replacementNode) { foreach (BusinessRuleNodeVO r in _rootNode[0].Nodes) { if (r.ComponentList != null) { foreach (BusinessRuleComponentVO c in r.ComponentList) { SearchReplaceChildNodes(c, replacementNode); } } } }
private bool updateBusinessRuleComponent(List <string> busRules, ref Dictionary <string, BusinessRuleVO> bvoHierarchy, ref PawnRule p) { if (p == null || busRules == null || bvoHierarchy == null) { return(false); } string pawnRuleCompKey = p.RuleKey; foreach (string bRule in busRules) { string curRule = bRule; BusinessRuleVO curBR = bvoHierarchy[curRule]; if (curBR == null || !curBR.ContainsKey(pawnRuleCompKey)) { continue; } BusinessRuleComponentVO bvo = curBR[pawnRuleCompKey]; bvo.FromDate = p.FromDate; bvo.ToDate = p.ToDate; //bvo.CheckLoanRange = p.CheckLoanRange; //bvo.CheckLoanAmount = p.CheckLoanAmount; bvo.Alias = p.Alias; switch (bvo.ValueType) { case BusinessRuleComponentVO.RuleValueType.FEES: bvo.FeesValue.Alias.Code = p.Alias; bvo.FeesValue.ParamKeyCode = p.RuleKey; bvo.FeesValue.Value = p.RuleValue; break; case BusinessRuleComponentVO.RuleValueType.INTEREST: bvo.InterestValue.Alias.Code = p.Alias; bvo.InterestValue.InterestAmount = 0.0M; bvo.InterestValue.InterestRate = decimal.Parse(p.RuleValue); bvo.InterestValue.MinAmount = p.LoanAmountMin; bvo.InterestValue.MaxAmount = p.LoanAmountMax; break; case BusinessRuleComponentVO.RuleValueType.PARAM: bvo.ParamValue.Alias.Code = p.Alias; bvo.ParamValue.Cacheable = false; bvo.ParamValue.Company = "1"; bvo.ParamValue.Code = p.RuleKey; bvo.ParamValue.Value = p.RuleValue; break; } } return(true); }
private void DeleteBusinessRuleComponent(BusinessRuleComponentVO comp) { //Will need to delete comp.Deleted = true; //Remove the node from the visual tree in all instances. foreach (BusinessRuleNodeVO node in _rootNode[0].Nodes) { if (node.ComponentList != null && node.ComponentList.Count() > 0) { FindAndRemoveChildNodes(node.ComponentList, comp); } } _tracker.ChangedComponents.Add(comp); _tracker.SaveChangesToWorkingFile(); }
private void SearchReplaceChildNodes(BusinessRuleComponentVO parentComp, BusinessRuleComponentVO replacementNode) { if (replacementNode.Id == parentComp.Id) { parentComp = replacementNode; } if (parentComp.Children != null) { if (parentComp.Children.Count > 0) { foreach (BusinessRuleComponentVO c in parentComp.Children) { SearchReplaceChildNodes(c, replacementNode); } } } }
private void SearchAddChildNodes(BusinessRuleComponentVO parentComp, BusinessRuleComponentVO newNode) { if (newNode.ParentId == parentComp.Id) { if (parentComp.Children == null) { parentComp.Children = new ObservableCollection <BusinessRuleComponentVO>(); } parentComp.Children.Add(newNode); } if (parentComp.Children != null) { if (parentComp.Children.Count > 0) { foreach (BusinessRuleComponentVO c in parentComp.Children) { SearchAddChildNodes(c, newNode); } } } }
private void AddComponentNode(BusinessRuleComponentVO newNode, BusinessRuleNodeVO parentNode) { if (parentNode != null) { BusinessRuleNodeVO node = (from n in _rootNode[0].Nodes where n.Id == parentNode.Id select n).First(); node.ComponentList.Add(newNode); } else { foreach (BusinessRuleNodeVO r in _rootNode[0].Nodes) { if (r.ComponentList != null) { foreach (BusinessRuleComponentVO c in r.ComponentList) { SearchAddChildNodes(c, newNode); } } } } }
public void UpdateBusinessComponent(BusinessRuleComponentVO comp, BusinessRuleNodeVO parentNode, bool isAdd) { //Adds to visual tree. if (isAdd) { //If it's a business rule as parent, will need to add the component //so that the relationship is updated. if (parentNode != null) { if (parentNode.ComponentList == null) { parentNode.ComponentList = new ObservableCollection <BusinessRuleComponentVO>(); } parentNode.ComponentList.Add(comp); } else { AddComponentNode(comp, parentNode); } ControlHelper.TreeViewHelper.ExpandAndSelectTreeItem(this.treeRules, comp); } else { ReplaceComponentNodes(comp); } //Add changes to change tracking. _tracker.ChangedComponents.Add(comp); if (parentNode != null) { _tracker.ChangedRules.Add(parentNode); } _tracker.SaveChangesToWorkingFile(); }
private void FindAndRemoveChildNodes(ObservableCollection <BusinessRuleComponentVO> compList, BusinessRuleComponentVO comp) { BusinessRuleComponentVO removeComp = null; //Search the list for the Id, if it's found break. foreach (BusinessRuleComponentVO node in compList) { if (node.Children != null && node.Children.Count() > 0) { FindAndRemoveChildNodes(node.Children, comp); } if (node.Id == comp.Id) { //Found the node so remove and break from loop. removeComp = node; break; } } if (removeComp != null) { compList.Remove(removeComp); } }
public EditBusinessRuleCompWindow(BusinessRuleComponentVO comp, BusinessRuleNodeVO parent, bool isReadOnly) { InitializeComponent(); spMainContent.Children.Add(new EditBusinessRuleComponent(comp, parent, isReadOnly)); }
private void SelectComponent(BusinessRuleComponentVO c) { App.RulesTreeView.AddExistingComponent(c); this.Close(); }
private void EditBusinessRuleComponent(BusinessRuleComponentVO comp, BusinessRuleNodeVO parent) { EditBusinessRuleCompWindow w = new EditBusinessRuleCompWindow(comp, parent, false); w.ShowDialog(); }
private void EditBusinessRuleComponent(BusinessRuleComponentVO comp) { EditBusinessRuleCompWindow w = new EditBusinessRuleCompWindow(comp, false); w.ShowDialog(); }
private void ViewComponent(BusinessRuleComponentVO c) { EditBusinessRuleCompWindow w = new EditBusinessRuleCompWindow(Utilities.DeepCopy(c), true); w.ShowDialog(); }
private void cmdEdit_Click(object sender, RoutedEventArgs e) { BusinessRuleComponentVO c = (BusinessRuleComponentVO)lvComponents.SelectedItem; EditComponent(c); }
public EditBusinessRuleComponent(BusinessRuleComponentVO component, BusinessRuleNodeVO parent, bool isReadOnly) : this(component, isReadOnly) { _parentRule = parent; }