You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 line
7.7KB

  1. <%
  2. '=======================================================================================================================
  3. ' KitLabels Model
  4. '=======================================================================================================================
  5. Class KitLabelsModel_Class
  6. Public Validator
  7. Public Class_Get_Properties
  8. Public ID '90
  9. Public KitId '122
  10. Public OutboundSerial '106
  11. Public InBoundSerial '106
  12. Public OutboundIMB '106
  13. Public InBoundIMB '106
  14. Public OutboundIMBDigits '106
  15. Public InBoundIMBDigits '106
  16. Private Sub Class_Initialize
  17. 'ValidateExitsts Me, "",""
  18. Class_Get_Properties = Array("ID, KitId, OutboundSerial, InBoundSerial, OutboundIMB, InBoundIMB, OutboundIMBDigits, InBoundIMBDigits")
  19. End Sub
  20. End CLass
  21. '=======================================================================================================================
  22. ' KitLabels Repository
  23. '=======================================================================================================================
  24. Class KitLabelsRepository_Class
  25. Public Function FindByID(ID)
  26. dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels] WHERE ID = ?"
  27. dim rs : set rs = DAL.Query(sql,ID)
  28. If rs.EOF then
  29. Err.Raise 1, "KitLabelsRepository_Class", KitLabelsNotFoundException("ID", ID)
  30. Else
  31. set FindByID = Automapper.AutoMap(rs,"KitLabelsModel_Class")
  32. End If
  33. End Function
  34. Public Function GetAll(orderBy)
  35. set GetAll = Find(empty,orderBy)
  36. End Function
  37. Public Function Find(where_kvarray, order_string_or_array)
  38. dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]"
  39. If Not IsEmpty(where_kvarray) then
  40. sql = sql & " WHERE "
  41. dim where_keys, where_values
  42. KVUnzip where_kvarray, where_keys, where_values
  43. dim i
  44. For i = 0 to UBound(where_keys)
  45. If i > 0 then sql = sql & " AND "
  46. sql = sql & " " & where_keys(i) & " "
  47. Next
  48. End If
  49. If Not IsEmpty(order_string_or_array) then
  50. sql = sql & "ORDER BY "
  51. If IsArray(order_string_or_array) then
  52. dim order_array : order_array = order_string_or_array
  53. For i = 0 to UBound(order_array)
  54. If i > 0 then sql = sql & ", "
  55. sql = sql & " " & order_array(i)
  56. Next
  57. Else
  58. sql = sql & order_string_or_array & " "
  59. End If
  60. End If
  61. dim rs : set rs = DAL.Query(sql, where_values)
  62. set Find = KitLabelsList(rs)
  63. Destroy rs
  64. End Function
  65. Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  66. dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]"
  67. If Not IsEmpty(where_kvarray) then
  68. sql = sql & " WHERE "
  69. dim where_keys, where_values
  70. KVUnzip where_kvarray, where_keys, where_values
  71. dim i
  72. For i = 0 to UBound(where_keys)
  73. If i > 0 then sql = sql & " AND "
  74. sql = sql & " " & where_keys(i) & " "
  75. Next
  76. End If
  77. If Not IsEmpty(order_string_or_array) then
  78. sql = sql & "ORDER BY "
  79. If IsArray(order_string_or_array) then
  80. dim order_array : order_array = order_string_or_array
  81. For i = 0 to UBound(order_array)
  82. If i > 0 then sql = sql & ", "
  83. sql = sql & " " & order_array(i)
  84. Next
  85. Else
  86. sql = sql & order_string_or_array & " "
  87. End If
  88. End If
  89. dim list : set list = new LinkedList_Class
  90. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  91. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  92. rs.PageSize = per_page
  93. rs.AbsolutePage = page_num
  94. page_count = rs.PageCount
  95. record_count = rs.RecordCount
  96. End If
  97. set FindPaged = PagedKitLabelsList(rs, per_page)
  98. Destroy rs
  99. End Function
  100. Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  101. dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]"
  102. If Not IsEmpty(where_kvarray) then
  103. sql = sql & " WHERE "
  104. dim where_keys, where_values
  105. KVUnzip where_kvarray, where_keys, where_values
  106. dim i
  107. For i = 0 to UBound(where_keys)
  108. If i > 0 then sql = sql & " OR"
  109. sql = sql & " " & where_keys(i) & " LIKE ?"
  110. Next
  111. End If
  112. If Not IsEmpty(order_string_or_array) then
  113. sql = sql & " ORDER BY "
  114. If IsArray(order_string_or_array) then
  115. dim order_array : order_array = order_string_or_array
  116. For i = 0 to UBound(order_array)
  117. If i > 0 then sql = sql & ", "
  118. sql = sql & " " & order_array(i)
  119. Next
  120. Else
  121. sql = sql & order_string_or_array & " "
  122. End If
  123. End If
  124. dim list : set list = new LinkedList_Class
  125. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  126. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  127. rs.PageSize = per_page
  128. rs.AbsolutePage = page_num
  129. page_count = rs.PageCount
  130. record_count = rs.RecordCount
  131. End If
  132. set SearchTablePaged = PagedKitLabelsList(rs, per_page)
  133. Destroy rs
  134. End Function
  135. Private Function PagedKitLabelsList(rs, per_page)
  136. dim list : set list = new LinkedList_Class
  137. dim x : x =0
  138. Do While x < per_page and Not rs.EOF
  139. list.Push Automapper.AutoMap(rs, new KitLabelsModel_Class)
  140. x = x +1
  141. rs.MoveNext
  142. Loop
  143. set PagedKitLabelsList = list
  144. End Function
  145. Private Function KitLabelsNotFoundException(ByVal field_name, ByVal field_val)
  146. KitLabelsNotFoundException = "KitLabels was not found with " & field_name & " of '" & field_val & "'."
  147. End Function
  148. Private Function KitLabelsList(rs)
  149. dim list : set list = new LinkedList_Class
  150. dim model
  151. Do until rs.EOF
  152. set model = new KitLabelsModel_Class
  153. list.Push Automapper.AutoMap(rs, model)
  154. rs.MoveNext
  155. Loop
  156. set KitLabelsList = list
  157. End Function
  158. Public Sub AddNew(ByRef model)
  159. dim sql : sql = "INSERT INTO [KitLabels] (" &_
  160. "[KitId]," &_
  161. "[OutboundSerial]," &_
  162. "[InBoundSerial]," &_
  163. "[OutboundIMB]," &_
  164. "[InBoundIMB]," &_
  165. "[OutboundIMBDigits]," &_
  166. "[InBoundIMBDigits])" &_
  167. "VALUES (?,?,?,?,?,?,?)"
  168. DAL.Execute sql, Array(model.KitId, _
  169. model.OutboundSerial, _
  170. model.InBoundSerial, _
  171. model.OutboundIMB, _
  172. model.InBoundIMB, _
  173. model.OutboundIMBDigits, _
  174. model.InBoundIMBDigits)
  175. sql = "SELECT TOP 1 ID FROM [KitLabels] ORDER BY ID DESC"
  176. dim rs : set rs = DAL.Query(sql, empty)
  177. model.ID = rs("ID")
  178. Destroy rs
  179. End Sub
  180. Public Sub Update(model)
  181. dim sql : sql = "UPDATE [KitLabels] SET [KitId] = ?," &_
  182. "[OutboundSerial] = ?," &_
  183. "[InBoundSerial] = ?," &_
  184. "[OutboundIMB] = ?," &_
  185. "[InBoundIMB] = ?," &_
  186. "[OutboundIMBDigits] = ?," &_
  187. "[InBoundIMBDigits] = ?" &_
  188. " WHERE [ID] = ?"
  189. DAL.Execute sql, Array(model.KitId, _
  190. model.OutboundSerial, _
  191. model.InBoundSerial, _
  192. model.OutboundIMB, _
  193. model.InBoundIMB, _
  194. model.OutboundIMBDigits, _
  195. model.InBoundIMBDigits, _
  196. model.ID)
  197. End Sub
  198. Public Sub Delete(id)
  199. dim sql : sql = "DELETE FROM [KitLabels] WHERE [ID] = ?"
  200. DAL.Execute sql, id
  201. End Sub
  202. End Class
  203. dim KitLabelsRepository__Singleton
  204. Function KitLabelsRepository()
  205. If IsEmpty(KitLabelsRepository__Singleton) then
  206. set KitLabelsRepository__Singleton = new KitLabelsRepository_Class
  207. End If
  208. set KitLabelsRepository = KitLabelsRepository__Singleton
  209. End Function
  210. %>

Powered by TurnKey Linux.