示例#1
0
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagridThesaurus(DBString ThesaurusID)
        {
            try
              {
            string sSortColumn = "Keyword";
            int nSelectedRow = -1;

            // Storing the previous sort order
            if (dtgThesaurus.DataSource != null)
            {
              sSortColumn = ((DataTable) dtgThesaurus.DataSource).DefaultView.Sort;
            }

            if (m_allDataThes == null)
            {
              // Retrieving data from BusinessServices

              // Retrieving Thesaurus
              IThesaurusService srv = ServiceFactory.GetThesaurusService();
              Thesaurus filter = new Thesaurus(ThesaurusID);
              filter.FilterOnIsactive = DBInt.Null;
              m_allDataThes = srv.ThesaurusSelectFiltered(filter);

              // Retrieving ProgramKeyword
              IProgramService srvP = ServiceFactory.GetProgramService();
              DBGuid ProgramID = new DBGuid(new Guid(m_sCurrentID));
              ProgramKeywordContainer allDataPK = srvP.SelectChildrenByProgramOfKeyword(ProgramID);

              // Hide selected Thesaurus items
              for (int i = 0; i < allDataPK.All.Count; i++)
              {
            DBString KeywordRef = ((ProgramKeyword) allDataPK.All.Items[i]).KeywordRef;
            Thesaurus selected = (Thesaurus) m_allDataThes[KeywordRef.ToString()];
            if (selected != null)
            {
              m_allDataThes.Delete(selected);
            }
              }
            }
            // Fill Thesaurus grid
            DataTable dt = m_allDataThes.CurrentAsDatatable;
            dt.DefaultView.Sort = sSortColumn;
            dtgThesaurus.DataSource = dt;

            // Fill Thesaurus "detail" grid
            DataTable dtDetail = m_allDataThes.DeletedAsDatatable;
            dtDetail.DefaultView.Sort = sSortColumn;
            dtgThesaurusDetail.DataSource = dtDetail;

            // Locates the row specified by ID param
            if (!ThesaurusID.IsNull)
            {
              BindingManagerBase bm = dtgExpert.BindingContext[dtgThesaurus.DataSource, dtgThesaurus.DataMember];
              int nPositionStart = bm.Position;
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            if (ThesaurusID.Value.Equals(dr["Keyword"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
              bm.Position = nPositionStart;
            }

            // Makes the row selected
            if (nSelectedRow <= ((DataTable) dtgThesaurus.DataSource).DefaultView.Count && nSelectedRow > -1)
            {
              dtgThesaurus.Select(nSelectedRow);
              dtgThesaurus.CurrentRowIndex = nSelectedRow;
            }
            else if (((DataTable) dtgThesaurus.DataSource).DefaultView.Count != 0)
            {
              dtgThesaurus.Select(0);
            }

            // Enabling or disabling the buttons according to record count.
            // And is because of previous disable state.
            bool bIsEmptyGrid = (((DataTable) dtgThesaurus.DataSource).DefaultView.Count == 0);
            btnAddThesaurus.Enabled = ! bIsEmptyGrid;
            btnDetailThesaurus.Enabled = ! bIsEmptyGrid;

            bIsEmptyGrid = (((DataTable) dtgThesaurusDetail.DataSource).DefaultView.Count == 0);
            btnRemoveThesaurus.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a tezaurusz lista frissítése során.", ex);
              }
        }
示例#2
0
        public ThesaurusContainer ThesaurusSelectForFilter(Thesaurus filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            string filterOnKeyword = filter.Keyword;
            if (filterOnKeyword.Length == 0)
            {
              filterOnKeyword = "%"; // return all
            }
            else
            {
              filterOnKeyword = filterOnKeyword.Replace("%", "%");
              filterOnKeyword = filterOnKeyword.Replace("_", "\\_");
              filterOnKeyword = filterOnKeyword.Replace("*", "%");
              filterOnKeyword = filterOnKeyword.Replace("?", "_");
            }

            ThesaurusContainer result;
            DataSet entitySet = m_DataContext.ndihdThesaurusSelectForFilter(
              filterOnKeyword);
            result = new ThesaurusContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
 public virtual ThesaurusContainer ThesaurusSelectAll()
 {
     TraceCallEnterEvent.Raise();
       try
       {
     ThesaurusContainer result;
     DataSet entitySet = m_DataContext.ndihdThesaurusSelectAll();
     result = new ThesaurusContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
示例#4
0
        public ThesaurusContainer ThesaurusSelectFiltered(Thesaurus filter)
        {
            // Check permission: Administrator
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            ThesaurusContainer result;
            DataSet entitySet = m_DataContext.ndihdThesaurusSelectFiltered(
              filter.FilterOnKeyword,
              filter.FilterOnIsactive);
            result = new ThesaurusContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }