/// <summary> /// 用指定的SQL语句等信息创建SQL字典类实例。 /// 字段的显示名称、显示哪些列、列宽等信息在columnStyles中指定 /// </summary> /// <param name="uniqueName">局部唯一的名称</param> /// <param name="query">查询语句</param> /// <param name="codeField">代码字段名</param> /// <param name="nameField">名称字段名</param> /// <param name="columnStyles">字段的显示名称、显示哪些列、列宽等信息</param> /// <param name="matchFieldComb">指定用来匹配输入数据的字段名,多个时用“//”格开,可以传入空</param> public SqlWordbook(string uniqueName, string query, string codeField, string nameField, GridColumnStyleCollection columnStyles, string matchFieldComb) : this(uniqueName, query, codeField, nameField, columnStyles) { string[] separator = new string[] { SeparatorSign.ListSeparator }; string[] values = matchFieldComb.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (values.Length > 0) { DefaultFilterFields.Clear(); CurrentMatchFields.Clear(); for (int i = 0; i < values.Length; i++) { DefaultFilterFields.Add(values[i]); CurrentMatchFields.Add(values[i]); } } }
/// <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> /// <param name="matchFieldComb">指定用来匹配输入数据的字段名,多个时用“//”格开,可以传入空</param> public SqlWordbook(string uniqueName, DataTable sourceData, string codeField, string nameField, Dictionary <string, int> columnWidthes, string matchFieldComb) : this(uniqueName, sourceData, codeField, nameField, columnWidthes) { string[] separator = new string[] { SeparatorSign.ListSeparator }; string[] values = matchFieldComb.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (values.Length > 0) { DefaultFilterFields.Clear(); CurrentMatchFields.Clear(); for (int i = 0; i < values.Length; i++) { if (!sourceData.Columns.Contains(values[i])) { throw new ArgumentOutOfRangeException("指定的查询字段在数据集中不存在"); } DefaultFilterFields.Add(values[i]); CurrentMatchFields.Add(values[i]); } } }