private void btnAddToList_Click(object sender, EventArgs e) { if (lkeMedications.EditValue == null || lkeDoses.EditValue == null) { XtraMessageBox.Show("You select Medication and Dosage before adding", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DefaultBoolean.Default); return; } if (PEMRBusinessLogic.ActivePEMRObject == null) { return; } if (PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_Medication == null) { PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_Medication = new List <VisitTiming_Medication>(); } VisitTiming_Medication medication = null; medication = PEMRBusinessLogic.CreateNew_VisitTiming_Medication(lkeMedications.EditValue, lkeDoses.EditValue, isDateInterval ? null : spnTimePerDay.EditValue, isDateInterval ? null : TimeDuration, isDateInterval ? dtFrom_DateInterval.EditValue : dtFrom_TimeInterval.EditValue, isDateInterval ? dtTo_DateInterval.EditValue : dtTo_TimeInterval.EditValue, txtDescription.EditValue, ApplicationStaticConfiguration.PEMRSavingMode); if (medication != null) { PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_Medication.Add(medication); } grdTreatmentPlans.DataSource = PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_Medication.FindAll( item => !Convert.ToInt32(item.PEMRElementStatus).Equals(Convert.ToInt32(PEMRElementStatus.Removed))); grdTreatmentPlans.RefreshDataSource(); ClearControls(true); }