Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

367 lignes
12KB

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

Powered by TurnKey Linux.