private void UpdateLotInfo() { ClearLotDetails(); if (lotEdit.EditValue == null) { return; } try { m_lotSplit.StockLot = StockLot.GetStockLot(lotEdit.EditValue.ToString()); SetLotDetails(); } catch (Exception ex) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("Error updating Lot details:\r{0}", ex.Message); } }
public IAsyncResult BeginAddStockLot(string checkCode, int AccountID, StockLot entity, ref int StockLotID, ref string ErrMsg, AsyncCallback callback, object asyncState) { IncrementCallCount(); var pCallback = new AsyncCallback((ar) => { DecrementCallCount(); callback(ar); }); return _client.BeginAddStockLot(checkCode, AccountID, entity, ref StockLotID, ref ErrMsg, pCallback, asyncState); }
public bool AddStockLot(string checkCode, int AccountID, StockLot entity, ref int StockLotID, ref string ErrMsg) { throw new NotImplementedException(); }
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", }); }; }
public Process_JianBaoViewModel() { _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); //订阅 _eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdName) { case CmdName.New: CurrentStockLot = new StockLot(); TXTLOTNOISEnabled = true; ReadComTest(); CountInfo = string.Empty;//统计初始化 Account loginAcount = Common.ServiceDataLocator.GetInstance<Account>(); if (!loginAcount.LoginNumber.Equals("admin")) { HOLDVisibility = Visibility.Collapsed; string roleDetail = loginAcount.Role.RoleDetail; if (roleDetail.Contains(_roleRule.str减薄后检验 + _roleRule.str接触HOLD)) HOLDVisibility = Visibility.Visible; } else { HOLDVisibility = Visibility.Visible; } if (!string.IsNullOrWhiteSpace(param.Tag)) { CurrentStockLot.LotNo = param.Tag; _stockLotRule.GetStockLotEntityByLotNoAsyns(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll); } break; case CmdName.SaveGlassID: SaveEntity = param.Entity as StockDetail; SaveEntity.Status = STATIC_STATUS; _stockLotRule.ModifyStockDetailListAsyns(SaveEntity); // _stockLotRule.UpdateStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, 2); break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "Process_JianBaoViewModel"); _roleRule = new RoleRule(); _stockLotRule = new StockLotRule(); _stockLotRule.GetStockLotEntityByLotNoCompleted += (s, e) => { if (e.Cancelled || e.Results == null) { Common.MessageBox.Show(e.Error.Message); } else { TXTLOTNOISEnabled = false; _lineNumber = 1; CurrentStockLot = e.Results as StockLot; CurrentStockLot.StockDetails = CurrentStockLot.StockDetails.OrderByDescending(p => p.JianBaoDT).ToArray(); CountInfo = string.Format(" 入库数:{0} PCS HOLD数:{2} 当前已减薄数:{1} PCS", _stockLotRule.StockInQty, _stockLotRule.OperaterQty, _stockLotRule.HOLDQty); _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.Enter, Target = "Process_JianBaoView", }); } }; _stockLotRule.ModifyStockDetailListCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { List<StockDetail> sd = CurrentStockLot.StockDetails.ToList(); SaveEntity.StockLot = CurrentStockLot; sd.Add(SaveEntity); CurrentStockLot.StockDetails = sd.OrderByDescending(p => p.StockInDT).ToArray(); int StockInQty = 0; int OperaterQty = 0; int FanGongQty = 0; int HOLDQty = 0; string ErrMsg = string.Empty; if (_stockLotRule.GetStockLotEntityByLotNoTotal(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll, ref StockInQty, ref OperaterQty, ref FanGongQty, ref HOLDQty, ref ErrMsg)) CountInfo = string.Format(" 入库数:{0} PCS HOLD数:{2} 当前已减薄数:{1} PCS", StockInQty, OperaterQty, HOLDQty); //_stockLotRule.GetStockLotEntityByLotNoAsyns(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll); GlassID = string.Empty; } isDispose = false; }; //验证GlassID方法调用成功后 _stockLotRule.CheckStockDetailStatusCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); GlassID = string.Empty; isDispose = false; } else { StockDetail entity = e.Results as StockDetail; _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdViewName = CmdViewName.ToolScanGlassID_JianBaoView, Entity = entity, Tag = CurrentStockLot.ImageHOLD, cmdName = CmdName.New, Target = "Sell", }); } }; //修改HOLD成功后回调事件 _stockLotRule.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状态成功"); } } }; ScanComExecute = (s, e) => { GlassID = s.ToString(); _stockLotRule.CheckStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, STATIC_STATUS); // _stockLotRule.UpdateStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, 2);//todo是否验证写死了 // AddStockDetailAsyns(); }; }
public void AddStockLotAsyns(StockLot entity) { string ErrMsg = string.Empty; int tmpStockID = 0; Proxy.BeginAddStockLot(CurrentAccount.CheckCode, CurrentAccount.ID, entity, ref tmpStockID, ref ErrMsg, result => { ThreadHelper.BeginInvokeOnUIThread(() => { try { bool bResult = Proxy.EndAddStockLot(ref tmpStockID, ref ErrMsg, result); if (bResult) { StockID = tmpStockID; AddStockLotCompleted(this, new ResultArgs<bool>(bResult, null, false, result.AsyncState)); } else { AddStockLotCompleted(this, new ResultArgs<bool>(bResult, new Exception(ErrMsg), true, result.AsyncState)); } } catch (Exception ex) { if (AddStockLotCompleted != null) { AddStockLotCompleted(this, new ResultArgs<bool>(false, ex, true, result.AsyncState)); } } }); }, null); }
/// <summary> /// 批量从Excel中导入GlassID到数据库(异步) /// </summary> /// <param name="fileName">Excel完整路径</param> /// <param name="ProductModel">产品型号</param> /// <param name="LotNo"></param> public void AddStockLotAndDetailsAsyns(string fileName, StockLot entity) { string ErrMsg = string.Empty; int tmpStockID = 0; if (entity.IsImport)//如果为导入模版 { ImportStockLot import = new ImportStockLot(); List<StockDetail> detailList = import.ImportToXls(fileName, ref ErrMsg); if (detailList == null || detailList.Count() <= 0) { AddStockLotAndDetailsCompleted(this, new ResultArgs<bool>(false, new Exception(ErrMsg), true, null)); return; } entity.StockDetails = detailList.ToArray(); entity.PCSQty = detailList.Count(); } //StockLot entity = new StockLot(); //entity.Status = 8; //entity.LotNo = LotNo; //entity.PCSQty = detailList.Count(); //entity.ProModel = ProductModel; //foreach (StockDetail item in detailList) //{ // } entity.CreateAccountID = CurrentAccount.ID; entity.CreateAccountName = CurrentAccount.Name; Proxy.BeginAddStockLot(CurrentAccount.CheckCode, CurrentAccount.ID, entity, ref tmpStockID, ref ErrMsg, result => { ThreadHelper.BeginInvokeOnUIThread(() => { try { bool bResult = Proxy.EndAddStockLot(ref tmpStockID, ref ErrMsg, result); if (bResult) { StockID = tmpStockID; AddStockLotAndDetailsCompleted(this, new ResultArgs<bool>(bResult, null, false, result.AsyncState)); } else { AddStockLotAndDetailsCompleted(this, new ResultArgs<bool>(bResult, new Exception(ErrMsg), true, result.AsyncState)); } } catch (Exception ex) { if (AddStockLotAndDetailsCompleted != null) { AddStockLotAndDetailsCompleted(this, new ResultArgs<bool>(false, ex, true, result.AsyncState)); } } }); }, null); }