You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

343 lines
12KB

  1. <%
  2. '=======================================================================================================================
  3. ' InkjetRecords Model
  4. '=======================================================================================================================
  5. Class InkjetRecordsModel_Class
  6. Public Validator
  7. Public Class_Get_Properties
  8. Public ID '90
  9. Public KitID '122
  10. Public VOTERID '106
  11. Public LASTNAME '106
  12. Public FIRSTNAME '106
  13. Public MIDDLENAME '106
  14. Public SUFFIX '106
  15. Public PRECINCT '106
  16. Public ADDRESS1 '106
  17. Public ADDRESS2 '106
  18. Public ADDRESS3 '106
  19. Public ADDRESS4 '106
  20. Public ADDRESS5 '106
  21. Public APPSENT '106
  22. Public APPRETURNED '106
  23. Public BALSENT '106
  24. Public BALRETURNED '106
  25. Public CountingBoard '106
  26. Public UOCAVASTATUS '106
  27. Public EMAILADDRESS '106
  28. Public PHONENUMBER '106
  29. Public BALLOT_NUMBER '106
  30. Public CassADDRESS1 '106
  31. Public CassADDRESS2 '106
  32. Public CassADDRESS3 '106
  33. Public CassADDRESS4 '106
  34. Public CassADDRESS5 '106
  35. Public KitLabelID
  36. Private Sub Class_Initialize
  37. 'ValidateExitsts Me, "",""
  38. Class_Get_Properties = Array("ID, KitID, VOTERID, LASTNAME, FIRSTNAME, MIDDLENAME, SUFFIX, PRECINCT, ADDRESS1, ADDRESS2, ADDRESS3, ADDRESS4, ADDRESS5, APPSENT, APPRETURNED, BALSENT, BALRETURNED, CountingBoard, UOCAVASTATUS, EMAILADDRESS, PHONENUMBER, BALLOT_NUMBER, CassADDRESS1, CassADDRESS2, CassADDRESS3, CassADDRESS4, CassADDRESS5,KitLabelID")
  39. End Sub
  40. End CLass
  41. '=======================================================================================================================
  42. ' InkjetRecords Repository
  43. '=======================================================================================================================
  44. Class InkjetRecordsRepository_Class
  45. Public Function FindByID(ID)
  46. dim sql : sql = "Select [ID], [KitID], [VOTERID], [LASTNAME], [FIRSTNAME], [MIDDLENAME], [SUFFIX], [PRECINCT], [ADDRESS1], [ADDRESS2], [ADDRESS3], [ADDRESS4], [ADDRESS5], [APPSENT], [APPRETURNED], [BALSENT], [BALRETURNED], [CountingBoard], [UOCAVASTATUS], [EMAILADDRESS], [PHONENUMBER], [BALLOT_NUMBER], [CassADDRESS1], [CassADDRESS2], [CassADDRESS3], [CassADDRESS4], [CassADDRESS5], [KitLabelID] FROM [InkjetRecords] WHERE ID = ?"
  47. dim rs : set rs = DAL.Query(sql,ID)
  48. If rs.EOF then
  49. Err.Raise 1, "InkjetRecordsRepository_Class", InkjetRecordsNotFoundException("ID", ID)
  50. Else
  51. set FindByID = Automapper.AutoMap(rs,"InkjetRecordsModel_Class")
  52. End If
  53. End Function
  54. Public Function GetAll(orderBy)
  55. set GetAll = Find(empty,orderBy)
  56. End Function
  57. Public Function Find(where_kvarray, order_string_or_array)
  58. dim sql : sql = "Select [ID], [KitID], [VOTERID], [LASTNAME], [FIRSTNAME], [MIDDLENAME], [SUFFIX], [PRECINCT], [ADDRESS1], [ADDRESS2], [ADDRESS3], [ADDRESS4], [ADDRESS5], [APPSENT], [APPRETURNED], [BALSENT], [BALRETURNED], [CountingBoard], [UOCAVASTATUS], [EMAILADDRESS], [PHONENUMBER], [BALLOT_NUMBER], [CassADDRESS1], [CassADDRESS2], [CassADDRESS3], [CassADDRESS4], [CassADDRESS5], [KitLabelID] FROM [InkjetRecords]"
  59. If Not IsEmpty(where_kvarray) then
  60. sql = sql & " WHERE "
  61. dim where_keys, where_values
  62. KVUnzip where_kvarray, where_keys, where_values
  63. dim i
  64. For i = 0 to UBound(where_keys)
  65. If i > 0 then sql = sql & " AND "
  66. sql = sql & " " & where_keys(i) & " "
  67. Next
  68. End If
  69. If Not IsEmpty(order_string_or_array) then
  70. sql = sql & "ORDER BY "
  71. If IsArray(order_string_or_array) then
  72. dim order_array : order_array = order_string_or_array
  73. For i = 0 to UBound(order_array)
  74. If i > 0 then sql = sql & ", "
  75. sql = sql & " " & order_array(i)
  76. Next
  77. Else
  78. sql = sql & order_string_or_array & " "
  79. End If
  80. End If
  81. dim rs : set rs = DAL.Query(sql, where_values)
  82. set Find = InkjetRecordsList(rs)
  83. Destroy rs
  84. End Function
  85. Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  86. dim sql : sql = "Select [ID], [KitID], [VOTERID], [LASTNAME], [FIRSTNAME], [MIDDLENAME], [SUFFIX], [PRECINCT], [ADDRESS1], [ADDRESS2], [ADDRESS3], [ADDRESS4], [ADDRESS5], [APPSENT], [APPRETURNED], [BALSENT], [BALRETURNED], [CountingBoard], [UOCAVASTATUS], [EMAILADDRESS], [PHONENUMBER], [BALLOT_NUMBER], [CassADDRESS1], [CassADDRESS2], [CassADDRESS3], [CassADDRESS4], [CassADDRESS5],[KitLabelID] FROM [InkjetRecords]"
  87. If Not IsEmpty(where_kvarray) then
  88. sql = sql & " WHERE "
  89. dim where_keys, where_values
  90. KVUnzip where_kvarray, where_keys, where_values
  91. dim i
  92. For i = 0 to UBound(where_keys)
  93. If i > 0 then sql = sql & " AND "
  94. sql = sql & " " & where_keys(i) & " "
  95. Next
  96. End If
  97. If Not IsEmpty(order_string_or_array) then
  98. sql = sql & "ORDER BY "
  99. If IsArray(order_string_or_array) then
  100. dim order_array : order_array = order_string_or_array
  101. For i = 0 to UBound(order_array)
  102. If i > 0 then sql = sql & ", "
  103. sql = sql & " " & order_array(i)
  104. Next
  105. Else
  106. sql = sql & order_string_or_array & " "
  107. End If
  108. End If
  109. dim list : set list = new LinkedList_Class
  110. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  111. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  112. rs.PageSize = per_page
  113. rs.AbsolutePage = page_num
  114. page_count = rs.PageCount
  115. record_count = rs.RecordCount
  116. End If
  117. set FindPaged = PagedInkjetRecordsList(rs, per_page)
  118. Destroy rs
  119. End Function
  120. Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)
  121. dim sql : sql = "Select [ID], [KitID], [VOTERID], [LASTNAME], [FIRSTNAME], [MIDDLENAME], [SUFFIX], [PRECINCT], [ADDRESS1], [ADDRESS2], [ADDRESS3], [ADDRESS4], [ADDRESS5], [APPSENT], [APPRETURNED], [BALSENT], [BALRETURNED], [CountingBoard], [UOCAVASTATUS], [EMAILADDRESS], [PHONENUMBER], [BALLOT_NUMBER], [CassADDRESS1], [CassADDRESS2], [CassADDRESS3], [CassADDRESS4], [CassADDRESS5], [KitLabelID] FROM [InkjetRecords]"
  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 & " OR"
  129. sql = sql & " " & where_keys(i) & " LIKE ?"
  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 list : set list = new LinkedList_Class
  145. dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
  146. If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
  147. rs.PageSize = per_page
  148. rs.AbsolutePage = page_num
  149. page_count = rs.PageCount
  150. record_count = rs.RecordCount
  151. End If
  152. set SearchTablePaged = PagedInkjetRecordsList(rs, per_page)
  153. Destroy rs
  154. End Function
  155. Private Function PagedInkjetRecordsList(rs, per_page)
  156. dim list : set list = new LinkedList_Class
  157. dim x : x =0
  158. Do While x < per_page and Not rs.EOF
  159. list.Push Automapper.AutoMap(rs, new InkjetRecordsModel_Class)
  160. x = x +1
  161. rs.MoveNext
  162. Loop
  163. set PagedInkjetRecordsList = list
  164. End Function
  165. Private Function InkjetRecordsNotFoundException(ByVal field_name, ByVal field_val)
  166. InkjetRecordsNotFoundException = "InkjetRecords was not found with " & field_name & " of '" & field_val & "'."
  167. End Function
  168. Private Function InkjetRecordsList(rs)
  169. dim list : set list = new LinkedList_Class
  170. dim model
  171. Do until rs.EOF
  172. set model = new InkjetRecordsModel_Class
  173. list.Push Automapper.AutoMap(rs, model)
  174. rs.MoveNext
  175. Loop
  176. set InkjetRecordsList = list
  177. End Function
  178. Public Sub AddNew(ByRef model)
  179. dim sql : sql = "INSERT INTO [InkjetRecords] (" &_
  180. "[KitID]," &_
  181. "[VOTERID]," &_
  182. "[LASTNAME]," &_
  183. "[FIRSTNAME]," &_
  184. "[MIDDLENAME]," &_
  185. "[SUFFIX]," &_
  186. "[PRECINCT]," &_
  187. "[ADDRESS1]," &_
  188. "[ADDRESS2]," &_
  189. "[ADDRESS3]," &_
  190. "[ADDRESS4]," &_
  191. "[ADDRESS5]," &_
  192. "[APPSENT]," &_
  193. "[APPRETURNED]," &_
  194. "[BALSENT]," &_
  195. "[BALRETURNED]," &_
  196. "[CountingBoard]," &_
  197. "[UOCAVASTATUS]," &_
  198. "[EMAILADDRESS]," &_
  199. "[PHONENUMBER]," &_
  200. "[BALLOT_NUMBER]," &_
  201. "[CassADDRESS1]," &_
  202. "[CassADDRESS2]," &_
  203. "[CassADDRESS3]," &_
  204. "[CassADDRESS4]," &_
  205. "[CassADDRESS5])" &_
  206. "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
  207. DAL.Execute sql, Array(model.KitID, _
  208. model.VOTERID, _
  209. model.LASTNAME, _
  210. model.FIRSTNAME, _
  211. model.MIDDLENAME, _
  212. model.SUFFIX, _
  213. model.PRECINCT, _
  214. model.ADDRESS1, _
  215. model.ADDRESS2, _
  216. model.ADDRESS3, _
  217. model.ADDRESS4, _
  218. model.ADDRESS5, _
  219. model.APPSENT, _
  220. model.APPRETURNED, _
  221. model.BALSENT, _
  222. model.BALRETURNED, _
  223. model.CountingBoard, _
  224. model.UOCAVASTATUS, _
  225. model.EMAILADDRESS, _
  226. model.PHONENUMBER, _
  227. model.BALLOT_NUMBER, _
  228. model.CassADDRESS1, _
  229. model.CassADDRESS2, _
  230. model.CassADDRESS3, _
  231. model.CassADDRESS4, _
  232. model.CassADDRESS5)
  233. sql = "SELECT TOP 1 ID FROM [InkjetRecords] ORDER BY ID DESC"
  234. dim rs : set rs = DAL.Query(sql, empty)
  235. model.ID = rs("ID")
  236. Destroy rs
  237. End Sub
  238. Public Sub Update(model)
  239. dim sql : sql = "UPDATE [InkjetRecords] SET [KitID] = ?," &_
  240. "[VOTERID] = ?," &_
  241. "[LASTNAME] = ?," &_
  242. "[FIRSTNAME] = ?," &_
  243. "[MIDDLENAME] = ?," &_
  244. "[SUFFIX] = ?," &_
  245. "[PRECINCT] = ?," &_
  246. "[ADDRESS1] = ?," &_
  247. "[ADDRESS2] = ?," &_
  248. "[ADDRESS3] = ?," &_
  249. "[ADDRESS4] = ?," &_
  250. "[ADDRESS5] = ?," &_
  251. "[APPSENT] = ?," &_
  252. "[APPRETURNED] = ?," &_
  253. "[BALSENT] = ?," &_
  254. "[BALRETURNED] = ?," &_
  255. "[CountingBoard] = ?," &_
  256. "[UOCAVASTATUS] = ?," &_
  257. "[EMAILADDRESS] = ?," &_
  258. "[PHONENUMBER] = ?," &_
  259. "[BALLOT_NUMBER] = ?," &_
  260. "[CassADDRESS1] = ?," &_
  261. "[CassADDRESS2] = ?," &_
  262. "[CassADDRESS3] = ?," &_
  263. "[CassADDRESS4] = ?," &_
  264. "[CassADDRESS5] = ?" &_
  265. " WHERE [ID] = ?"
  266. DAL.Execute sql, Array(model.KitID, _
  267. model.VOTERID, _
  268. model.LASTNAME, _
  269. model.FIRSTNAME, _
  270. model.MIDDLENAME, _
  271. model.SUFFIX, _
  272. model.PRECINCT, _
  273. model.ADDRESS1, _
  274. model.ADDRESS2, _
  275. model.ADDRESS3, _
  276. model.ADDRESS4, _
  277. model.ADDRESS5, _
  278. model.APPSENT, _
  279. model.APPRETURNED, _
  280. model.BALSENT, _
  281. model.BALRETURNED, _
  282. model.CountingBoard, _
  283. model.UOCAVASTATUS, _
  284. model.EMAILADDRESS, _
  285. model.PHONENUMBER, _
  286. model.BALLOT_NUMBER, _
  287. model.CassADDRESS1, _
  288. model.CassADDRESS2, _
  289. model.CassADDRESS3, _
  290. model.CassADDRESS4, _
  291. model.CassADDRESS5, _
  292. model.ID)
  293. End Sub
  294. Public Sub Delete(id)
  295. dim sql : sql = "DELETE FROM [InkjetRecords] WHERE [ID] = ?"
  296. DAL.Execute sql, id
  297. End Sub
  298. End Class
  299. dim InkjetRecordsRepository__Singleton
  300. Function InkjetRecordsRepository()
  301. If IsEmpty(InkjetRecordsRepository__Singleton) then
  302. set InkjetRecordsRepository__Singleton = new InkjetRecordsRepository_Class
  303. End If
  304. set InkjetRecordsRepository = InkjetRecordsRepository__Singleton
  305. End Function
  306. %>

Powered by TurnKey Linux.