public PatologyDataSource(string Name, string DateAppear, string DateDisapear, DelegateCommand ArchiveCommand, DelegateCommand RedactCommand, Patology Patology, float Opacity) { this.Name = Name; this.DateAppear = DateAppear; this.DateDisapear = DateDisapear; this.ArchiveCommand = ArchiveCommand; this.RedactCommand = RedactCommand; this.Patology = Patology; this.Opacity = Opacity; if (Opacity == 0.38f) { ArchiveButtonVis = Visibility.Hidden; } else { ArchiveButtonVis = Visibility.Visible; } }
private void SetCurrentPatology(object sender, object data) { isNewTypeAvalible = Visibility.Hidden; isReadOnly = false; PatologyTypes = new ObservableCollection <string>(); PatologyTypesId = new ObservableCollection <int>(); foreach (var Patology in Data.PatologyType.GetAll) { PatologyTypes.Add(Patology.Str); PatologyTypesId.Add(Patology.Id); } CurrentPatology = (Patology)data; CurrentPatient = Data.Patients.Get(CurrentPatology.id_пациента); foreach (var Patology in PatologyTypesId) { if (CurrentPatology.id_патологии == Patology) { Index = PatologyTypesId.IndexOf(Patology); break; } } YearSelectedId = Year.IndexOf(CurrentPatology.YearAppear.Value.Year.ToString()); MonthSelectedId = Month.IndexOf(getmonthNameClassic(CurrentPatology.MonthAppear.Value.Month)); try { YearDissapearSelectedId = Yeard.IndexOf(CurrentPatology.YearDisappear.Value.Year.ToString()); MonthDissapearSelectedId = Monthd.IndexOf(getmonthNameClassic(CurrentPatology.MonthDisappear.Value.Month)); } catch { YearDissapearSelectedId = Yeard.Count - 1; MonthDissapearSelectedId = Monthd.Count - 1; } TextAddOrSave = "Вернуться"; }
public ViewModelAddPathology(NavigationController controller) : base(controller) { Monthd = new ObservableCollection <string>(); Yeard = new ObservableCollection <string>(); Year = new List <string>(); // MonthAndYear = new List<string>(); Month = new ObservableCollection <string>(); Month.Add("Январь"); Month.Add("Февраль"); Month.Add("Март"); Month.Add("Апрель"); Month.Add("Май"); Month.Add("Июнь"); Month.Add("Июль"); Month.Add("Август"); Month.Add("Сентябрь"); Month.Add("Октябрь"); Month.Add("Ноябрь"); Month.Add("Декабрь"); Monthd = new ObservableCollection <string>(Month); for (int i = 1950; i <= DateTime.Now.Year; ++i) { Year.Add(i.ToString()); if (DateTime.Now.Month == 1 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 2 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 3 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 4 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 5 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 6 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 7 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 8 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 9 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 10 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 11 && i == DateTime.Now.Year) { setCurrMonth(i); break; } if (DateTime.Now.Month == 12 && i == DateTime.Now.Year) { setCurrMonth(i); break; } } Yeard = new ObservableCollection <string>(Year); Yeard.Add("-"); Monthd.Add("-"); ReturnBtnName = "Вернуться"; TextAddOrSave = "Добавить"; YearAppearB = Brushes.Gray; MonthAppearB = Brushes.Gray; YearDisappearB = Brushes.Gray; MonthDisappearB = Brushes.Gray; DateAppear = DateTime.Now; DateDisappear = DateTime.Now; MessageBus.Default.Subscribe("GetPatientForAddPatology", SetCurrentPatientID); HasNavigation = true; CurrentPanelViewModel = new PatologyTypePanelViewModel(this); OpenPanelCommand = new DelegateCommand(() => { CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = true; }); ToPathologyListCommand = new DelegateCommand( () => { if (PatologyTypes.Count != 0) { try { Patology buff = new Patology(); // string[] curDate = MonthAndYear[MonthAndYearSelectedId].Split(' '); DateAppear = new DateTime(int.Parse(Year[YearSelectedId]), getmonthName(Month[MonthSelectedId]), 1); buff.MonthAppear = DateAppear; buff.YearAppear = DateAppear; if (Monthd[MonthDissapearSelectedId] != "-" && Yeard[YearDissapearSelectedId] != "-") { buff.isArchivatied = true; DateDisappear = new DateTime(int.Parse(Yeard[YearDissapearSelectedId]), getmonthName(Monthd[MonthDissapearSelectedId]), 1); buff.MonthDisappear = DateDisappear; buff.YearDisappear = DateDisappear; } else { buff.MonthDisappear = null; buff.YearDisappear = null; } buff.id_пациента = CurrentPatient.Id; buff.id_патологии = PatologyTypesId[Index]; Data.Patology.Add(buff); Data.Complete(); MessageBus.Default.Call("GetPatientForPatology", this, CurrentPatient.Id); Controller.NavigateTo <ViewModelPathologyList>(); } catch (Exception ex) { MessageBox.Show("Добавьте патологию"); } } else { MessageBox.Show("Добавьте патологию"); } } ); ToPathologyListNoSaveCommands = new DelegateCommand( () => { MessageBus.Default.Call("GetPatientForPatology", this, CurrentPatient.Id); Controller.NavigateTo <ViewModelPathologyList>(); } ); RevertCommand = new DelegateCommand(() => { CurrentPanelViewModel.PanelOpened = false; Handled = false; }); SaveCommand = new DelegateCommand(() => { var newType = CurrentPanelViewModel.GetPanelType(); if (!string.IsNullOrWhiteSpace(newType.Str)) { CurrentPanelViewModel.PanelOpened = false; Handled = false; Data.PatologyType.Add((newType)); Data.Complete(); MessageBus.Default.Call("GetPatientForAddPatology", this, CurrentPatient.Id); Index = PatologyTypes.Count - 1; } else { MessageBox.Show("Не все поля заполнены"); } }); }