public override void Execute(ListLogicalView view) { //创建一个临时的拷贝数据 var listEntity = view.Current; var tmp = Entity.New(view.EntityType); tmp.Clone(listEntity); var evm = view.Meta; var res = PopupEditingDialog(evm, tmp, w => { w.Title = this.Meta.Label.Translate() + " " + evm.Label.Translate(); }); if (res == WindowButton.Yes) { //修改按钮如果使用新的 Id,则它下面子对象的父外键都将是错误的值。 listEntity.Clone(tmp, new CloneOptions( CloneActions.NormalProperties | CloneActions.RefEntities )); listEntity.MarkModifiedIfUnchanged(); view.RefreshControl(); } }
public override void Execute(ListLogicalView view) { var barcode = BarcodeTextBoxGenerator.GetTextBoxParameter(this); if (!string.IsNullOrEmpty(barcode)) { var list = view.Data; var item = list.Cast<ProductRefItem>().FirstOrDefault(i => i.Product.Barcode == barcode); if (item != null) { item.Amount++; } else { var product = RF.Concrete<ProductRepository>().GetByBarcode(barcode); if (product == null) { App.MessageBox.Show(string.Format("没有找到对应 {0} 的商品".Translate(), barcode), MessageBoxImage.Error); return; } item = view.CreateNewItem().CastTo<ProductRefItem>(); item.Product = product; item.Amount = 1; list.Add(item); view.RefreshControl(); } view.Current = item; } }
public override void Execute(ListLogicalView view) { var category = view.CreateNewItem() as TaskOrCategory; category.MonthPercent = 0; category.MonthScore = 0; view.Data.Add(category); view.RefreshControl(); view.Current = category; CommandsHelper.EditCurrent(view); }
protected override void Complete(ListLogicalView view) { if (this._firstSelection != null) { view.RefreshControl(); view.Current = this._firstSelection; var treeGrid = view.Control.CastTo<RafyTreeGrid>(); var amountColumn = treeGrid.FindColumnByProperty(ProductRefItem.AmountProperty); var row = treeGrid.FindRow(this._firstSelection); if (row != null) { var cell = row.ScrollToCell(amountColumn); treeGrid.TryEditRow(row, cell); } } }
public override void Execute(ListLogicalView view) { var dataList = view.Data; var isTree = dataList.SupportTree; var selectedItems = view.SelectedEntities.ToArray(); for (int i = selectedItems.Length - 1; i >= 0; i--) { var selectedItem = selectedItems[i]; //如果是树形,则级联删除所有子节点 if (isTree) { var node = selectedItem as ITreeComponent; var parent = node.TreeComponentParent; if (parent.ComponentType == TreeComponentType.NodeList) { dataList.Remove(selectedItem); } else if (parent.ComponentType == TreeComponentType.TreeChildren) { var parentList = parent as Entity.EntityTreeChildren; parentList.Remove(selectedItem); } } else { dataList.Remove(selectedItem); } } if (dataList.Count > 0) { view.Current = dataList[0] as Entity; } else { view.Current = null; } view.RefreshControl(); }
/// <summary> /// 最后完成本次选择。 /// </summary> /// <param name="view"></param> protected virtual void Complete(ListLogicalView view) { view.RefreshControl(); }
public override void Execute(ListLogicalView view) { var current = view.Current; var parentList = GetParentList(current); var index = parentList.IndexOf(current); parentList.Remove(current); if (this.MoveUp) { parentList.Insert(index - 1, current); } else { parentList.Insert(index + 1, current); } view.RefreshControl(); view.Current = current; }
public override void Execute(ListLogicalView view) { var current = view.Current; var treeParent = current.TreeParent; var grandParentList = GetParentList(treeParent); if (grandParentList == view.Data) { if (!view.Data.IsTreeRootList) { //不处理这种情况。 return; } } treeParent.TreeChildren.Remove(current); grandParentList.Add(current); view.RefreshControl(); view.Current = current; }
public override void Execute(ListLogicalView view) { var current = view.Current; var previous = FindPreviousNode(current); current.TreeParent = previous; view.RefreshControl(); view.Current = current; }
public override void Execute(ListLogicalView view) { var list = view.Data; if (list == null) throw new ArgumentNullException("list"); var current = view.Current; var newEntity = view.CreateNewItem(); var parentList = GetParentList(current); var index = parentList.IndexOf(current); parentList.Insert(index, newEntity); view.RefreshControl(); view.Current = newEntity; }
public override void Execute(ListLogicalView view) { var category = view.Current as TaskOrCategory; if (category.IsTaskRO) { category = category.TreeParent as TaskOrCategory; } var task = view.CreateNewItem() as TaskOrCategory; var weeksCount = task.MonthPlan.WeeksCountRO; for (int i = 0; i < weeksCount; i++) { task.WeekCompletionList.Add(new WeekCompletion { Index = i + 1 }); } task.WeightInCategory = 1; task.Score = 0; task.ObjectiveNum = 1;//放在添加 WeekCompletionList 之后 category.TreeChildren.Add(task); view.RefreshControl(); view.Current = task; CommandsHelper.EditCurrent(view); }
public override void Execute(ListLogicalView view) { //创建一个临时的拷贝数据 var tmp = view.CreateNewItem(); var evm = view.Meta; var result = PopupEditingDialog(evm, tmp, w => { w.Title = this.Meta.Label.Translate() + " " + evm.Label.Translate(); }); //如果没有点击确定,则删除刚才添加的记录。 if (result == WindowButton.Yes) { //先添加一行记录 var curEntity = view.AddNew(false); var oldTreeCode = string.Empty; object oldTreePId = null; if (evm.EntityMeta.IsTreeEntity) { oldTreeCode = curEntity.TreeIndex; oldTreePId = curEntity.TreePId; } curEntity.Clone(tmp, new CloneOptions( CloneActions.NormalProperties | CloneActions.RefEntities )); //如果用户没有设置树型编码,则把树型编码还原到 Clone 之前系统自动生成的编码 if (!string.IsNullOrEmpty(oldTreeCode) && string.IsNullOrEmpty(curEntity.TreeIndex) && view.Data.AutoTreeIndexEnabled) { curEntity.TreeIndex = oldTreeCode; curEntity.TreePId = oldTreePId; } this.OnDataCloned(curEntity, tmp); view.RefreshControl(); view.Current = curEntity; } }