Ejemplo n.º 1
0
        //private static ShowListMatchTypeSetting ReadSettingFromReg(string wordbookName)
        //{
        //   string regValue = Registry.GetValue(CurrentUserRegFullKey, wordbookName, String.Empty);

        //   CurrentUserSetting.Add(wordbookName, new ShowListMatchTypeSetting(regValue));

        //   return CurrentUserSetting[wordbookName];
        //}

        private static void WriteSettingToReg(string wordbookName, ShowListMatchTypeSetting setting)
        {
            try {
                Registry.SetValue(Registry.LocalMachine + "\\" + CurrentUserRegFullKey, wordbookName, setting.ToString());
            }
            catch { }
        }
Ejemplo n.º 2
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();
        }