public FormworkDetailViewModel()
 {
     _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
     //订阅
     _eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
     {
         CurrentFormwork = param.Entity as FormWork;
         IdKeyWordsTmp = new IDKeyWordsEx();
         if (CurrentFormwork == null)
         {
             CurrentFormwork = new FormWork();
             IsProModelEnb = true;
         }
         else
         {
             IsProModelEnb = false;
             IdKeyWordsTmp.Assignment(CurrentFormwork.IDKeyWords, CurrentFormwork.IDNumber);
         }
     }, ThreadOption.UIThread, true, p => p.Target == "FormworkDetailViewModel");
     _rule = new FormworkRule();
     _rule.PropertyChanged += (s, e) =>
         {
             if (e.PropertyName.Equals("IsBusy"))
             {
                 this.IsBusy = _rule.IsBusy;
             }
         };
     _rule.AddFormworkCompleted += (s, e) =>
        {
            if (e.Cancelled)
            {
                Common.MessageBox.Show(e.Error.Message);
            }
            else
            {
                Common.MessageBox.Show("添加成功");
                _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                {
                    cmdViewName = CmdViewName.FormworkMainView,
                    Target = "Sell",
                });
            }
        };
     _rule.ModifyFormworkCompleted += (s, e) =>
         {
             if (e.Cancelled)
             {
                 Common.MessageBox.Show(e.Error.Message);
             }
             else
             {
                 Common.MessageBox.Show("修改成功");
                 _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                 {
                     cmdViewName = CmdViewName.FormworkMainView,
                     Target = "Sell",
                 });
             }
         };
 }
        public ImportStockLotViewModel()
        {
            _rule = new StockLotRule();
            _formworkRule = new FormworkRule();
            _rule.AddStockLotAndDetailsCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                    {
                        Common.MessageBox.Show("新建LotNo成功!");
                        GuanKongMulti = false;
                        GuanKongSingle = false;
                    }
                };
            _formworkRule.GetFormworkListCompleted += (s, e) =>
            {
                if (e.Cancelled)
                {
                    Common.MessageBox.Show(e.Error.Message);
                }
                else
                {
                    FormWorkCollection = new ObservableCollection<string>(e.Results.Select(p => p.ProductModel));
                }
            };
            _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {

            }, ThreadOption.UIThread, true, p => p.Target == "ImportStockLotViewModel");
        }
        public ToolScanGlassID_StockOutViewModel()
        {
            this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _rule = new FormworkRule();
            this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {
                switch (param.cmdName)
                {
                    case CmdName.New:
                        CurrentStockDetail = param.Entity as StockDetail;
                        CurrentStockDetail.DuMoDT = DateTime.Now;
                        IsWu = true;
                        IsDanMian = false;
                        IsShuangMian = false;
                        //CurrentStockDetail.IsPaoGuang = true;

                        if (param.Tag != null && param.Tag.Contains("镀膜"))
                        {
                            IsImgHOLD = true;
                        }
                        else
                            IsImgHOLD = false;

                        string ErrMsg = string.Empty;
                        FormWork fw = _rule.GetFormWorkByProModel(CurrentStockDetail.StockLot.ProModel, ref ErrMsg);
                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.New,
                            Entity = fw,
                            Entity1 = CurrentStockDetail.StockLot,
                            //      Tag = param.Tag,
                            Target = "ToolScanGlassID_StockOutView",
                        });
                        break;

                    case CmdName.SendTag:
                        if ((!string.IsNullOrWhiteSpace(param.Tag)) && CurrentStockDetail.StockLot.ImageHOLD.Contains("镀膜"))
                        {
                            if (string.IsNullOrWhiteSpace(param.Entity.ToString()))
                            {
                                Common.MessageBox.Show("当前已勾选品质信息,所以在图形界面中至少需要勾选一个或以上的单元");
                                return;
                            }
                        }

                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.Close,
                            Target = "ToolScanGlassID_StockOutView",
                        });

                        CurrentStockDetail.DuMoImgInfo = param.Entity.ToString();
                        CurrentStockDetail.DuMoInfo = param.Tag;
                        if (IsWu)
                            CurrentStockDetail.IsPaoGuangOverInfo = "无";
                        if (IsDanMian)
                            CurrentStockDetail.IsPaoGuangOverInfo = "单面";
                        if (IsShuangMian)
                            CurrentStockDetail.IsPaoGuangOverInfo = "双面";
                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.SaveGlassID,
                            Entity = CurrentStockDetail,
                            Target = "StockOutMainViewModel",
                        });
                        break;
                }
            }, ThreadOption.UIThread, true, p => p.Target == "ToolScanGlassID_StockOutViewModel");
        }
Example #4
0
        public StockInMainViewModel()
        {
            _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _rule = new RoleRule();
            //订阅
            _eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {
                switch (param.cmdName)
                {
                    case CmdName.New:
                        IsCheck = (bool)param.Entity;
                        _stockLotRule.QtyCount = 0;
                        CurrentStockLot = new StockLot();
                        LotNoEnabled = true;

                        StockInHOLD = false;
                        DuMoHOLD = false;
                        PaoGuangHOLD = false;
                        JianBaoHOLD = false;

                        DuMoImgHOLD = false;
                        PaoGuangImgHOLD = false;
                        JianBaoImgHOLD = false;

                        SumQty = 0;// CurrentStockLot.StockDetails.Count();
                        SurQty = 0;
                        TXTLOTNOISEnabled = true;
                        HOLDQty = "    HOLD数:0 PCS    ";
                        ReadComTest();
                        Account loginAcount = Common.ServiceDataLocator.GetInstance<Account>();
                        if (!loginAcount.LoginNumber.Equals("admin"))
                        {
                            HOLDVisibility = Visibility.Collapsed;
                            EndStockLotVisibility = Visibility.Collapsed;
                            string roleDetail = loginAcount.Role.RoleDetail;
                            if (roleDetail.Contains(_rule.str扫描入库 + _rule.str接触HOLD))
                                HOLDVisibility = Visibility.Visible;
                            if (roleDetail.Contains(_rule.str扫描入库 + _rule.str入库结束))
                                EndStockLotVisibility = Visibility.Visible;
                        }
                        else
                        {
                            HOLDVisibility = Visibility.Visible;
                            EndStockLotVisibility = Visibility.Visible;
                        }
                        if (!string.IsNullOrWhiteSpace(param.Tag))
                        {
                            CurrentStockLot.LotNo = param.Tag;
                            _stockLotRule.GetStockLotEntityByLotNo_ExAsyns(CurrentStockLot.LotNo, 1, IsCheckAll);
                        }
                        break;
                    case CmdName.SaveGlassID:
                        StockDetail entity = param.Entity as StockDetail;
                        AddStockDetailAsyns(entity);
                        break;
                    default:
                        break;
                }

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

            _formworkRule = new FormworkRule();
            _formworkRule.GetFormworkListCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                    {
                        FormWorkCollection = new ObservableCollection<string>(e.Results.Select(p => p.ProductModel));
                    }
                };
            _stockLotRule = new StockLotRule();
            _stockLotRule.GetStockLotEntityByLotNo_ExCompleted += (s, e) =>
            {
                if (e.Cancelled)
                {
                    Common.MessageBox.Show(e.Error.Message);
                }
                else
                {
                    TXTLOTNOISEnabled = false;
                    LineNumber = 1;
                    CurrentStockLot = e.Results as StockLot;
                    ControlsEnabled = (CurrentStockLot == null);
                    LotNoEnabled = ControlsEnabled;
                    if (!ControlsEnabled)
                    {
                        HOLDQty = "    HOLD数:" + _stockLotRule.HOLDQty_Ex + " PCS    ";
                        if (CurrentStockLot.StockDetails != null)//如果它的Glass明细不为空
                        {
                          //  if (_stockLotRule.QtyCount <= 0)  2014年5月6日 12:56:26  无意义
                          //  {
                                SumQty = _stockLotRule.IStockInQty;// CurrentStockLot.StockDetails.Count();
                                SurQty = CurrentStockLot.PCSQty - SumQty;
                           // }
                            CurrentStockLot.StockDetails = CurrentStockLot.StockDetails.OrderByDescending(p => p.StockInDT).ToArray();
                        }
                        if (CurrentStockLot.DetailInfoHOLD != null)
                        {
                            StockInHOLD = CurrentStockLot.DetailInfoHOLD.Contains("入库");
                            DuMoHOLD = CurrentStockLot.DetailInfoHOLD.Contains("镀膜");
                            PaoGuangHOLD = CurrentStockLot.DetailInfoHOLD.Contains("抛光");
                            JianBaoHOLD = CurrentStockLot.DetailInfoHOLD.Contains("减薄");
                        }
                        if (CurrentStockLot.ImageHOLD != null)
                        {
                            DuMoImgHOLD = CurrentStockLot.ImageHOLD.Contains("镀膜");
                            PaoGuangImgHOLD = CurrentStockLot.ImageHOLD.Contains("抛光");
                            JianBaoImgHOLD = CurrentStockLot.ImageHOLD.Contains("减薄");
                        }
                        CurrentFormwork = CurrentStockLot.ProModel;
                        if (CurrentStockLot.Status > 0 && CurrentStockLot.Status < 8)
                        {
                            Common.MessageBox.Show("该LotNo已结束");
                            return;
                        }

                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.Enter,
                            Target = "StockInMainView",
                        });
                    }
                    else
                    {
                        // _formworkRule.GetFormWorkListAsyns();
                    }
                }
            };

            _stockLotRule.AddStockDetailCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                        GlassID = string.Empty;
                    }
                    else
                    {
                        GlassID = string.Empty;
                        SumQty = _stockLotRule.QtyCount;
                        SurQty = CurrentStockLot.PCSQty - SumQty;

                        _stockLotRule.GetStockLotEntityByLotNo_ExAsyns(CurrentStockLot.LotNo, 1, IsCheckAll);
                    }
                    isDispose = false;
                };
            _stockLotRule.GetStockDetailListCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                    {
                        //ObservableCollection<StockDetail> tmppdetails = new ObservableCollection<StockDetail>(e.Results);
                        CurrentStockLot.StockDetails = e.Results.OrderByDescending(p => p.CreateDt).ToArray();
                        LineNumber = 1;
                    }
                };
            _stockLotRule.AddStockLotCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                    {
                        CurrentStockLot.ID = _stockLotRule.StockID;
                        SumQty = 0;
                        SurQty = CurrentStockLot.PCSQty - SumQty;
                        ControlsEnabled = false;
                    }
                };
            _stockLotRule.ModifyStockDetailListCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                        _stockLotRule.GetStockLotEntityByLotNo_ExAsyns(CurrentStockLot.LotNo, 1, IsCheckAll);
                };
            ScanComExecute = (s, e) =>
               {
                   string ErrMsg = string.Empty;
                   if (!_stockLotRule.CheckStockDetail_In(s.ToString(), CurrentStockLot.ID, IsCheck, ref ErrMsg))
                   {
                       //if (ErrMsg.Equals("特殊处理:退货"))
                       //{
                       //    if (!(Common.MessageBox.Show("该ID曾经退货,确定再次入库吗?", Common.LED_MessageBoxButton.YesNo) == Common.LED_MessageBoxResult.Yes))
                       //    {
                       //        isDispose = false;
                       //        return;
                       //    }
                       //}
                       //else
                       //{

                       Common.MessageBox.Show(ErrMsg);
                       isDispose = false;
                       return;
                       //  }
                   }
                   GlassID = s.ToString();
                   //   AddStockDetailAsyns();
                   _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                   {
                       cmdViewName = CmdViewName.ToolScanGlassID_StockInView,
                       cmdName = CmdName.New,
                       Entity = CurrentStockLot,
                       Target = "Sell",
                   });
               };
        }
