| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System.Collections;
- using System.Data;
- namespace IwbZero.IwbDataQuery
- {
- public class IwbBaseAttribute
- {
- protected readonly Hashtable _htProperties = new Hashtable();
- protected int _rowIndex = -1;
- public bool addToTable(DataTable dt)
- {
- DataRow row;
- if (_rowIndex == -1)
- {
- row = dt.NewRow();
- _rowIndex = dt.Rows.Count;
- }
- else
- {
- row = dt.Rows[_rowIndex];
- }
- row.BeginEdit();
- for (int i = 0; i < row.Table.Columns.Count; i++)
- {
- string str = row.Table.Columns[i].ColumnName.ToUpper().Trim();
- row[str] = this[str];
- }
- row.EndEdit();
- if (_rowIndex == dt.Rows.Count)
- {
- dt.Rows.Add(row);
- }
- return false;
- }
- public virtual void loadFromDataRow(DataRow dr)
- {
- _htProperties.Clear();
- for (int i = 0; i < dr.Table.Columns.Count; i++)
- {
- string key = dr.Table.Columns[i].ColumnName.ToUpper().Trim();
- _htProperties.Add(key, dr[i]);
- }
- }
- public void loadFromTable(DataTable dt, int index)
- {
- loadFromDataRow(dt.Rows[index]);
- _rowIndex = index;
- }
- //public void UpdateValueToTable(npTable poFormTable)
- //{
- // foreach (string str in _htProperties.Keys)
- // {
- // if (poFormTable.Columns.Contains(str))
- // {
- // poFormTable.SetField(str, _htProperties[str].ToString());
- // }
- // }
- //}
- public object this[string pcColName]
- {
- get
- {
- object obj2 = "";
- string key = pcColName.Trim().ToUpper();
- if (_htProperties.ContainsKey(key))
- {
- obj2 = _htProperties[key];
- }
- return obj2;
- }
- set
- {
- string key = pcColName.Trim().ToUpper();
- if (_htProperties.ContainsKey(key))
- {
- _htProperties[key] = value;
- }
- else
- {
- _htProperties.Add(key, value);
- }
- }
- }
- }
- }
|