PageRenderTime 74ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestObjects/BestField.cs

https://github.com/sirivedula/BEST
C# | 197 lines | 170 code | 26 blank | 1 comment | 8 complexity | aff4f5b549dc5a3d91f0d46195bb7a4c MD5 | raw file
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Xml.Linq;
  12. using System.Data.OleDb;
  13. using System.Collections.Generic;
  14. namespace BaliEnterpriseSystems.BestObjects
  15. {
  16. public class BestField
  17. {
  18. private Func<BestRow, object> _formatFunc;
  19. public string fieldHeader
  20. {
  21. get;
  22. set;
  23. }
  24. public bool displayField
  25. {
  26. get;
  27. set;
  28. }
  29. public bool calcField
  30. {
  31. get;
  32. set;
  33. }
  34. public Func<BestRow, object> displayFormatFunc
  35. {
  36. get
  37. {
  38. return _formatFunc;
  39. }
  40. set
  41. {
  42. _formatFunc = value;
  43. }
  44. }
  45. public string fieldName
  46. {
  47. get;
  48. set;
  49. }
  50. public string fieldType
  51. {
  52. get;
  53. set;
  54. }
  55. public int fieldSize
  56. {
  57. get;
  58. set;
  59. }
  60. public byte Precision
  61. {
  62. get;
  63. set;
  64. }
  65. public byte scale
  66. {
  67. get;
  68. set;
  69. }
  70. public string fieldValue
  71. {
  72. get;
  73. set;
  74. }
  75. public string OldValue
  76. {
  77. get;
  78. set;
  79. }
  80. public bool IsRequired
  81. {
  82. get;
  83. set;
  84. }
  85. public bool hasChange
  86. {
  87. get
  88. {
  89. if (this.fieldValue != null)
  90. {
  91. return !this.fieldValue.Equals(this.OldValue, StringComparison.InvariantCultureIgnoreCase);
  92. }
  93. else
  94. {
  95. return (this.OldValue != null && this.fieldValue == null);
  96. }
  97. }
  98. }
  99. public bool IsPrimaryKey
  100. {
  101. get;
  102. set;
  103. }
  104. public OleDbType paramOledbType
  105. {
  106. get;
  107. set;
  108. }
  109. public OleDbParameter Param
  110. {
  111. get
  112. {
  113. object oledbvalue = null;
  114. if (this.fieldValue != null)
  115. {
  116. oledbvalue = Utils.ToType(this.fieldValue, Type.GetType(this.fieldType));
  117. }
  118. OleDbParameter _param = new OleDbParameter(this.fieldName, this.paramOledbType, this.fieldSize, ParameterDirection.Input, this.IsRequired, this.Precision, this.scale, this.fieldName, DataRowVersion.Current, oledbvalue);
  119. return _param;
  120. }
  121. }
  122. public BestField Clone()
  123. {
  124. BestField bfld = (BestField)this.MemberwiseClone();
  125. return bfld;
  126. }
  127. }
  128. /* Best Fields Object */
  129. public class BestFields
  130. {
  131. private List<BestField> _fields = new List<BestField>();
  132. public BestField this[int i]
  133. {
  134. get
  135. {
  136. return _fields[i];
  137. }
  138. }
  139. public BestField this[string name]
  140. {
  141. get
  142. {
  143. BestField fld = new BestField();
  144. foreach (BestField field in _fields)
  145. {
  146. if (field.fieldName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
  147. {
  148. fld = field;
  149. break;
  150. }
  151. }
  152. return fld;
  153. }
  154. }
  155. public void Add(BestField field)
  156. {
  157. _fields.Add(field);
  158. }
  159. public void Clear()
  160. {
  161. _fields.Clear();
  162. }
  163. public int Count
  164. {
  165. get
  166. {
  167. return _fields.Count;
  168. }
  169. }
  170. }
  171. }