Exemple #1
0
        public void PutClinicInList(DoctorClinicViewModel doctorClinicViewModel, RoutedEventHandler onDelete = null)
        {
            StackPanel stackPanel = new StackPanel();

            stackPanel.Children.Add(new TextBlock()
            {
                Visibility = Visibility.Hidden,
                Text       = doctorClinicViewModel.IdClinic.ToString()
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text = language.Name + " : " + doctorClinicViewModel.ClinicsName
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text = language.Since + " : " + doctorClinicViewModel.Since
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text = language.Until + " : " + doctorClinicViewModel.UntilDate
            });
            if (onDelete != null)
            {
                Button deleteButton = new Button()
                {
                    Content = language.Delete
                };
                deleteButton.Click += onDelete;

                stackPanel.Children.Add(deleteButton);
            }
            ClinicsListBox.Items.Add(stackPanel);
            ClinicsListBox.Items.Refresh();
        }
        public void DeleteClinic(RoutedEventArgs e)
        {
            StackPanel            item                  = (e.OriginalSource as Button).Parent as StackPanel;
            string                sinceDate             = (item.Children[2] as TextBlock).Text.Substring(language.Since.Count() + 2);
            DoctorClinicViewModel doctorClinicViewModel = new DoctorClinicViewModel()
            {
                IdClinic = int.Parse((item.Children[0] as TextBlock).Text),
                Since    = DateTime.Parse(sinceDate)
            };

            doctor.GetClinics().Remove(doctor.GetClinics().Where(x => x.IdClinic == doctorClinicViewModel.IdClinic && x.Since == doctorClinicViewModel.Since).Single());
            ClinicsListBox.Items.Remove(item);
            ClinicsListBox.Items.Refresh();
        }
        public void WorkInClinic(DatePicker sinceDatePicker, DatePicker untilDatePicker, RoutedEventHandler onDelete)
        {
            ClinicViewModel       clinicViewModel       = ClinicComboBox.SelectedItem as ClinicViewModel;
            DateTime              since                 = sinceDatePicker.SelectedDate.Value;
            DateTime?             until                 = untilDatePicker.SelectedDate != null ? untilDatePicker.SelectedDate : null;
            DoctorClinicViewModel doctorClinicViewModel = new DoctorClinicViewModel()
            {
                IdClinic  = clinicViewModel.IdClinic,
                Since     = since,
                UntilDate = until,
                IdDoctor  = doctor.IdDoctor
            };

            doctor.GetClinics().Add(Mapping.Mapper.Map <DoctorClinic>(doctorClinicViewModel));
            PutClinicInList(doctorClinicViewModel, onDelete);
            untilDatePicker.SelectedDate = null;
            sinceDatePicker.SelectedDate = null;
            ClinicComboBox.SelectedItem  = null;
        }
        public void PutClinicInList(DoctorClinicViewModel doctorClinicViewModel, RoutedEventHandler onDelete = null)
        {
            StackPanel stackPanel = new StackPanel
            {
                CanVerticallyScroll   = true,
                CanHorizontallyScroll = true
            };

            stackPanel.Children.Add(new TextBlock()
            {
                Visibility = Visibility.Hidden,
                Text       = doctorClinicViewModel.IdClinic.ToString()
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text  = language.Name + " : " + doctorClinicViewModel.ClinicsName,
                Style = CurrentDictionary[textBlockStyle] as Style
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text  = language.Since + " : " + doctorClinicViewModel.Since,
                Style = CurrentDictionary[textBlockStyle] as Style
            });
            stackPanel.Children.Add(new TextBlock()
            {
                Text  = language.Until + " : " + doctorClinicViewModel.UntilDate,
                Style = CurrentDictionary[textBlockStyle] as Style
            });
            if (onDelete != null)
            {
                Button deleteButton = new Button()
                {
                    Content  = language.Delete,
                    Style    = CurrentDictionary[buttonStyle] as Style,
                    MaxWidth = 100,
                    Width    = 80
                };
                deleteButton.Click += onDelete;
                stackPanel.Children.Add(deleteButton);
            }
            ClinicsListBox.Items.Add(stackPanel);
            ClinicsListBox.Items.Refresh();
        }