private void btnPlay_Click(object sender, System.EventArgs e)
        {
            DialogResult result = XtraMessageBox.Show("Do you want to run serving this patient ?", "Notice",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

            switch (result)
            {
            case DialogResult.Yes:
                if (ActiveQueueResult == null || MerkDBBusinessLogicEngine.ActiveStationPoint == null ||
                    MerkDBBusinessLogicEngine.ActiveStationPointStage == null)
                {
                    return;
                }

                if (ActiveQueueResult == null)
                {
                    return;
                }

                DB_QueueManagerStatus queueManagerStatus = (DB_QueueManagerStatus)ActiveQueueResult.QueueStatusID;
                switch (queueManagerStatus)
                {
                case DB_QueueManagerStatus.Paused:
                case DB_QueueManagerStatus.Served:
                    List <GetPreviousMedicalVisits_Result> previousVisitsList =
                        MerkDBBusinessLogicEngine.GetPreviousMedicalVisitsList(PatientID, true,
                                                                               null, DateTime.Now.Date, DateTime.Now.Date, DoctorID);
                    if (previousVisitsList.Count > 0)
                    {
                        PEMRBusinessLogic.ActivePEMRObject =
                            PEMRBusinessLogic.GetVisitFullTree(previousVisitsList[0]);
                    }
                    break;

                case DB_QueueManagerStatus.Waiting:
                    PEMRBusinessLogic.ActiveVisitTimming = PEMRBusinessLogic.CreateNewVisitTiming(
                        ActiveQueueResult.InvoiceDetailID, MerkDBBusinessLogicEngine.ActiveStationPoint.ID,
                        MerkDBBusinessLogicEngine.ActiveStationPointStage.ID, DoctorID, DateTime.Now,
                        ApplicationStaticConfiguration.PEMRSavingMode);
                    break;
                }

                if (PEMRBusinessLogic.ActiveVisitTimming == null)
                {
                    return;
                }

                ParentPEMRContainer.ShowLeftQueuePanel(true);
                ParentPEMRContainer.ShowPEMRHistoryContainer(ActiveQueueResult, PEMRBusinessLogic.ActiveVisitTimming, true);
                break;
            }
        }
        private void btnSearch_Click(object sender, System.EventArgs e)
        {
            tabQueue.Controls.Clear();

            if ((txtPatientID.EditValue == null || string.IsNullOrEmpty(txtPatientID.Text) ||
                 string.IsNullOrWhiteSpace(txtPatientID.Text)) &&
                (lkeDoctors.EditValue == null || string.IsNullOrEmpty(lkeDoctors.Text) ||
                 string.IsNullOrWhiteSpace(lkeDoctors.Text)) &&
                (txtPatientName.EditValue == null || string.IsNullOrEmpty(txtPatientName.Text) ||
                 string.IsNullOrWhiteSpace(txtPatientName.Text)) &&
                (lkeService.EditValue == null || string.IsNullOrEmpty(lkeService.Text) ||
                 string.IsNullOrWhiteSpace(lkeService.Text)) &&
                (dtFrom.EditValue == null || string.IsNullOrEmpty(dtFrom.Text) ||
                 string.IsNullOrWhiteSpace(dtFrom.Text)) &&
                (dtTo.EditValue == null || string.IsNullOrEmpty(dtTo.Text) || string.IsNullOrWhiteSpace(dtTo.Text)))
            {
                XtraMessageBox.Show("You should write a search criteria before searching.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
                return;
            }

            List <GetPreviousMedicalVisits_Result> previousVisitsList =
                MerkDBBusinessLogicEngine.GetPreviousMedicalVisitsList(txtPatientID.EditValue, true,
                                                                       lkeService.EditValue, dtFrom.EditValue, dtTo.EditValue, lkeDoctors.EditValue);

            if (previousVisitsList.Count == 0)
            {
                XtraMessageBox.Show("No Previous visits found.", "Not Found",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
                return;
            }

            foreach (GetPreviousMedicalVisits_Result medicalVisitsResult in previousVisitsList)
            {
                PEMR_PreviousVisitCard_UC card = new PEMR_PreviousVisitCard_UC();
                card.Dock = DockStyle.Top;
                PEMRObject pemrObject = PEMRBusinessLogic.GetVisitFullTree(medicalVisitsResult);
                if (pemrObject == null)
                {
                    return;
                }
                card.Initialize(ParentContainer, pemrObject, medicalVisitsResult);
                tabQueue.Controls.Add(card);
            }
        }