Exemple #1
0
 public void SaveChanges()
 {
     trainingBindingSource.EndEdit();
     try
     {
         _proxy.Save();
         //saveBarButton.Enabled = false;
     }
     catch (Exception exception)
     {
         ViewHelper.ShowErrorMessage("Error has occured while saving the training information.", exception);
     }
 }
 public void SaveChanges()
 {
     try
     {
         var tlist = (List <EmployeeInfoTraining>)attendanceBindingSource.List;
         var ta    = _proxy.Context.TrainingAttendances.Where(t => t.TrainingId == _trainingId);
         foreach (var t in tlist)
         {
             if (t.Attended)
             {
                 var x = (from r in ta
                          where r.EmployeeId == t.EmployeeId
                          select r).FirstOrDefault();
                 if (x == null)
                 {
                     var obj = new TrainingAttendance()
                     {
                         TrainingId = _trainingId, EmployeeId = t.EmployeeId
                     };
                     _proxy.Context.TrainingAttendances.AddObject(obj);
                 }
                 continue;
             }
             else
             {
                 var x = (from r in ta
                          where r.EmployeeId == t.EmployeeId
                          select r).FirstOrDefault();
                 if (x != null)
                 {
                     _proxy.Context.TrainingAttendances.DeleteObject(x);
                 }
                 continue;
             }
         }
         _proxy.Save();
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception exception)
     {
         ViewHelper.ShowErrorMessage("Error has occured while saving attendance information.", exception);
     }
 }
Exemple #3
0
 public void SaveChanges()
 {
     trainingRequestBindingSource.EndEdit();
     trainingRequest = (TrainingRequest)trainingRequestBindingSource.Current;
     try
     {
         var t = new Training();
         trainingRequest.trainings.Add(t);
         trainingRequest.Status = Training.StatusPending;
         _proxy.Context.TrainingRequests.AddObject(trainingRequest);
         _proxy.Save();
         this.DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception exception)
     {
         ViewHelper.ShowErrorMessage("Error occured when savind training request", exception);
     }
 }