123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Data;
- using System.Collections.Generic;
- using Ant.ORM.SQL;
- namespace Ant.ORM.Table
- {
- //internal class ValueFormat
- //{
- // public static bool IsFormat = false;
- // public static string formatString = "{0}";
- // public static string Format(object value)
- // {
- // return string.Format(formatString, value);
- // }
- // public static void Reset()
- // {
- // IsFormat = false;
- // formatString = "{0}";
- // }
- //}
- /// <summary>
- /// 单元值
- /// </summary>
- public class CellValue
- {
- internal bool IsNull = true;
- internal bool IsChange = false;
- internal object Value = null;
- }
- /// <summary>
- /// 单元结构属性
- /// </summary>
- public class CellStruct
- {
- public bool IsCanNull;
- public bool IsReadOnly;
- public string ColumnName;
- public System.Data.SqlDbType SqlType;
- public int MaxSize;
- public string Operator = "=";
- public ParameterDirection ParaDirection;
- internal Type ValueType;
- #region 构造函数
- public CellStruct(string columnName, System.Data.SqlDbType sqlType, bool isReadOnly, bool isCanNull, int maxSize, ParameterDirection paraDirection)
- {
- ColumnName = columnName;
- SqlType = sqlType;
- IsReadOnly = isReadOnly;
- IsCanNull = isCanNull;
- MaxSize = maxSize;
- ParaDirection = paraDirection;
- ValueType = DataType.GetType(sqlType);
- }
- #endregion
- }
- /// <summary>
- /// 单元格
- /// </summary>
- public class MDataCell
- {
- internal CellValue _CellValue;
- internal CellStruct _CellStruct;
- #region 构造函数
- internal MDataCell(ref CellStruct dataStruct)
- {
- Init(dataStruct, null);
- }
- internal MDataCell(ref CellStruct dataStruct, object value)
- {
- Init(dataStruct, value);
- }
- #endregion
- #region 初始化
- private void Init(CellStruct dataStruct, object value)
- {
- _CellValue = new CellValue();
- _CellStruct = dataStruct;
- _CellValue.Value = value;
- }
- #endregion
- #region 属性
- public object Value
- {
- get
- {
- return _CellValue.Value;
- }
- set
- {
- //if (value != null)
- //{
- _CellValue.IsChange = true;
- _CellValue.IsNull = value == null || value == DBNull.Value || (this._CellStruct.ValueType.Name == "DateTime" && Convert.ToString(value) == "");
- //if (ValueFormat.IsFormat && DataType.GetGroupID(_CellStruct.SqlType) == 0)
- //{
- // _CellValue.Value = ValueFormat.Format(value);
- //}
- //else
- //{
- _CellValue.Value = value;
- //}
- //if (_CellValue.ValueType == null)
- //{
- // _CellValue.ValueType = value.GetType();
- //}
- //}
- }
- }
- #endregion
- }
- }
|