123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Ant.ORM.Table
- {
- /// <summary>
- /// 头列表集合
- /// </summary>
- public class MDataColumn : List<CellStruct>
- {
- private MDataTable _Table;
- public MDataColumn()
- : base()
- {
- }
- internal MDataColumn(MDataTable table)
- {
- _Table = table;
- }
- public MDataColumn Clone()
- {
- MDataColumn mcs = new MDataColumn();
- for (int i = 0; i < base.Count; i++)
- {
- CellStruct mcb = base[i];
- mcs.Add(mcb);
- }
- return mcs;
- }
- /// <summary>
- /// 获取列所在的索引位置
- /// </summary>
- public int GetIndex(string columnName)
- {
- for (int i = 0; i < base.Count; i++)
- {
- if (string.Compare(base[i].ColumnName, columnName, true) == 0)
- {
- return i;
- }
- }
- return -1;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="columnName"></param>
- /// <returns></returns>
- public bool Contains(string columnName)
- {
- for (int i = 0; i < this.Count; i++)
- {
- if (string.Compare(this[i].ColumnName, columnName, true) == 0)
- {
- return true;
- }
- }
- return false;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="columnName"></param>
- public void Add(string columnName)
- {
- Add(columnName, System.Data.SqlDbType.NVarChar);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="columnName"></param>
- /// <param name="SqlType"></param>
- public void Add(string columnName, System.Data.SqlDbType SqlType)
- {
- CellStruct mdcStruct = new CellStruct(columnName, SqlType, false, true, 0, System.Data.ParameterDirection.Input);
- this.Add(mdcStruct);
- if (_Table != null)
- {
- for (int i = 0; i < _Table.Rows.Count; i++)
- {
- _Table.Rows[i].Add(new MDataCell(ref mdcStruct));
- }
- }
- }
- /// <summary>
- /// 移除列
- /// </summary>
- /// <param name="columnName"></param>
- public void Remove(string columnName)
- {
- int index = -1;
- for (int i = 0; i < this.Count; i++)
- {
- if (string.Compare(this[i].ColumnName, columnName, true) == 0)
- {
- index = i;
- break;
- }
- }
- if (index > -1)
- {
- RemoveAt(index);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="index"></param>
- public new void RemoveAt(int index)
- {
- if (_Table != null)
- {
- foreach (MDataRow row in _Table.Rows)
- {
- row.RemoveAt(index);
- }
- }
- base.RemoveAt(index);
- }
- }
- }
|