Пример #1
0
		/// <summary>
		/// Get the matching entries.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="currentID"></param>
		/// <param name="form"></param>
		/// <param name="ws"></param>
		/// <returns></returns>
		public static List<ExtantReversalIndexEntryInfo> ExtantEntries(FdoCache cache, string form, int ws)
		{
			List<ExtantReversalIndexEntryInfo> al = new List<ExtantReversalIndexEntryInfo>();
			if (form == null || form == String.Empty)
				return al;

			s_form = form;

			SqlConnection sqlCon = new SqlConnection(
				string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
				+ "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));
			sqlCon.Open();
			SqlDataReader sqlreader = null;
			try
			{
				SqlCommand sqlComm = sqlCon.CreateCommand();
				//sqlComm.CommandText = "SELECT Id, Form"
				//    + " FROM ReversalIndexEntry_"
				//    + " WHERE LOWER(RTRIM(LTRIM(Form))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%'"
				//    + "		AND WritingSystem = @ws"
				//    + "	ORDER BY Id, Form";
				sqlComm.CommandText = "SELECT Obj, Txt" +
					" FROM ReversalIndexEntry_ReversalForm" +
					" WHERE LOWER(RTRIM(LTRIM(Txt))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%' AND Ws=@ws" +
					" ORDER BY Obj, Txt";
				sqlComm.Parameters.AddWithValue("@form", form);
				sqlComm.Parameters.AddWithValue("@ws", ws.ToString());
				sqlreader =	sqlComm.ExecuteReader(System.Data.CommandBehavior.Default);
				while (sqlreader.Read())
				{
					ExtantReversalIndexEntryInfo eriei = new ExtantReversalIndexEntryInfo();
					eriei.ID = sqlreader.GetInt32(0);
					eriei.Form = sqlreader.GetString(1);
					al.Add(eriei);
				}
			}
			catch (Exception err)
			{
				Debug.WriteLine(err.Message);
			}
			finally
			{
				try
				{
					if (sqlreader != null && !sqlreader.IsClosed)
						sqlreader.Close();
				}
				finally
				{
					try
					{
						sqlCon.Close();
					}
					catch
					{
					}
				}
			}

			return al;
		}
Пример #2
0
		public void SetDlgInfo(Mediator mediator, WindowParams wp, List<IReversalIndexEntry> filteredEntries)
		{
			CheckDisposed();

			Debug.Assert(filteredEntries != null && filteredEntries.Count > 0);

			m_mediator = mediator;
			m_cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
			m_ws = (filteredEntries[0] as ReversalIndexEntry).ReversalIndex.WritingSystemRAHvo;
			m_owningIndex = (filteredEntries[0] as ReversalIndexEntry).Owner;
			// Don't bother filtering out the current entry -- we don't do it for lex entries, why
			// do it here? (SFM 4/23/2009 Why? because it causes a crash, so uncommented)
			foreach (IReversalIndexEntry rie in filteredEntries)
			{
				ExtantReversalIndexEntryInfo eriei = new ExtantReversalIndexEntryInfo();
				eriei.ID = rie.Hvo;
				m_filteredEntries.Add(eriei);
			}
			// End SFM edit

			btnOK.Text = wp.m_btnText;
			Text = wp.m_title;
			label1.Text = wp.m_label;

			m_tbForm.Font = new Font(
					m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_ws).DefaultSerif,
					10);
			m_tbForm.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
			m_tbForm.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_tbForm.WritingSystemCode = m_ws;
			m_tbForm.AdjustStringHeight = false;
			m_tsf = TsStrFactoryClass.Create();
			m_tbForm.Tss = m_tsf.MakeString("", m_ws);
			m_tbForm.TextChanged += new EventHandler(m_tbForm_TextChanged);

			btnInsert.Visible = false;
			btnHelp.Visible = true;

			switch(Text)
			{
				case "Find Reversal Entry":
					m_helpTopic = "khtpFindReversalEntry";
					break;
				case "Move Reversal Entry":
					m_helpTopic = "khtpMoveReversalEntry";
					break;
			}
			if(m_helpTopic != null && FwApp.App != null) // FwApp.App could be null during tests
			{
				this.helpProvider = new System.Windows.Forms.HelpProvider();
				this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
				this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(m_helpTopic, 0));
				this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
			}
			Debug.Assert(m_mediator != null);
			ReplaceMatchingItemsControl();

			// Adjust things if the form box needs to grow to accommodate its style.
			int oldHeight = m_tbForm.Height;
			int newHeight = Math.Max(oldHeight, m_tbForm.PreferredHeight);
			int delta = newHeight - oldHeight;
			if (delta != 0)
			{
				m_tbForm.Height = newHeight;
				FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_tbForm);
			}
		}
Пример #3
0
        /// <summary>
        /// Get the matching entries.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="currentID"></param>
        /// <param name="form"></param>
        /// <param name="ws"></param>
        /// <returns></returns>
        public static List <ExtantReversalIndexEntryInfo> ExtantEntries(FdoCache cache, string form, int ws)
        {
            List <ExtantReversalIndexEntryInfo> al = new List <ExtantReversalIndexEntryInfo>();

            if (form == null || form == String.Empty)
            {
                return(al);
            }

            s_form = form;

            SqlConnection sqlCon = new SqlConnection(
                string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
                              + "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));

            sqlCon.Open();
            SqlDataReader sqlreader = null;

            try
            {
                SqlCommand sqlComm = sqlCon.CreateCommand();
                //sqlComm.CommandText = "SELECT Id, Form"
                //    + " FROM ReversalIndexEntry_"
                //    + " WHERE LOWER(RTRIM(LTRIM(Form))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%'"
                //    + "		AND WritingSystem = @ws"
                //    + "	ORDER BY Id, Form";
                sqlComm.CommandText = "SELECT Obj, Txt" +
                                      " FROM ReversalIndexEntry_ReversalForm" +
                                      " WHERE LOWER(RTRIM(LTRIM(Txt))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%' AND Ws=@ws" +
                                      " ORDER BY Obj, Txt";
                sqlComm.Parameters.AddWithValue("@form", form);
                sqlComm.Parameters.AddWithValue("@ws", ws.ToString());
                sqlreader = sqlComm.ExecuteReader(System.Data.CommandBehavior.Default);
                while (sqlreader.Read())
                {
                    ExtantReversalIndexEntryInfo eriei = new ExtantReversalIndexEntryInfo();
                    eriei.ID   = sqlreader.GetInt32(0);
                    eriei.Form = sqlreader.GetString(1);
                    al.Add(eriei);
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.Message);
            }
            finally
            {
                try
                {
                    if (sqlreader != null && !sqlreader.IsClosed)
                    {
                        sqlreader.Close();
                    }
                }
                finally
                {
                    try
                    {
                        sqlCon.Close();
                    }
                    catch
                    {
                    }
                }
            }

            return(al);
        }