Example #5
0
        public FormworkMainViewModel()
        {
            _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _roleRule = new RoleRule();
            _eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {
                switch (param.cmdName)
                {
                    case CmdName.New:
                        StrProduct = string.Empty;
                        Account loginAcount = Common.ServiceDataLocator.GetInstance<Account>();
                        if (!loginAcount.LoginNumber.Equals("admin"))
                        {
                            AddVisibility = Visibility.Collapsed;
                            ModifyVisibility = Visibility.Collapsed;
                            DeleteVisibility = Visibility.Collapsed;

                            string roleDetail = loginAcount.Role.RoleDetail;
                            if (roleDetail.Contains(_roleRule.str模版管理 + _roleRule.str添加))
                                AddVisibility = Visibility.Visible;
                            if (roleDetail.Contains(_roleRule.str模版管理 + _roleRule.str修改))
                                ModifyVisibility = Visibility.Visible;
                            if (roleDetail.Contains(_roleRule.str模版管理 + _roleRule.str删除))
                                DeleteVisibility = Visibility.Visible;
                        }
                        else
                        {
                            AddVisibility = Visibility.Visible;
                            ModifyVisibility = Visibility.Visible;
                            DeleteVisibility = Visibility.Visible;
                        }
                        break;
                }
            }, ThreadOption.UIThread, true, p => p.Target == "FormworkMainViewModel");
            _rule = new FormworkRule();
            _rule.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName.Equals("IsBusy"))
                {
                    IsBusy = _rule.IsBusy;
                }
            };
            _rule.GetFormworkListCompleted += (s, e) =>
            {
                if (e.Cancelled)
                {
                    Common.MessageBox.Show(e.Error.Message);
                }
                else
                {
                    FormworkCollection = new ObservableCollection<FormWork>(e.Results);
                }
            };
            _rule.DelFormworkCompleted += (s, e) =>
                {
                    if (e.Cancelled)
                    {
                        Common.MessageBox.Show(e.Error.Message);
                    }
                    else
                    {
                        Common.MessageBox.Show("删除成功");
                        Dictionary<string, string> queryList = new Dictionary<string, string>();
                        if (!string.IsNullOrWhiteSpace(StrProduct))
                            queryList.Add("Product", StrProduct.Trim());
                        _rule.GetFormWorkListAsyns(queryList);
                    }
                };
        }
        public ToolScanGlassID_JianBaoViewModel()
        {
            this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            _rule = new FormworkRule();
            this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param =>
            {

                switch (param.cmdName)
                {
                    case CmdName.New:
                        CurrentStockDetail = param.Entity as StockDetail;
                        CurrentStockDetail.JianBaoDT = DateTime.Now;
                        CurrentStockDetail.IsPaoGuang = true;
                        if (param.Tag != null && param.Tag.Contains("减薄"))
                        {
                            IsImgHOLD = true;
                        }
                        else
                            IsImgHOLD = false;
                        IsHOLD = false;
                        string ErrMsg = string.Empty;
                        FormWork fw = _rule.GetFormWorkByProModel(CurrentStockDetail.StockLot.ProModel, ref ErrMsg);
                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.New,
                            Entity = fw,
                            Entity1 = CurrentStockDetail.StockLot,
                            //      Tag = param.Tag,
                            Target = "ToolScanGlassID_JianBaoView",
                        });
                        break;

                    case CmdName.SendTag:
                        if (string.IsNullOrWhiteSpace(CurrentStockDetail.JianBaoNum))
                        {
                            Common.MessageBox.Show("必须输入减薄槽号");
                            return;
                        }
                        //如果勾选了品质信息和LOT 具有图片减薄品质信息开关
                        if ((!string.IsNullOrWhiteSpace(param.Tag)) && CurrentStockDetail.StockLot.ImageHOLD.Contains("减薄"))
                        {
                            if (string.IsNullOrWhiteSpace(param.Entity.ToString()))
                            {
                                Common.MessageBox.Show("当前已勾选品质信息,所以在图形界面中至少需要勾选一个或以上的单元");
                                return;
                            }
                        }
                        //CF面判断,必须选择至少一项
                        if (CurrentStockDetail.IsPaoGuang)
                        {
                            if ((!IsTFT) && (!IsCF))
                            {
                                Common.MessageBox.Show("抛光面至少需要选择一项");
                                return;
                            }
                        }
                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                       {
                           cmdName = CmdName.Close,
                           Target = "ToolScanGlassID_JianBaoView",
                       });

                        CurrentStockDetail.IsHOLD = IsHOLD;
                        CurrentStockDetail.JianBaoImgInfo = param.Entity.ToString();
                        CurrentStockDetail.JianBaoInfo = param.Tag;
                        if (CurrentStockDetail.IsPaoGuang)
                        {
                            if (IsFuFei)
                                CurrentStockDetail.PaoguangType = "付费抛光";
                            else
                                CurrentStockDetail.PaoguangType = "制程抛光";
                            string strPaoGuangMian = string.Empty;//抛光面
                            if (IsTFT)
                                strPaoGuangMian += "TFT面,";
                            if (IsCF)
                                strPaoGuangMian += "CF面";

                            CurrentStockDetail.PaoGuangMian = strPaoGuangMian;
                        }
                        _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                        {
                            cmdName = CmdName.SaveGlassID,
                            Entity = CurrentStockDetail,
                            Target = "Process_JianBaoViewModel",
                        });
                        break;
                }

                //if (CurrentStockLot != null)
                //{
                //    if (CurrentStockLot.DetailInfoHOLD != null)
                //        ControlsEnabled = CurrentStockLot.DetailInfoHOLD.Contains("入库");
                //    else
                //        ControlsEnabled = false;

                //    _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam()
                //    {
                //        cmdName = CmdName.New,
                //        Target = "ToolScanGlassID_StockInView",
                //    });
                //}
            }, ThreadOption.UIThread, true, p => p.Target == "ToolScanGlassID_JianBaoViewModel");
        }