コード例 #1
0
        void HistoryPaneItem_Click(object sender, SmartItemClickEventArgs e)
        {
            Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem;
            SearchHistoryInfo       his  = item.Tag as SearchHistoryInfo;

            m_sm.FirstResult = 0;
            m_sm.LoadData(SearchExpression.Parse(his.Expression), SearchOrder.Parse(his.Order));
        }
コード例 #2
0
        public bool LoadLayout(AMS.Profile.IProfile profile)
        {
            int r = profile.GetValue("SearchManager." + m_sm.Name, "MaxResult", -1);

            if (r != -1)
            {
                m_sm.MaxResult = r;
            }

            string history = profile.GetValue("SearchManager." + m_sm.Name, "History", string.Empty);

            if (!string.IsNullOrEmpty(history))
            {
                string[] ss = history.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = ss.Length - 1; i >= 0; --i)
                {
                    string s = ss[i];
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    string[] sss = s.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (sss.Length == 0)
                    {
                        continue;
                    }
                    ISearchExpression se = null;
                    try
                    {
                        se = SearchExpression.Parse(sss[0]);
                    }
                    catch (Exception)
                    {
                    }

                    if (se == null)
                    {
                        continue;
                    }
                    IList <ISearchOrder> so = null;
                    if (sss.Length > 1)
                    {
                        so = SearchOrder.Parse(sss[1]);
                    }
                    SearchHistoryInfo his = m_sm.SetHistory(se, so);
                    his.IsCurrentSession = false;
                }
            }

            bool ret = this.searchControlContainer1.LoadLayout(profile);

            return(ret);
        }
コード例 #3
0
        private void tsmCopyHistory_Click(object sender, EventArgs e)
        {
            if (m_currentContextItem == null)
            {
                return;
            }

            SearchHistoryInfo his = m_currentContextItem.Tag as SearchHistoryInfo;

            ClipboardHelper.CopyTextToClipboard(his.Expression);

            m_currentContextItem = null;
        }
コード例 #4
0
        void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 1)
            {
                historyPane.Items.Clear();

                int groupIdx1 = historyPane.Items.Add("历史");

                int idx = 0;
                while (true)
                {
                    SearchHistoryInfo his = m_sm.GetHistory(idx);

                    // 如果为null,则还不存在记录。如果为空,是全部
                    if (his.Expression == null)
                    {
                        break;
                    }

                    string text;
                    if (string.IsNullOrEmpty(his.Expression))
                    {
                        text = "全部";
                    }
                    else
                    {
                        text = his.Expression;
                    }
                    if (!string.IsNullOrEmpty(his.Order))
                    {
                        text += ", ORDER BY " + his.Order;
                    }

                    text = text.Substring(0, Math.Min(text.Length, 100));
                    int childIdx1 = historyPane.Items[groupIdx1].Items.Add(text);
                    historyPane.Items[groupIdx1].Items[childIdx1].Text        = text;
                    historyPane.Items[groupIdx1].Items[childIdx1].ToolTipText = text;
                    historyPane.Items[groupIdx1].Items[childIdx1].Click      += new SmartItemClickEventHandler(HistoryPaneItem_Click);
                    historyPane.Items[groupIdx1].Items[childIdx1].Tag         = his;
                    historyPane.Items[groupIdx1].Items[childIdx1].MouseDown  += new MouseEventHandler(ArchiveSearchForm_MouseDown);
                    idx++;
                }
            }
        }
コード例 #5
0
        public bool SaveLayout(AMS.Profile.IProfile profile)
        {
            if (m_sm == null)
            {
                return(false);
            }
            if (m_sm.MaxResult != SearchManagerDefaultValue.MaxResult)
            {
                profile.SetValue("SearchManager." + m_sm.Name, "MaxResult", m_sm.MaxResult);
            }

            StringBuilder sb  = new StringBuilder();
            int           idx = 0;

            while (true)
            {
                SearchHistoryInfo his = m_sm.GetHistory(idx);
                if (!string.IsNullOrEmpty(his.Expression))
                {
                    sb.Append(his.Expression);
                    if (!string.IsNullOrEmpty(his.Order))
                    {
                        sb.Append(";");
                        sb.Append(his.Order);
                    }
                    sb.Append(Environment.NewLine);

                    idx++;
                }
                else
                {
                    break;
                }
            }
            profile.SetValue("SearchManager." + m_sm.Name, "History", sb.ToString());

            bool ret = this.searchControlContainer1.SaveLayout(profile);

            return(ret);
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        /// <param name="parentItem"></param>
        /// <returns></returns>
        public override System.Collections.IEnumerable GetData(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders, object parentItem)
        {
            if (parentItem == null)
            {
                return(null);
            }

            SearchHistoryInfo his = this.ParentDisplayManager.SearchManager.GetHistory(0);

            if (!string.IsNullOrEmpty(his.Expression))
            {
                ISearchExpression exp = SearchExpression.Parse(his.Expression);
                exp = RemoveParentSelectAsExpression(exp);
                searchExpression = SearchExpression.And(searchExpression, exp);
            }

            foreach (string s in m_groupByColumns)
            {
                object            r = EntityScript.GetPropertyValue(parentItem, s);
                ISearchExpression se2;

                if (r != null && r != System.DBNull.Value)
                {
                    se2 = SearchExpression.Eq(s, EntityScript.GetPropertyValue(parentItem, s));
                }
                else
                {
                    se2 = SearchExpression.IsNull(s);
                }
                searchExpression = SearchExpression.And(searchExpression, se2);
            }

            this.SetHistory(searchExpression, searchOrders);

            return(m_innerSearchManager.GetData(searchExpression, searchOrders));
        }
コード例 #7
0
        void GridGotoFormTaskPane_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e)
        {
            Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem;
            GridRelatedInfo         info = item.Tag as GridRelatedInfo;

            switch (info.RelatedType)
            {
            case GridRelatedType.ByRows:
            {
                if (item.ParentItem.Text == "按选定行")
                {
                    ShowFormFromGrid(m_parentForm, info, false);
                }
                else
                {
                    ShowFormFromGrid(m_parentForm, info, true);
                }
            }
            break;

            case GridRelatedType.BySearchExpression:
            {
                SearchHistoryInfo his = m_dm.SearchManager.GetHistory(0);

                if (string.IsNullOrEmpty(his.Expression))
                {
                    MessageForm.ShowInfo("还未有搜索条件!");
                    return;
                }
                string                      newSearchExpression = info.SearchExpression;
                ISearchExpression           oldSe = SearchExpression.Parse(his.Expression);
                Dictionary <string, object> dict  = GetSearchExpreesionValues(oldSe);

                ISearchExpression newSe = SearchExpression.Parse(newSearchExpression);

                newSe = ReplaceSearchExpreesionValues(newSe, dict);

                ShowFrom(info.Action.Name, newSe, false);
            }
            break;

            case GridRelatedType.ByDataControl:
            {
                Dictionary <string, object> dict = m_dm.Copy();
                string exp = EntityHelper.ReplaceEntity(info.SearchExpression, new EntityHelper.GetReplaceValue(delegate(string paramName)
                    {
                        return(dict[paramName]);
                    }));
                ShowFrom(info.Action.Name, SearchExpression.Parse(exp), false);
            }
            break;

            case GridRelatedType.ByNone:
            {
                ShowFrom(info.Action.Name, null, false);
            }
            break;

            default:
                throw new NotSupportedException("Invalid GridRelatedInfo's RelatedType of " + info.Name);
            }
        }