Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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

Powered by TurnKey Linux.