Exemplo n.º 1
0
        /// <summary>
        /// 执行选择代码的过程
        /// </summary>
        /// <param name="searchText"></param>
        /// <param name="callType">调用ShowListWindow方式--</param>
        private void SelectRecord(string searchText, ShowListCallType callType)
        {
            LookUpWindow _listWindow_back = new LookUpWindow();

            _listWindow_back = _listWindow;
            if (_listWindow == null)
            {
                MessageBox.Show("未设置代码选择窗口", "严重错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SyncListWindowProperties();

            // 调用ShowListWindow的执行函数
            // 暂未处理使用动态SQL语句的情况!!!
            if (callType == ShowListCallType.Initialize)
            {
                _listWindow.CallLookUpWindow(CurrentWordbook
                                             , Kind
                                             , searchText);
            }
            else
            {
                //if (m_OwnerForm == null)
                m_OwnerForm = FindForm();
                // 设置ShowList窗口的查询匹配模式
                ShowListMatchTypeSetting setting = ShowListMatchTypeRecorder.ReadDefaultSetting(CurrentWordbook.WordbookName);
                _listWindow.MatchType = setting.MatchType;
                _listWindow.IsDynamic = setting.IsDynamic;

                bool oldShowImmediately = ShowFormImmediately;
                ShowFormImmediately = false; // 强制关闭此属性
                _listWindow.Owner   = m_OwnerForm;
                _listWindow.CallLookUpWindow(CurrentWordbook
                                             , Kind
                                             , searchText
                                             , FormMode
                                             , this.Parent.PointToScreen(this.Location)
                                             , Size
                                             , Screen.GetBounds(this)
                                             , callType);
                if (_listWindow.CodeValue.Trim() == "" && _listWindow.DisplayValue == "")
                {
                    _listWindow = _listWindow_back;
                }
                _listWindow.Owner = null;

                ShowFormImmediately = oldShowImmediately;
                // 保存ShowList窗口的查询匹配模式
                ShowListMatchTypeRecorder.WriteSetting(CurrentWordbook.WordbookName, _listWindow.MatchType, _listWindow.IsDynamic);
            }

            // 保存选择结果
            if (_listWindow.HadGetValue)
            {
                string tempCodeValue    = _codeValue;
                string tempDisplayValue = _displayValue;

                _codeValue    = _listWindow.CodeValue;
                _displayValue = _listWindow.DisplayValue;
                _queryValue   = _listWindow.QueryValue;

                if (_resultRows == null)
                {
                    _resultRows = new Collection <DataRow>();
                }
                else
                {
                    _resultRows.Clear();
                }

                foreach (DataRow row in _listWindow.ResultRows)
                {
                    _resultRows.Add(row);
                }

                if (_persistentObjects != null)
                {
                    _persistentObjects.Clear();
                }

                _persistentObjects = null;

                // 触发CodeValue变化事件
                if ((_codeValue != tempCodeValue) || (_displayValue != tempDisplayValue))
                {
                    OnCodeValueChanged(new EventArgs());
                }
            }
            else
            {
                // 不保留原始数据或初始化控件时,都清空相关属性
                if ((!KeepOriginalData) || (callType == ShowListCallType.Initialize))
                {
                    CleanupPropertiesValue();
                }
            }
            Text = _displayValue;
            SelectAll();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 调用代码选择窗口。
        /// 初始化ShowList窗口的部分属性。这些属性因为与行为、显示效果等有关,所以需要统一设置。
        /// <param name="wordbook">默认的字典类</param>
        /// <param name="kind">字典类的类型</param>
        /// <param name="initText">查询条件初始值</param>
        /// <param name="formMode">ShowList窗口显示模式</param>
        /// <param name="initPosition">ShowListForm默认显示位置(屏幕坐标)</param>
        /// <param name="inputSize">ShowListForm输入框的尺寸</param>
        /// <param name="screenSize">调用ShowListForm的窗口所在屏幕的尺寸</param>
        /// <param name="callType">调用模式</param>
        /// </summary>
        public void CallLookUpWindow(BaseWordbook wordbook, WordbookKind kind, string initText, ShowListFormMode formMode, Point initPosition, Size inputSize, Rectangle screenSize, ShowListCallType callType)
        {
            //m_SelForm.ClearTempData();

            //// 初始化时如果没有传入初始代码则直接退出
            //if ((callType == ShowListCallType.Initialize) && (String.IsNullOrEmpty(initText)))
            //   return;

            m_SelForm.CallShowListWindow(wordbook, kind, initText, formMode
                                         , initPosition, inputSize, screenSize, callType);
        }