public UserLoginViewModel() { _rule = new AccountRule(); _rule.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("IsBusy")) { IsBusy = _rule.IsBusy; } }; _rule.LoginCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { Common.ServiceDataLocator.Register<Account>(e.Results); LoginName = string.Empty; LoginPwd = string.Empty; //Account account = Common.ServiceDataLocator.GetInstance<Account>(); // int i = 1; _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdViewName = CmdViewName.MainView, Entity = null, Target = "Sell", }); } }; this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdName) { case CmdName.New: break; case CmdName.Edit: break; case CmdName.Manager: break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "UserLoginViewModel"); }
public AccountViewModel() { _rule = new AccountRule(); _roleRule = new RoleRule(); _rule.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("IsBusy")) { IsBusy = _rule.IsBusy; } }; _rule.GetAccountsCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { AccountList = new ObservableCollection<Account>(e.Results); } }; _rule.DelAccountCompleted += (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(StrLoginName)) queryList.Add("Name", StrLoginName.Trim()); if (!string.IsNullOrWhiteSpace(_strLoginNumber)) queryList.Add("Number", StrLoginName.Trim()); _rule.GetAccountsAsyns(queryList); } }; this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdName) { case CmdName.New: StrLoginName = string.Empty; StrLoginNumber = 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; case CmdName.Edit: break; case CmdName.Manager: break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "AccountViewModel"); }
public ToolChangePwd() { InitializeComponent(); _accountRule = new AccountRule(); }
public Sell() { InitializeComponent(); _rule = new AccountRule(); UserLoginView = new Lazy<Views.UserLoginView>(); this.ContentLogin.Content = UserLoginView.Value; GotoLoginView(); eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdViewName) { case CmdViewName.AccountView://账户列表界面 GotoAccountView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.New, Target = "AccountViewModel", }); break; case CmdViewName.MainView://主界面 labWelcome.Text = Common.ServiceDataLocator.GetInstance<Account>().Name; GotoMainView(); break; case CmdViewName.LoginView://登录界面 if (Common.MessageBox.Show("确定退出系统吗?", Common.LED_MessageBoxButton.YesNo) == Common.LED_MessageBoxResult.Yes) { if (Common.ReadCOM.serialport.IsOpen) { Common.ReadCOM.serialport.Close(); } _rule.ExitCurrentAccountAsyns(); Common.ServiceDataLocator.Clear(); GotoLoginView(); } break; case CmdViewName.FormworkMainView://模板列表界面 GotoFormworkMainView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.New, Target = "FormworkMainViewModel", }); break; case CmdViewName.StockInMainView://入库 GotoStockInMainView(param); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, cmdName = CmdName.New, Tag = param.Tag, Target = "StockInMainViewModel", }); break; case CmdViewName.StockOutMainView://出库 GotoStockOutMainView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, cmdName = CmdName.New, Tag = param.Tag, Target = "StockOutMainViewModel", }); break; case CmdViewName.RoleMainView://角色列表 GotoRoleMainView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.New, Target = "RoleMainViewModel", }); break; case CmdViewName.RoleMainDetailView://角色明细 GotoRoleDetailView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "RoleDetailViewModel", }); break; case CmdViewName.QualityInfoMainView://品质信息列表 GotoQualityInfoMainView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.New, Target = "QualityInfoMainViewModel", }); break; case CmdViewName.QualityInfoDetailView://品质信息明细 GotoQualityInfoDetailView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "QualityInfoDetailViewModel", }); break; case CmdViewName.FormworkDetailView://模版明细 GotoFormworkDetailView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "FormworkDetailViewModel", }); break; case CmdViewName.Process_JianBaoView://减薄 GotoProcess_JianBaoView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, cmdName = CmdName.New, Tag = param.Tag, Target = "Process_JianBaoViewModel", }); break; case CmdViewName.Process_PaoGuangView://抛光 GotoProcess_PaoGuangView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Tag = param.Tag, Target = "Process_PaoGuangViewModel", }); break; case CmdViewName.Process_DuMoView://镀膜 GotoProcess_DuMoView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "Process_DuMoViewModel", }); break; case CmdViewName.AccountDetailView://账户明细 GotoAccountDetailView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "AccountDetailViewModel", }); break; case CmdViewName.Process_FanGongView://返工 GotoProcess_FanGongView(); break; case CmdViewName.ImportStockLotView: GotoImportStockLotView(); break; case CmdViewName.ModifyGlassIDView: GotoModifyGlassIDView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, cmdName = CmdName.New, Target = "ModifyGlassIDViewModel", }); break; case CmdViewName.ToolScanGlassID_StockInView: GotoToolScanGlassID_StockInView(param); break; case CmdViewName.ToolScanGlassID_PaoGuangView: GotoToolScanGlassID_PaoGuangView(param); break; case CmdViewName.ToolEnterNoToPrintView: GotoToolEnterNoToPrintView(param); break; case CmdViewName.ToolScanGlassID_JianBaoView: GotoToolScanGlassID_JianBaoView(param); break; case CmdViewName.ToolScanGlassID_StockOutView: GotoToolScanGlassID_StockOutView(param); break; case CmdViewName.StockLotMainView: GotoStockLotMainView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = param.cmdName, // Entity = param.Entity, Target = "StockLotMainViewModel", }); break; case CmdViewName.StockLotDetailView: GotoStockLotDetailView(); eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { Entity = param.Entity, Target = "StockLotDetailViewModel", }); break; case CmdViewName.ToolExportGlassIDsView: GotoToolExportGlassIDsView(param); break; case CmdViewName.ToolReplaceGlassID: GotoToolReplaceGlassID(param); break; case CmdViewName.AgainEnterNoPrint: GotoAgainEnterNoPrint(param); break; case CmdViewName.CloseApplication: if (!(Common.MessageBox.Show("确定直接关闭系统吗?", Common.LED_MessageBoxButton.YesNo) == Common.LED_MessageBoxResult.Yes)) { //e.Cancel = true; } else { _rule.ExitCurrentAccountAsyns(); Application.Current.Shutdown(); } break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "Sell"); }
public AccountDetailViewModel() { _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); //订阅 _eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { string ErrMsg = string.Empty; RoleCollection = new ObservableCollection<Role>(_roleRule.GetRoleList(new Dictionary<string, string>(), ref ErrMsg)); CurrentAccount = param.Entity as Account; if (CurrentAccount == null) CurrentAccount = new Account(); else { CurrentRole = RoleCollection.FirstOrDefault(p => p.ID == CurrentAccount.RoleID); } }, ThreadOption.UIThread, true, p => p.Target == "AccountDetailViewModel"); // CurrentAccount = new Account(); _rule = new AccountRule(); _rule.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("IsBusy")) { IsBusy = _rule.IsBusy; } }; _rule.AddAccountCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { Common.MessageBox.Show("添加成功"); _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdViewName = CmdViewName.AccountView, Target = "Sell", }); } }; _rule.ModifyAccountCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { Common.MessageBox.Show("修改成功"); _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdViewName = CmdViewName.AccountView, Target = "Sell", }); } }; _roleRule = new RoleRule(); _roleRule.GetRolesCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { RoleCollection = e.Results as ObservableCollection<Role>; } }; }