Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

344 řádky
11KB

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

Powered by TurnKey Linux.