Exemple #1
0
        private void SetParameter(string fieldName, GridColumnStyle value)
        {
            //this.OnChange();
            int num1 = this.IndexOf(fieldName);

            if (num1 < 0)
            {
                throw new ArgumentOutOfRangeException(MessageStringManager.GetString("ParameterOutOfRange"));
            }
            this.Replace(num1, value);
        }
Exemple #2
0
 /// <summary>
 /// 查找与指定对象匹配的列显示样式对象在列表中的位置
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int IndexOf(GridColumnStyle value)
 {
     return(this.IndexOf(value));
 }
Exemple #3
0
 /// <summary>
 /// 列表是否包含指定的对象
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Contains(GridColumnStyle value)
 {
     return(-1 != this.IndexOf(value));
 }
Exemple #4
0
 /// <summary>
 /// 向列表添加显示样式对象
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public GridColumnStyle Add(GridColumnStyle value)
 {
     this.Add((object)value);
     return(value);
 }
Exemple #5
0
 private void SetParameter(int index, GridColumnStyle value)
 {
     //this.OnChange();
     this.RangeCheck(index);
     this.Replace(index, value);
 }
Exemple #6
0
        /// <summary>
        /// 用指定的DataTable等信息创建SQL字典类实例。
        /// 列的显示名用DataColumn的Caption代替,需要显示的列及其列宽通过columnWidthes设置
        /// </summary>
        /// <param name="uniqueName">局部唯一的字典名</param>
        /// <param name="sourceData">数据集</param>
        /// <param name="codeField">代码字段名</param>
        /// <param name="nameField">名称字段名</param>
        /// <param name="columnWidthes">需要显示的列名及其列宽</param>
        public SqlWordbook(string uniqueName, DataTable sourceData, string codeField, string nameField, Dictionary <string, int> columnWidthes)
            : base()
        {
            Debug.Assert(uniqueName != null, "类名不能为NULL");
            Debug.Assert(uniqueName.Length > 0, "类名不能为空");
            WordbookName = uniqueName;
            Caption      = WordbookName;

            if (sourceData == null)
            {
                throw new ArgumentNullException("数据集不能为空");
            }
            //if (sourceData.Rows.Count == 0)
            //   throw new ArgumentNullException("数据集中未包含数据");
            _bookData = sourceData;

            // DataTable中默认RowFilter作为扩展条件保存
            ExtraCondition = _bookData.DefaultView.RowFilter;

            QuerySentence = "";

            if (codeField.Length == 0)
            {
                throw new ArgumentNullException("必须指定代码字段");
            }
            if (!sourceData.Columns.Contains(codeField))
            {
                throw new ArgumentOutOfRangeException("指定的代码字段在数据集中不存在");
            }

            CodeField      = codeField;
            QueryCodeField = CodeField;

            if (nameField.Length == 0)
            {
                throw new ArgumentNullException("必须指定名称字段");
            }
            if (!sourceData.Columns.Contains(nameField))
            {
                throw new ArgumentOutOfRangeException("指定的名称字段在数据集中不存在");
            }
            NameField = nameField;

            DefaultFilterFields = new Collection <string>();
            // 使用默认的代码列和名称列进行过滤
            DefaultFilterFields.Add(codeField);
            DefaultFilterFields.Add(nameField);

            CurrentMatchFields = new Collection <string>();
            foreach (string field in DefaultFilterFields)
            {
                CurrentMatchFields.Add(field);
            }

            Parameters = new FilterParameterCollection();

            ShowStyles = new Collection <GridColumnStyleCollection>();
            GridColumnStyleCollection styleCollection = new GridColumnStyleCollection();
            GridColumnStyle           style;

            foreach (KeyValuePair <string, int> keyValue in columnWidthes)
            {
                style = new GridColumnStyle(keyValue.Key
                                            , sourceData.Columns[keyValue.Key].Caption, keyValue.Value);
                styleCollection.Add(style);
            }
            if (styleCollection.Count == 0)
            {
                throw new ArgumentException("必须设置字典的显示列信息");
            }
            ShowStyles.Add(styleCollection);
            SelectedStyleIndex = 0;

            // Sql字典默认为不缓存数据
            CacheTime = -1;

            //_useSqlStatement = false;
            //_autoAddShortCode = false;
            //_shortCodeAdded = true;

            //m_DrawConditions = new Collection<CustomDrawSetting>();
        }