MDataCell.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Data;
  3. using System.Collections.Generic;
  4. using Ant.ORM.SQL;
  5. namespace Ant.ORM.Table
  6. {
  7. //internal class ValueFormat
  8. //{
  9. // public static bool IsFormat = false;
  10. // public static string formatString = "{0}";
  11. // public static string Format(object value)
  12. // {
  13. // return string.Format(formatString, value);
  14. // }
  15. // public static void Reset()
  16. // {
  17. // IsFormat = false;
  18. // formatString = "{0}";
  19. // }
  20. //}
  21. /// <summary>
  22. /// 单元值
  23. /// </summary>
  24. public class CellValue
  25. {
  26. internal bool IsNull = true;
  27. internal bool IsChange = false;
  28. internal object Value = null;
  29. }
  30. /// <summary>
  31. /// 单元结构属性
  32. /// </summary>
  33. public class CellStruct
  34. {
  35. public bool IsCanNull;
  36. public bool IsReadOnly;
  37. public string ColumnName;
  38. public System.Data.SqlDbType SqlType;
  39. public int MaxSize;
  40. public string Operator = "=";
  41. public ParameterDirection ParaDirection;
  42. internal Type ValueType;
  43. #region 构造函数
  44. public CellStruct(string columnName, System.Data.SqlDbType sqlType, bool isReadOnly, bool isCanNull, int maxSize, ParameterDirection paraDirection)
  45. {
  46. ColumnName = columnName;
  47. SqlType = sqlType;
  48. IsReadOnly = isReadOnly;
  49. IsCanNull = isCanNull;
  50. MaxSize = maxSize;
  51. ParaDirection = paraDirection;
  52. ValueType = DataType.GetType(sqlType);
  53. }
  54. #endregion
  55. }
  56. /// <summary>
  57. /// 单元格
  58. /// </summary>
  59. public class MDataCell
  60. {
  61. internal CellValue _CellValue;
  62. internal CellStruct _CellStruct;
  63. #region 构造函数
  64. internal MDataCell(ref CellStruct dataStruct)
  65. {
  66. Init(dataStruct, null);
  67. }
  68. internal MDataCell(ref CellStruct dataStruct, object value)
  69. {
  70. Init(dataStruct, value);
  71. }
  72. #endregion
  73. #region 初始化
  74. private void Init(CellStruct dataStruct, object value)
  75. {
  76. _CellValue = new CellValue();
  77. _CellStruct = dataStruct;
  78. _CellValue.Value = value;
  79. }
  80. #endregion
  81. #region 属性
  82. public object Value
  83. {
  84. get
  85. {
  86. return _CellValue.Value;
  87. }
  88. set
  89. {
  90. //if (value != null)
  91. //{
  92. _CellValue.IsChange = true;
  93. _CellValue.IsNull = value == null || value == DBNull.Value || (this._CellStruct.ValueType.Name == "DateTime" && Convert.ToString(value) == "");
  94. //if (ValueFormat.IsFormat && DataType.GetGroupID(_CellStruct.SqlType) == 0)
  95. //{
  96. // _CellValue.Value = ValueFormat.Format(value);
  97. //}
  98. //else
  99. //{
  100. _CellValue.Value = value;
  101. //}
  102. //if (_CellValue.ValueType == null)
  103. //{
  104. // _CellValue.ValueType = value.GetType();
  105. //}
  106. //}
  107. }
  108. }
  109. #endregion
  110. }
  111. }