private void Validation_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (Validation != null)
         {
             if (Validation.SelectedItem is ModelHCI.MedicationHCI)
             {
                 SelectedRow          = (ModelHCI.MedicationHCI)Validation.SelectedItem;
                 Valid_Grid.Margin    = new Thickness(0, 0, 0, 0);
                 Valid_Label.Margin   = new Thickness(0, 0, 0, 0);
                 Storage_Label.Margin = new Thickness(0, 0, 0, 0);
                 Storage_Grid.Margin  = new Thickness(0, 0, 0, 0);
                 Panel.SetZIndex(Storage_Grid, 1);
                 Panel.SetZIndex(Valid_Grid, 1);
                 MyEvents.RefreshMedEventHandelr.RaiseMyCustomEvent(this, new MyEvents.RefreshMeds());
                 Details.Navigate(new Uri("/Pages/Meds/ValidationDetails.xaml", UriKind.Relative));
             }
         }
     } catch (Exception)
     {
     }
 }
        private void Generate_Click(object sender, RoutedEventArgs e)
        {
            autoList.Visibility = Visibility.Collapsed;
            boxic.Visibility    = Visibility.Collapsed;
            if (Medication.Text.Equals("") && HourlyUsage.SelectedItem == null)
            {
                ErrorMessage.Visibility = Visibility.Visible;
            }
            else
            {
                ModelHCI.MedicationHCI medForPrescription = null;
                foreach (ModelHCI.MedicationHCI med in ModelHCI.MedicationData.meds)
                {
                    if (med.name.ToLower().Trim().Equals(Medication.Text.Trim().ToLower()))
                    {
                        medForPrescription = med;
                    }
                }

                ModelHCI.PrescriptionHCI prescription = new ModelHCI.PrescriptionHCI();
                prescription.medication         = medForPrescription;
                prescription.dateOfPrescription = DateTime.Today;
                prescription.patient            = Appointments.currentExamination.appointment.patient;
                prescription.id = 15;
                if (HourlyUsage.SelectedIndex != 0)
                {
                    prescription.intake = int.Parse((string)HourlyUsage.SelectedItem);
                }
                else
                {
                    prescription.intake = 0;
                }
                prescription.reasonWhy = HowToUSe.Text;
                ExportPrescrption.ExportAsPdf(prescription);
            }
        }