public bool AddSellOrderCanExecute(object parameter) { SellCargoUserControl sc = parameter as SellCargoUserControl; SellCargoUserControlViewModel scvm = sc.DataContext as SellCargoUserControlViewModel; if (scvm.SellOrderCollectionViewModel == null) { return(false); } else { return(true); } }
public void AddSellOrderExecute(object parameter) { SellCargoUserControl sellCargoUserControl = parameter as SellCargoUserControl; SellCargoUserControlViewModel sellCargoUserControlvm = sellCargoUserControl.DataContext as SellCargoUserControlViewModel; SellOrderCollectionViewModel = sellCargoUserControlvm.SellOrderCollectionViewModel; if (sellCargoUserControlvm.OutSellOrderButtonIsEnabled == false) { string message = "尚未创建订单"; string detailMessage = "卖出货品前,需要首先创建一个订单,每次卖出物品会在订单中添加一个条目"; WarningWindow warn = new WarningWindow(message, detailMessage); warn.ShowDialog(); } else { bool IsExist = SellOrderCollectionViewModel.SellOrderViewModels.Any <SellOrderViewModel> (item => item.SellOrder.WarehouseName == CargoCollection.WarehouseName && item.SellOrder.PlaneName == CargoCollection.PlaneName && item.SellOrder.BlockName == CargoCollection.BlockName && item.SellOrder.PreciseCargoName == CargoCollection.PreciseCargoName); if (IsExist) { string message = "订单中已存在同名条目"; string detailMessage = string.Format("同一订单中的不同条目之间,以下四个项目应至少有一个不重复:仓库名称,楼层名称,区域名称,货品名称"); WarningWindow warn = new WarningWindow(message, detailMessage); warn.ShowDialog(); } else { AddSellOrderWindow addSellOrderWindow = new AddSellOrderWindow(CargoCollection); AddSellOrderWindowViewModel addSellOrderWindowvm = addSellOrderWindow.DataContext as AddSellOrderWindowViewModel; addSellOrderWindowvm.CallBack = new Action <SellOrder>(CallBack); addSellOrderWindow.Show(); } } }