public ToolEnterNoToPrintViewModel()
        {
            this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _stockboxRule = new StockBoxRule();
            _trayRule = new TrayRule();
            this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {
                CurrentPrintType = (PrintType)param.Entity;

                int LotID = Convert.ToInt32(param.Tag);
                string ErrMsg = string.Empty;
                IsMessageEnable = false;
                CancelVisibility = Visibility.Collapsed;
                txtIsEnabled = false;
                switch (CurrentPrintType)
                {
                    case PrintType.Box:
                        Title = "打印 BOX ID标签";
                        Head = "请输入BOX ID标签";
                        _isTuoHao = false;
                      //  CurrentStockBox = _stockboxRule.GetMaxStockBox_Ex(ref ErrMsg);
                        CurrentStockBox = param.Entity1 as StockBox;
                        Content = CurrentStockBox.BarCode;
                        break;
                    case PrintType.Tray:
                        Title = "打印 托号标签";
                        Head = "请输入托号标签";
                        _isTuoHao = true;
                        _IsQiangDa = false;
                        Content = _trayRule.GetTrayMaxBarCode(LotID, ref ErrMsg);
                        _TrayID = Content;
                        IsMessageEnable = true;
                        break;
                    case PrintType.ForceBox:
                        Title = "打印 BOX ID标签[强制打印]";
                        Head = "请输入BOX ID标签";
                        _isTuoHao = false;
                      //  CurrentStockBox = _stockboxRule.GetMaxStockBox_Ex(ref ErrMsg);
                        CurrentStockBox = param.Entity1 as StockBox;
                        Content = CurrentStockBox.BarCode;
                        CancelVisibility = Visibility.Visible;
                        break;
                    case PrintType.ForceTray:
                        Title = "打印 托号标签[强制打印]";
                        Head = "请输入托号标签";
                        _isTuoHao = true;
                        Content = _trayRule.GetTrayMaxBarCode(LotID, ref ErrMsg);
                        _TrayID = Content;
                        CancelVisibility = Visibility.Visible;
                        _IsQiangDa = true;
                        break;
                    case PrintType.AgainBox:
                        Title = "打印 托号标签[补打打印]";
                        Head = "请输入BOX ID标签";
                        CancelVisibility = Visibility.Visible;
                        break;
                    case PrintType.AgainTray:
                        Title = "打印 托号标签[补打打印]";
                        Head = "请输入托号标签";
                        CancelVisibility = Visibility.Visible;
                        break;
                    default:
                        break;
                }

            }, ThreadOption.UIThread, true, p => p.Target == "ToolEnterNoToPrintViewModel");
        }
Esempio n. 2
0
        public AgainEnterNoPrint()
        {
            InitializeComponent();
            _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _stockBoxRule = new StockBoxRule();
            _trayRule = new TrayRule();
            //订阅
            _eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {
                switch (param.cmdName)
                {
                    case CmdName.New:
                        iType = (int)param.Entity;
                        dtEnd.Text = DateTime.Now.ToString("yyyy-MM-dd");
                        dtStart.Text = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");

                        DateTime Startdt = Convert.ToDateTime(dtStart.Text);
                        DateTime Enddt = Convert.ToDateTime(dtEnd.Text);
                        string ErrMsg = string.Empty;
                        txtChangeBoxID.Visibility = Visibility.Hidden;
                        txtChangeBoxID.Text = string.Empty;
                        switch (iType)
                        {
                            case 0:
                                strTypaName = "BOX ID";
                                TitleInfo.Content = "补打外箱标签";
                                title.Content = "选择BOX ID";
                                btnChange.Visibility = Visibility.Visible;

                                var boxList = _stockBoxRule.GetBoxListByDt(Startdt, Enddt.AddDays(1), ref ErrMsg).ToList();
                                if (boxList != null)
                                {
                                    boxList = boxList.OrderByDescending(p => p.CreateDt).ToList();
                                    cbBarCode.Items.Clear();
                                    foreach (var item in boxList)
                                    {
                                        cbBarCode.Items.Add(item.BarCode);
                                    }
                                }
                                break;
                            case 1:
                                strTypaName = "托号";
                                TitleInfo.Content = "补打托号";
                                title.Content = "选择托号";

                                var list = _trayRule.GetTrayListByDt(Startdt, Enddt.AddDays(1), ref ErrMsg);
                                if (list != null)
                                {
                                    list = list.OrderByDescending(p => p.CreateDt).ToList();
                                    cbBarCode.Items.Clear();
                                    foreach (var item in list)
                                    {
                                        cbBarCode.Items.Add(item.BarCode);
                                    }
                                }
                                btnChange.Visibility = Visibility.Hidden;
                                break;
                            default:
                                break;
                        }

                        break;

                    default:
                        break;
                }

            }, ThreadOption.UIThread, true, p => p.Target == "AgainEnterNoPrint");
        }