private void SaveCustomReason()
 {
     if (ReasonListBox.Items.FindByText(SaveReasonAsName.Text) != null)
     {
         // update
         StudyDeleteReasonAdaptor adaptor  = new StudyDeleteReasonAdaptor();
         CannedTextSelectCriteria criteria = new CannedTextSelectCriteria();
         criteria.Label.EqualTo(SaveReasonAsName.Text);
         criteria.Category.EqualTo(REASON_CANNEDTEXT_CATEGORY);
         IList <CannedText> reasons = adaptor.Get(criteria);
         foreach (CannedText reason in reasons)
         {
             CannedTextUpdateColumns rowColumns = new CannedTextUpdateColumns();
             rowColumns.Text = Comment.Text;
             adaptor.Update(reason.Key, rowColumns);
         }
     }
     else
     {
         // add
         StudyDeleteReasonAdaptor adaptor    = new StudyDeleteReasonAdaptor();
         CannedTextUpdateColumns  rowColumns = new CannedTextUpdateColumns();
         rowColumns.Category = REASON_CANNEDTEXT_CATEGORY;
         rowColumns.Label    = SaveReasonAsName.Text;
         rowColumns.Text     = Comment.Text;
         adaptor.Add(rowColumns);
     }
 }
示例#2
0
        private void EnsurePredefinedReasonsLoaded()
        {
            ReasonListBox.Items.Clear();

            ICannedTextEntityBroker  broker   = HttpContextData.Current.ReadContext.GetBroker <ICannedTextEntityBroker>();
            CannedTextSelectCriteria criteria = new CannedTextSelectCriteria();

            criteria.Category.EqualTo(REASON_CANNEDTEXT_CATEGORY);
            IList <CannedText> list = broker.Find(criteria);

            if (SessionManager.Current.User.IsInRole(Enterprise.Authentication.AuthorityTokens.Study.SaveReason))
            {
                ReasonListBox.Items.Add(new ListItem(SR.CustomReason, SR.CustomReasonComment));
            }
            else
            {
                ReasonListBox.Items.Add(new ListItem(SR.SelectOne, string.Empty));
            }
            foreach (CannedText text in list)
            {
                ReasonListBox.Items.Add(new ListItem(text.Label, text.Text));
            }
        }