25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KitRepository.asp 12KB

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

Powered by TurnKey Linux.