Ejemplo n.º 1
0
        private void EditStudy_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.SelectedStudyHeader == null)
            {
                MessageDisplay.Show("Please select a Study.");

                return;
            }

            try
            {
                #region CHECK FOR OPEN STUDIES

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() != typeof(ControlWindow))
                    {
                        continue;
                    }

                    UserControlBase controlBase = window.GetPropertyValue("ControlContent").To <UserControlBase>();

                    if (controlBase.GetType() != typeof(EditStudy))
                    {
                        continue;
                    }

                    StudyHeader studyHeader = controlBase.GetPropertyValue("SubjectHeader").To <StudyHeader>();

                    if (studyHeader.StudyHeaderId <= 0)
                    {
                        continue;
                    }

                    window.Focus();

                    this.CloseIfNotMainWindow(true);

                    return;
                }

                #endregion


                EditStudy edit = new EditStudy(this.SelectedStudyHeader);

                ControlDialog.Show(this.SelectedStudyHeader.StudyName, edit, "SaveStudy", autoSize: false);

                this.CloseIfNotMainWindow(true);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
        private void NewStudy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.newStudy = new EditStudy();

                ControlDialog.ControlDialogClosing += this.ControlDialog_Closing;

                ControlDialog.Show("New Study", this.newStudy, "SaveStudy", autoSize: false, owner: Application.Current.MainWindow);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
        public bool TryEditStudy()
        {
            if (this.SelectedStudyHeader == null)
            {
                MessageDisplay.Show("Please select a Study.");

                return(false);
            }

            #region CHECK FOR OPEN STUDIES

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() != typeof(ControlWindow))
                {
                    continue;
                }

                UserControlBase controlBase = window.GetPropertyValue("ControlContent").To <UserControlBase>();

                if (controlBase.GetType() != typeof(EditStudy))
                {
                    continue;
                }

                StudyHeader studyHeader = controlBase.GetPropertyValue("SubjectHeader").To <StudyHeader>();

                if (studyHeader.StudyHeaderId <= 0 ||
                    studyHeader.StudyHeaderId != this.SelectedStudyHeader.StudyHeaderId)
                {
                    continue;
                }

                window.Focus();

                return(true);
            }

            #endregion

            EditStudy edit = new EditStudy(this.SelectedStudyHeader);

            ControlDialog.Show(this.SelectedStudyHeader.StudyName, edit, "SaveStudy", autoSize: false, owner: Application.Current.MainWindow);

            return(true);
        }