Exemple #1
0
        /// <summary>
        /// Получение запрашиваемой uc для отображения
        /// </summary>
        /// <param name="key">ключ (см. AppController) связанный с uc</param>
        /// <returns></returns>
        internal async Task <UserControl> GetUcViewAsync(string key)
        {
            //получаем экземпляр
            dynamic uc = _appController.GetUcViewInput(key);

            switch (key)
            {
            case "Ob":
                _observationVM = uc.ViewModel;
                _observationVM.ButtonSaveClicked += AddVM_ButtonSaveClicked;
                await SetupObservationUc();

                break;

            case "Ex":
                _examinationVM = uc.ViewModel;
                _examinationVM.ButtonSaveClicked += AddVM_ButtonSaveClicked;
                await SetupExaminationUc();

                break;

            case "Ho":
                _hospitalizationVM = uc.ViewModel;
                _hospitalizationVM.ButtonSaveClicked += AddVM_ButtonSaveClicked;
                await SetupHospitalizationUc();

                break;

            default:
                throw new ArgumentException(nameof(key));
            }

            return(uc as UserControl);
        }
        public AddHospitalizationView(AddHospitalizationViewModel viewModel)
        {
            InitializeComponent();
            ViewModel = viewModel;

            _dateTimePickerStart.DataBindings.Add("Value",
                                                  ViewModel, nameof(ViewModel.StartHospitalizationDate),
                                                  true, DataSourceUpdateMode.OnPropertyChanged);
            _dateTimePickerEnd.DataBindings.Add("Value",
                                                ViewModel, nameof(ViewModel.EndHospitalizationDate),
                                                true, DataSourceUpdateMode.OnPropertyChanged);
            _textBoxDiag.DataBindings.Add("Text", ViewModel, nameof(ViewModel.DefinitiveDiagnosis));
            _textBoxMedOrg.DataBindings.Add("Text", ViewModel, nameof(ViewModel.MedicalOrganization));

            _labelCount.DataBindings.Add("Text", ViewModel, nameof(ViewModel.Count));

            _buttonSave.Click += (s, e) => ViewModel.SaveHospitalization();
        }
        //public Form GetAutorizationForm()
        //{
        //    return _autorizationView;
        //}

        public UserControl GetUcViewInput(string key)
        {
            switch (key)
            {
            case "Ob":
                var vmO = new AddObservationViewModel();
                var ucO = new AddObservationView(vmO);
                return(ucO);

            case "Ex":
                var vmE = new AddExaminationViewModel();
                var ucE = new AddExaminationView(vmE);
                return(ucE);

            case "Ho":
                var vmH = new AddHospitalizationViewModel();
                var ucH = new AddHospitalizationView(vmH);
                return(ucH);

            default:
                throw new ArgumentException(nameof(key));
            }
        }