public void Refresh()
 {
     if (!StudyListGridView.IsDataSourceSet())
     {
         StudyListGridView.SetDataSource();
     }
     StudyListGridView.RefreshCurrentPage();
     SearchUpdatePanel.Update();
 }
        protected void AssignAuthorityGroupsButton_Click(object sender, ImageClickEventArgs e)
        {
            StudyListGridView.RefreshCurrentPage();
            var args = new SearchPanelButtonClickedEventArgs
            {
                SelectedStudies = StudyListGridView.SelectedStudies
            };

            EventsHelper.Fire(_assignAuthorityGroupsButtonClickedHandler, this, args);
        }
        protected void SearchButton_Click(object sender, ImageClickEventArgs e)
        {
            if (DisplaySearchWarning)
            {
                StudyListGridView.DataBindOnPreRender     = false;
                ConfirmStudySearchMessageBox.Message      = SR.NoFiltersSearchWarning;
                ConfirmStudySearchMessageBox.MessageStyle = "font-weight: bold; color: #205F87;";
                ConfirmStudySearchMessageBox.Show();
            }
            else
            {
                StudyListGridView.Refresh();
            }
            var sb = new StringBuilder();

            if (!String.IsNullOrEmpty(PatientId.Text))
            {
                sb.AppendFormat("PatientId={0};", PatientId.Text);
            }
            if (!String.IsNullOrEmpty(PatientName.Text))
            {
                sb.AppendFormat("PatientsName={0};", PatientName.Text);
            }
            if (!String.IsNullOrEmpty(AccessionNumber.Text))
            {
                sb.AppendFormat("AccessionNumber={0};", AccessionNumber.Text);
            }
            if (!String.IsNullOrEmpty(ToStudyDate.Text) || !String.IsNullOrEmpty(FromStudyDate.Text))
            {
                sb.AppendFormat("StudyDate={0}-{1};", FromStudyDate.Text, ToStudyDate.Text);
            }
            if (!String.IsNullOrEmpty(StudyDescription.Text))
            {
                sb.AppendFormat("StudyDescription={0};", StudyDescription.Text);
            }
            if (ModalityListBox.SelectedIndex < 0)
            {
                bool first = true;
                foreach (ListItem item in ModalityListBox.Items)
                {
                    if (!item.Selected)
                    {
                        continue;
                    }

                    if (first)
                    {
                        sb.AppendFormat("ModalitiesInStudy={0}", item.Value);
                        first = false;
                    }
                    else
                    {
                        sb.AppendFormat(",{0}", item.Value);
                    }
                }
                if (!first)
                {
                    sb.Append(';');
                }
            }

            var helper = new QueryAuditHelper(ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success,
                                              new AuditPersonActiveParticipant(SessionManager.Current.Credentials.UserName,
                                                                               null,
                                                                               SessionManager.Current.Credentials.DisplayName),
                                              ServerPartition.AeTitle, ServerPlatform.HostId, sb.ToString());

            ServerPlatform.LogAuditMessage(helper);
        }
 internal void Reset()
 {
     Clear();
     StudyListGridView.Reset();
 }
        private void SetupChildControls()
        {
            foreach (StudyStatusEnum s in  StudyStatusEnum.GetAll())
            {
                StatusListBox.Items.Add(new ListItem {
                    Text = ServerEnumDescription.GetLocalizedDescription(s), Value = s.Lookup
                });
            }

            ClearToStudyDateButton.Attributes["onclick"]   = ScriptHelper.ClearDate(ToStudyDate.ClientID, ToStudyDateCalendarExtender.ClientID);
            ClearFromStudyDateButton.Attributes["onclick"] = ScriptHelper.ClearDate(FromStudyDate.ClientID, FromStudyDateCalendarExtender.ClientID);
            ToStudyDate.Attributes["OnChange"]             = ScriptHelper.CheckDateRange(FromStudyDate.ClientID, ToStudyDate.ClientID, ToStudyDate.ClientID, ToStudyDateCalendarExtender.ClientID, "To Date must be greater than From Date");
            FromStudyDate.Attributes["OnChange"]           = ScriptHelper.CheckDateRange(FromStudyDate.ClientID, ToStudyDate.ClientID, FromStudyDate.ClientID, FromStudyDateCalendarExtender.ClientID, "From Date must be less than To Date");

            GridPagerTop.InitializeGridPager(SR.GridPagerStudySingleItem, SR.GridPagerStudyMultipleItems, StudyListGridView.TheGrid,
                                             () => StudyListGridView.ResultCount, ImageServerConstants.GridViewPagerPosition.Top);
            StudyListGridView.Pager = GridPagerTop;

            ConfirmStudySearchMessageBox.Confirmed += delegate
            {
                StudyListGridView.DataBindOnPreRender =
                    true;
                StudyListGridView.Refresh();
                if (SearchUpdatePanel.UpdateMode ==
                    UpdatePanelUpdateMode.Conditional)
                {
                    SearchUpdatePanel.Update();
                }
            };
            ConfirmStudySearchMessageBox.Cancel += delegate
            {
                StudyListGridView.DataBindOnPreRender = false;
            };

            RestoreMessageBox.Confirmed += delegate(object data)
            {
                if (data is IList <Study> )
                {
                    var studies = data as IList <Study>;
                    foreach (Study study in studies)
                    {
                        _controller.RestoreStudy(study);
                    }
                }
                else if (data is IList <StudySummary> )
                {
                    var studies = data as IList <StudySummary>;
                    foreach (StudySummary study in studies)
                    {
                        _controller.RestoreStudy(study.TheStudy);
                    }
                }
                else if (data is Study)
                {
                    var study = data as Study;
                    _controller.RestoreStudy(study);
                }

                DataBind();
                SearchUpdatePanel.Update();                 // force refresh
            };

            StudyListGridView.DataSourceCreated += delegate(StudyDataSource source)
            {
                source.Partition   = ServerPartition;
                source.DateFormats = ToStudyDateCalendarExtender.Format;

                if (!String.IsNullOrEmpty(PatientId.Text))
                {
                    source.PatientId = SearchHelper.TrailingWildCard(PatientId.Text);
                }
                if (!String.IsNullOrEmpty(PatientName.Text))
                {
                    source.PatientName = SearchHelper.NameWildCard(PatientName.Text);
                }
                if (!String.IsNullOrEmpty(AccessionNumber.Text))
                {
                    source.AccessionNumber = SearchHelper.TrailingWildCard(AccessionNumber.Text);
                }
                if (!String.IsNullOrEmpty(ToStudyDate.Text))
                {
                    source.ToStudyDate = ToStudyDate.Text;
                }
                if (!String.IsNullOrEmpty(FromStudyDate.Text))
                {
                    source.FromStudyDate = FromStudyDate.Text;
                }
                if (!String.IsNullOrEmpty(StudyDescription.Text))
                {
                    source.StudyDescription = SearchHelper.LeadingAndTrailingWildCard(StudyDescription.Text);
                }
                if (!String.IsNullOrEmpty(ReferringPhysiciansName.Text))
                {
                    source.ReferringPhysiciansName = SearchHelper.NameWildCard(ReferringPhysiciansName.Text);
                }
                if (!String.IsNullOrEmpty(ResponsiblePerson.Text))
                {
                    source.ResponsiblePerson = SearchHelper.NameWildCard(ResponsiblePerson.Text);
                }
                if (!String.IsNullOrEmpty(ResponsibleOrganization.Text))
                {
                    source.ResponsibleOrganization = SearchHelper.NameWildCard(ResponsibleOrganization.Text);
                }

                if (ModalityListBox.SelectedIndex > -1)
                {
                    var modalities = new List <string>();
                    foreach (ListItem item in ModalityListBox.Items)
                    {
                        if (item.Selected)
                        {
                            modalities.Add(item.Value);
                        }
                    }
                    source.Modalities = modalities.ToArray();
                }

                if (StatusListBox.SelectedIndex > -1)
                {
                    var statuses = new List <string>();
                    foreach (ListItem status in StatusListBox.Items)
                    {
                        if (status.Selected)
                        {
                            statuses.Add(status.Value);
                        }
                    }
                    source.Statuses = statuses.ToArray();
                }
            };

            //Set Roles
            ViewImagesButton.Roles            = AuthorityTokens.Study.ViewImages;
            ViewStudyDetailsButton.Roles      = AuthorityTokens.Study.View;
            MoveStudyButton.Roles             = AuthorityTokens.Study.Move;
            DeleteStudyButton.Roles           = AuthorityTokens.Study.Delete;
            RestoreStudyButton.Roles          = AuthorityTokens.Study.Restore;
            AssignAuthorityGroupsButton.Roles = Macro.ImageServer.Enterprise.Authentication.AuthorityTokens.Study.EditDataAccess;
        }