private void CancelExecute(object parameter)
        {
            SellOrder = null;
            AddSellOrderWindow AddSellOrderWindow = parameter as AddSellOrderWindow;

            CallBack(SellOrder);
            AddSellOrderWindow.Close();
        }
        private void ConfirmExecute(object parameter)
        {
            bool   IsValid       = true;
            string message       = "存在非法输入";
            string detailMessage = "";

            if (SellOrder.UnitSellPrize <= 0)
            {
                detailMessage += "单位售价不允许小于等于零\n";
                IsValid        = false;
            }
            if (SellOrder.Amount <= 0)
            {
                detailMessage += "数量不允许小于等于零\n";
                IsValid        = false;
            }
            if (IsValid)
            {
                if (CargoCollection.Amount < SellOrder.Amount)
                {
                    string        message2       = "货物数量不足";
                    string        detailMessage2 = string.Format("仓库:{0},楼层:{1},区域:{2}中的商品:{3},库存数量:{4},订单要求卖出数量:{5}。数量不足!", CargoCollection.WarehouseName, CargoCollection.PlaneName, CargoCollection.BlockName, CargoCollection.Cargo.CargoName, CargoCollection.Amount, SellOrder.Amount);
                    WarningWindow warn           = new WarningWindow(message2, detailMessage2);
                    warn.ShowDialog();
                }
                else
                {
                    CallBack(SellOrder);
                    AddSellOrderWindow AddSellOrderWindow = parameter as AddSellOrderWindow;
                    AddSellOrderWindow.Close();
                }
            }
            else
            {
                WarningWindow warn = new WarningWindow(message, detailMessage);
                warn.ShowDialog();
            }
        }
Esempio n. 3
0
        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();
                }
            }
        }