public StockLotDetailViewModel() { _quInforule = new QualityInfoRule(); _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); _rule = new StockLotRule(); _roleRule = new RoleRule(); _rule.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("IsBusy")) { IsBusy = _rule.IsBusy; } }; //订阅 _eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { GlassSearchId = string.Empty; string LotNo = param.Entity as string; _rule.GetStockLotEntityByLotNoAsyns(LotNo, 99, true); Account loginAcount = Common.ServiceDataLocator.GetInstance<Account>(); if (!loginAcount.LoginNumber.Equals("admin")) { ExportVisibility = Visibility.Collapsed; HOLDVisibility = Visibility.Collapsed; UnHOLDVisibility = Visibility.Collapsed; string roleDetail = loginAcount.Role.RoleDetail; if (roleDetail.Contains(_roleRule.str查询GlassID + _roleRule.str导出)) ExportVisibility = Visibility.Visible; if (roleDetail.Contains(_roleRule.str查询GlassID + _roleRule.strHOLD)) HOLDVisibility = Visibility.Visible; if (roleDetail.Contains(_roleRule.str查询GlassID + _roleRule.str接触HOLD)) UnHOLDVisibility = Visibility.Visible; } else { ExportVisibility = Visibility.Visible; HOLDVisibility = Visibility.Visible; UnHOLDVisibility = Visibility.Visible; } //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; //} string ErrMsg = string.Empty; List<QualityInfo> lst = _quInforule.GetQualityInfoList(new Dictionary<string, string>(), ref ErrMsg); if (lst != null) { StockInList = new ObservableCollection<string>(lst.Where(p => p.InfoType == "入库").Select(p => p.Name)); StockInList.Insert(0, "全部"); JianBaoList = new ObservableCollection<string>(lst.Where(p => p.InfoType == "减薄").Select(p => p.Name)); JianBaoList.Insert(0, "全部"); PaoGuangList = new ObservableCollection<string>(lst.Where(p => p.InfoType == "抛光").Select(p => p.Name)); PaoGuangList.Insert(0, "全部"); DuMoList = new ObservableCollection<string>(lst.Where(p => p.InfoType == "镀膜").Select(p => p.Name)); DuMoList.Insert(0, "全部"); StockInSelect = "全部"; JianBaoSelect = "全部"; PaoGuangSelect = "全部"; DuMoSelect = "全部"; } }, ThreadOption.UIThread, true, p => p.Target == "StockLotDetailViewModel"); _rule.GetStockLotEntityByLotNoCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { _lineNumber = 1; CurrentStockLot = e.Results; //LineNumber = 1; StockDetailCollection = new ObservableCollection<StockDetail>(CurrentStockLot.StockDetails); if (CurrentStockLot.StockDetails != null) { double operaterCount = CurrentStockLot.StockDetails.Where(p => p.Status > 0).Count(); double holdCount = CurrentStockLot.StockDetails.Where(p => p.IsHOLD).Count(); LotNoInfo = string.Format("当前LotNO:{0} 总GlassID数:{1} ,实际操作数:{2} ,其中HOLD数:{3} 。另:退货数为:{4}", CurrentStockLot.LotNo, CurrentStockLot.PCSQty, operaterCount, holdCount, CurrentStockLot.TuiHuoCount); double stockinCount = CurrentStockLot.StockDetails.Where(p => p.StockInDT != null).Count(); StockInInfo = string.Format("已完成入库检验的GlassID:{0},所占比例:{1}%", stockinCount, (stockinCount / operaterCount) * 100); double jianbaoCount = CurrentStockLot.StockDetails.Where(p => p.JianBaoDT != null).Count(); JianBaoInfo = string.Format("已完成减薄后检验的GlassID:{0},所占比例:{1}%", jianbaoCount, (jianbaoCount / operaterCount) * 100); double paoguangCount = CurrentStockLot.StockDetails.Where(p => p.PaoGuangDT != null).Count(); PaoGuangInfo = string.Format("已完成抛光后检验的GlassID:{0},所占比例:{1}%", paoguangCount, (paoguangCount / operaterCount) * 100); double dumoCount = CurrentStockLot.StockDetails.Where(p => p.DuMoDT != null).Count(); DuMoInfo = string.Format("已完成镀膜后检验的GlassID:{0},所占比例:{1}%", dumoCount, (dumoCount / operaterCount) * 100); } } }; //修改HOLD成功后回调事件 _rule.ChangeStockDetail_HOLDCompleted += (s, e) => { bool bHOLD = (bool)e.UserState; if (e.Cancelled) { CurrentDetail.IsHOLD = !bHOLD; Common.MessageBox.Show(e.Error.Message); } else { if (bHOLD) { Common.MessageBox.Show(CurrentDetail.GlassID + " 设置HOLD状态成功"); } else { Common.MessageBox.Show(CurrentDetail.GlassID + " 取消HOLD状态成功"); } // CurrentDetail.IsHOLD = (bool)e.UserState; } }; }
public void SetCheckList(string iType) { ugMain.Children.Clear(); _rule = new QualityInfoRule(); string ErrMsg = string.Empty; Dictionary<string, string> queryList = new Dictionary<string, string>(); queryList.Add("Type", iType); List<QualityInfo> lst = _rule.GetQualityInfoList(queryList, ref ErrMsg); if (lst != null) { foreach (QualityInfo item in lst) { CheckBox cb = new CheckBox(); cb.Click += (s, e) => { string strcondition = string.Empty; foreach (var cbitem in ugMain.Children) { CheckBox tmpcb = cbitem as CheckBox; if (tmpcb != null && tmpcb.IsChecked.Value) { strcondition += tmpcb.Content.ToString() + ","; } } eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = strcondition, Target = "CheckBoxButtonListView", }); }; cb.Content = item.Name; ugMain.Children.Add(cb); } } }