Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

KitRepository.asp 8.6KB

vor 8 Monaten
vor 7 Monaten
vor 7 Monaten
vor 8 Monaten
vor 7 Monaten
vor 7 Monaten
vor 8 Monaten
vor 7 Monaten
vor 8 Monaten
vor 7 Monaten
vor 8 Monaten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <%
  2. '=======================================================================================================================
  3. ' Kit Model
  4. '=======================================================================================================================
  5. Class KitModel_Class
  6. Public Validator
  7. Public Class_Get_Properties
  8. Public ID '90
  9. Public JobNumber '106
  10. Public Jcode '106
  11. Private Sub Class_Initialize
  12. 'ValidateExitsts Me, "",""
  13. Class_Get_Properties = Array("ID, JobNumber, Jcode")
  14. End Sub
  15. End CLass
  16. Class IndexKitModel_Class
  17. Public Validator
  18. Public Class_Get_Properties
  19. Public ID
  20. Public JobNumber '90
  21. Public Jurisdiction '106
  22. Public LabelCount '106
  23. Public CreatedOn
  24. Public LabelsPrinted
  25. Public ExportedToSnailWorks
  26. Public JobType
  27. Private Sub Class_Initialize
  28. 'ValidateExitsts Me, "",""
  29. Class_Get_Properties = Array("ID, JobNumber, Jurisdiction,LabelCount,CreatedOn,LabelsPrinted,ExportedToSnailWorks,JobType")
  30. End Sub
  31. End Class
  32. '=======================================================================================================================
  33. ' Kit Repository
  34. '=======================================================================================================================
  35. Class KitRepository_Class
  36. Public Function PagedIndexView(per_page, page_num, ByRef page_count, ByRef record_count)
  37. dim sql : sql = "SELECT Kit.ID,Kit.JobNumber as [JobNumber], " &_
  38. "Jurisdiction.Name As Jurisdiction," &_
  39. "(SELECT COUNT(*) From KitLabels Where KitId = Kit.ID)" &_
  40. " As [LabelCount],[CreatedOn],[LabelsPrinted],[ExportedToSnailWorks],[JobType] FROM Kit INNER JOIN Jurisdiction ON Kit.Jcode = Jurisdiction.JCode Where Kit.JobType Is Null or Kit.JobType = 'Labels';"
  41. dim list : set list = new LinkedList_Class
  42. dim rs : set rs = DAL.PagedQuery(sql, empty, per_page, page_num)
  43. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  44. rs.PageSize = per_page
  45. rs.AbsolutePage = page_num
  46. page_count = rs.PageCount
  47. record_count = rs.RecordCount
  48. End If
  49. set PagedIndexView = PagedIndexViewKitList(rs, per_page)
  50. Destroy rs
  51. End Function
  52. Private Function PagedIndexViewKitList(rs, per_page)
  53. dim list : set list = new LinkedList_Class
  54. dim x : x =0
  55. Do While x < per_page and Not rs.EOF
  56. list.Push Automapper.AutoMap(rs, new IndexKitModel_Class)
  57. x = x +1
  58. rs.MoveNext
  59. Loop
  60. set PagedIndexViewKitList = list
  61. End Function
  62. Public Function SwitchBoardEditFindById(ID)
  63. dim sql : sql = "SELECT Kit.ID,Kit.JobNumber as [JobNumber], " &_
  64. "Jurisdiction.Name As Jurisdiction," &_
  65. "(SELECT COUNT(*) From KitLabels Where KitId = Kit.ID)" &_
  66. " As [LabelCount],[CreatedOn],[LabelsPrinted],[ExportedToSnailWorks],[JobType] FROM Kit INNER JOIN Jurisdiction ON Kit.Jcode = Jurisdiction.JCode " &_
  67. "WHERE ID = ? AND Kit.JobType Is Null or Kit.JobType = 'Labels'"
  68. dim rs : set rs = DAL.Query(sql,ID)
  69. If rs.EOF then
  70. Err.Raise 1, "KitRepository_Class", KitNotFoundException("ID", ID)
  71. Else
  72. set SwitchBoardEditFindByID = Automapper.AutoMap(rs,"IndexKitModel_Class")
  73. End If
  74. End Function
  75. Public Function FindByID(ID)
  76. dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit] WHERE ID = ?"
  77. dim rs : set rs = DAL.Query(sql,ID)
  78. If rs.EOF then
  79. Err.Raise 1, "KitRepository_Class", KitNotFoundException("ID", ID)
  80. Else
  81. set FindByID = Automapper.AutoMap(rs,"KitModel_Class")
  82. End If
  83. End Function
  84. Public Function GetAll(orderBy)
  85. set GetAll = Find(empty,orderBy)
  86. End Function
  87. Public Function Find(where_kvarray, order_string_or_array)
  88. dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]"
  89. If Not IsEmpty(where_kvarray) then
  90. sql = sql & " WHERE "
  91. dim where_keys, where_values
  92. KVUnzip where_kvarray, where_keys, where_values
  93. dim i
  94. For i = 0 to UBound(where_keys)
  95. If i > 0 then sql = sql & " AND "
  96. sql = sql & " " & where_keys(i) & " "
  97. Next
  98. End If
  99. If Not IsEmpty(order_string_or_array) then
  100. sql = sql & "ORDER BY "
  101. If IsArray(order_string_or_array) then
  102. dim order_array : order_array = order_string_or_array
  103. For i = 0 to UBound(order_array)
  104. If i > 0 then sql = sql & ", "
  105. sql = sql & " " & order_array(i)
  106. Next
  107. Else
  108. sql = sql & order_string_or_array & " "
  109. End If
  110. End If
  111. dim rs : set rs = DAL.Query(sql, where_values)
  112. set Find = KitList(rs)
  113. Destroy rs
  114. End Function
  115. Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  116. dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]"
  117. If Not IsEmpty(where_kvarray) then
  118. sql = sql & " WHERE "
  119. dim where_keys, where_values
  120. KVUnzip where_kvarray, where_keys, where_values
  121. dim i
  122. For i = 0 to UBound(where_keys)
  123. If i > 0 then sql = sql & " AND "
  124. sql = sql & " " & where_keys(i) & " "
  125. Next
  126. End If
  127. If Not IsEmpty(order_string_or_array) then
  128. sql = sql & "ORDER BY "
  129. If IsArray(order_string_or_array) then
  130. dim order_array : order_array = order_string_or_array
  131. For i = 0 to UBound(order_array)
  132. If i > 0 then sql = sql & ", "
  133. sql = sql & " " & order_array(i)
  134. Next
  135. Else
  136. sql = sql & order_string_or_array & " "
  137. End If
  138. End If
  139. dim list : set list = new LinkedList_Class
  140. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  141. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  142. rs.PageSize = per_page
  143. rs.AbsolutePage = page_num
  144. page_count = rs.PageCount
  145. record_count = rs.RecordCount
  146. End If
  147. set FindPaged = PagedKitList(rs, per_page)
  148. Destroy rs
  149. End Function
  150. Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  151. dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]"
  152. If Not IsEmpty(where_kvarray) then
  153. sql = sql & " WHERE "
  154. dim where_keys, where_values
  155. KVUnzip where_kvarray, where_keys, where_values
  156. dim i
  157. For i = 0 to UBound(where_keys)
  158. If i > 0 then sql = sql & " OR"
  159. sql = sql & " " & where_keys(i) & " LIKE ?"
  160. Next
  161. End If
  162. If Not IsEmpty(order_string_or_array) then
  163. sql = sql & " ORDER BY "
  164. If IsArray(order_string_or_array) then
  165. dim order_array : order_array = order_string_or_array
  166. For i = 0 to UBound(order_array)
  167. If i > 0 then sql = sql & ", "
  168. sql = sql & " " & order_array(i)
  169. Next
  170. Else
  171. sql = sql & order_string_or_array & " "
  172. End If
  173. End If
  174. dim list : set list = new LinkedList_Class
  175. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  176. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  177. rs.PageSize = per_page
  178. rs.AbsolutePage = page_num
  179. page_count = rs.PageCount
  180. record_count = rs.RecordCount
  181. End If
  182. set SearchTablePaged = PagedKitList(rs, per_page)
  183. Destroy rs
  184. End Function
  185. Private Function PagedKitList(rs, per_page)
  186. dim list : set list = new LinkedList_Class
  187. dim x : x =0
  188. Do While x < per_page and Not rs.EOF
  189. list.Push Automapper.AutoMap(rs, new KitModel_Class)
  190. x = x +1
  191. rs.MoveNext
  192. Loop
  193. set PagedKitList = list
  194. End Function
  195. Private Function KitNotFoundException(ByVal field_name, ByVal field_val)
  196. KitNotFoundException = "Kit was not found with " & field_name & " of '" & field_val & "'."
  197. End Function
  198. Private Function KitList(rs)
  199. dim list : set list = new LinkedList_Class
  200. dim model
  201. Do until rs.EOF
  202. set model = new KitModel_Class
  203. list.Push Automapper.AutoMap(rs, model)
  204. rs.MoveNext
  205. Loop
  206. set KitList = list
  207. End Function
  208. Public Sub AddNew(ByRef model)
  209. dim sql : sql = "INSERT INTO [Kit] (" &_
  210. "[JobNumber]," &_
  211. "[Jcode]," &_
  212. "[CreatedOn]," &_
  213. "[JobType])" &_
  214. "VALUES (?,?,?,?)"
  215. DAL.Execute sql, Array(model.JobNumber, _
  216. model.Jcode,Now(),"Labels")
  217. sql = "SELECT TOP 1 ID FROM [Kit] ORDER BY ID DESC"
  218. dim rs : set rs = DAL.Query(sql, empty)
  219. model.ID = rs("ID")
  220. Destroy rs
  221. End Sub
  222. Public Sub Update(model)
  223. dim sql : sql = "UPDATE [Kit] SET [JobNumber] = ?," &_
  224. "[Jcode] = ?" &_
  225. " WHERE [ID] = ?"
  226. DAL.Execute sql, Array(model.JobNumber, _
  227. model.Jcode, _
  228. model.ID)
  229. End Sub
  230. Public Sub Delete(id)
  231. dim sql : sql = "DELETE FROM [Kit] WHERE [ID] = ?"
  232. DAL.Execute sql, id
  233. End Sub
  234. End Class
  235. dim KitRepository__Singleton
  236. Function KitRepository()
  237. If IsEmpty(KitRepository__Singleton) then
  238. set KitRepository__Singleton = new KitRepository_Class
  239. End If
  240. set KitRepository = KitRepository__Singleton
  241. End Function
  242. %>

Powered by TurnKey Linux.