private void SetTrainBackground(string empId) { TrainingManager mTrainManager = new TrainingManager(); List <TrainingItem> trainList = new List <TrainingItem>(); if (trainCollection.Count != 0) { trainCollection.Remove(selectedTrainItem); foreach (var item in trainCollection) { trainList.Add(item); } } if (!string.IsNullOrEmpty(tbTitle.Text)) { var trainItem = new TrainingItem(); trainItem._EMP_ID = empId; trainItem._TITLE = tbTitle.Text; trainItem._INSTITUTION = tbInstitution.Text; trainItem._TRAINING_LOCATION = tbLocation.Text; trainItem._TRAINING_DATE = dpTrainingFinished.Text; trainList.Add(trainItem); } mTrainManager.DeleteTrainData(empId); foreach (var item in trainList) { mTrainManager.SaveTrainingData(item); } }