Exemple #1
0
        private void OnTraineeChanged(OperationType operation, TraineeModel trainee)
        {
            switch (operation)
            {
            case OperationType.Add:
                if (trainee.IsNew)    //新建学员
                {
                    string traineeID;
                    _dal.Add(trainee, out traineeID);
                    trainee.TraineeID = traineeID;
                }
                _dal.AddTraineeForBlock(trainee.CurrentBlockID, trainee.TraineeID);
                OverdueChangedEvent?.Invoke();
                break;

            case OperationType.Update:
                _dal.UpdateForBlock(trainee, _currentClassID);
                if (trainee.CurrentBlockID != _currentClassID)
                {
                    operation = OperationType.Delete;
                }
                break;
            }
            TraineeChangedEvent?.Invoke(operation, trainee);
        }
 /// <summary>
 /// 学员信息已更改,更新界面,更新数据库
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="trainee"></param>
 public void OnTraineeChanged(OperationType operation, TraineeModel trainee)
 {
     if (operation == OperationType.Update)
     {
         _dal.Update(trainee);
         if (trainee.RegularClassID != _currentClassID)
         {
             operation = OperationType.Delete;
         }
         OverdueChangedEvent?.Invoke();
     }
     else if (operation == OperationType.Add)
     {
         if (trainee.IsNew)
         {
             string traineeID;
             _dal.Add(trainee, out traineeID);
             trainee.TraineeID = traineeID;
         }
         else
         {
             _dal.AddTraineeForRegular(trainee.RegularClassID, trainee.TraineeID);
         }
         _trainees.Add(trainee);
         OverdueChangedEvent?.Invoke();
     }
     TraineeChangedEvent?.Invoke(operation, trainee);
 }
Exemple #3
0
 /// <summary>
 /// 在列表中添加学员
 /// </summary>
 /// <param name="trainee"></param>
 public void AddTrainee(TraineeModel trainee)
 {
     _trinees.Add(trainee);
     if (!string.IsNullOrEmpty(trainee.CurrentBlockID))
     {
         _blockTrainnesCannotBeChosen.Add(trainee.TraineeID);
     }
     TraineeChangedEvent?.Invoke();
 }
 public PresenceBussiness(TraineeManagementBussiness trainees, RegularClassManagement regular,
                          RegularTraineeBussiness regularTrainees, OverdueManagementBussiness overdue, NameCallingBussiness calling)
 {
     _regular         = regular;
     _trainees        = trainees;
     _overdue         = overdue;
     _calling         = calling;
     _regularTrainees = regularTrainees;
     _regular.RegularClassChangedEvent  += (op, model, index) => RegularClassChangedEvent?.Invoke();
     _regularTrainees.LoadTraineesEvent += traineeCollection =>
     {
         _currentTrainees = traineeCollection;
         TraineeChangedEvent?.Invoke(_currentTrainees);
     };
 }
Exemple #5
0
 /// <summary>
 /// 界面请求对学员进行编辑
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="trainee"></param>
 public void OperateTrainee(OperationType operation, TraineeModel trainee)
 {
     trainee = trainee ?? new TraineeModel();
     trainee.CurrentBlockID = _currentClassID;
     if (operation == OperationType.Delete)
     {
         _dal.DeleteTraineeForBlock(trainee.CurrentBlockID, trainee.TraineeID);
         TraineeChangedEvent?.Invoke(OperationType.Delete, trainee);
         return;
     }
     if (operation == OperationType.Add)
     {
         if (string.IsNullOrEmpty(_currentClassID))
         {
             return;
         }
     }
     TraineeOperation.Enable(operation, trainee);
 }
 /// <summary>
 /// 删除学员
 /// </summary>
 /// <param name="trainee"></param>
 private void DeleteOrReverseTrainee(OperationType operation, TraineeModel trainee)
 {
     if (operation == OperationType.Delete)
     {
         trainee.State++;
     }
     else if (operation == OperationType.Reverse)
     {
         trainee.State--;
     }
     _dal.Update(trainee);
     if (trainee.State == 2)
     {//彻底删除
         TraineeChangedEvent?.Invoke(OperationType.Delete, trainee);
     }
     else
     {//暂时删除或者恢复正常
         _trainees[_trainees.IndexOf(_trainees.Where(t => t.TraineeID == trainee.TraineeID).First())] = trainee;
         _trainees.Sort();
         int newIndex = _trainees.IndexOf(trainee);
         TraineeChangedEvent?.Invoke(OperationType.Update, trainee, newIndex);
     }
 }
Exemple #7
0
 /// <summary>
 /// 在列表中修改学员
 /// </summary>
 /// <param name="trainee"></param>
 public void UpdateTrainee(TraineeModel trainee)
 {
     _trinees[_trinees.IndexOf(_trinees.Where(t => t.TraineeID == trainee.TraineeID).First())] = trainee;
     TraineeChangedEvent?.Invoke();
 }
 public void OperateTrainee(OperationType operation, TraineeModel model)
 {
     TraineeChangedEvent?.Invoke(operation, model);
 }