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.

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

Powered by TurnKey Linux.